// ListSubscriptions lists matching subscriptions. func (c *SubscriberClient) ListSubscriptions(ctx context.Context, req *pubsubpb.ListSubscriptionsRequest) *SubscriptionIterator { md, _ := metadata.FromContext(ctx) ctx = metadata.NewContext(ctx, metadata.Join(md, c.metadata)) it := &SubscriptionIterator{} it.InternalFetch = func(pageSize int, pageToken string) ([]*pubsubpb.Subscription, string, error) { var resp *pubsubpb.ListSubscriptionsResponse req.PageToken = pageToken if pageSize > math.MaxInt32 { req.PageSize = math.MaxInt32 } else { req.PageSize = int32(pageSize) } err := gax.Invoke(ctx, func(ctx context.Context) error { var err error resp, err = c.subscriberClient.ListSubscriptions(ctx, req) return err }, c.CallOptions.ListSubscriptions...) if err != nil { return nil, "", err } return resp.Subscriptions, resp.NextPageToken, nil } fetch := func(pageSize int, pageToken string) (string, error) { items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) if err != nil { return "", err } it.items = append(it.items, items...) return nextPageToken, nil } it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) return it }
// ListSubscriptions lists matching subscriptions. func (c *SubscriberClient) ListSubscriptions(ctx context.Context, req *pubsubpb.ListSubscriptionsRequest) *SubscriptionIterator { ctx = metadata.NewContext(ctx, c.metadata) it := &SubscriptionIterator{} it.apiCall = func() error { var resp *pubsubpb.ListSubscriptionsResponse err := gax.Invoke(ctx, func(ctx context.Context) error { var err error req.PageToken = it.nextPageToken req.PageSize = it.pageSize resp, err = c.client.ListSubscriptions(ctx, req) return err }, c.CallOptions.ListSubscriptions...) if err != nil { return err } if resp.NextPageToken == "" { it.atLastPage = true } it.nextPageToken = resp.NextPageToken it.items = resp.Subscriptions return nil } return it }