Skip to content

Commit

Permalink
fix(pubsublite): set a default grpc connection pool size of 8 (#4462)
Browse files Browse the repository at this point in the history
To ensure most users don't hit the limit of 100 streams per connection, if they have a high number of topic partitions.
  • Loading branch information
tmdiep committed Jul 20, 2021
1 parent f1b7c8b commit b7ce742
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pubsublite/internal/wire/rpc.go
Expand Up @@ -192,24 +192,30 @@ func defaultClientOptions(region string) []option.ClientOption {
}
}

func streamClientOptions(region string) []option.ClientOption {
// To ensure most users don't hit the limit of 100 streams per connection, if
// they have a high number of topic partitions.
return append(defaultClientOptions(region), option.WithGRPCConnectionPool(8))
}

// NewAdminClient creates a new gapic AdminClient for a region.
func NewAdminClient(ctx context.Context, region string, opts ...option.ClientOption) (*vkit.AdminClient, error) {
options := append(defaultClientOptions(region), opts...)
return vkit.NewAdminClient(ctx, options...)
}

func newPublisherClient(ctx context.Context, region string, opts ...option.ClientOption) (*vkit.PublisherClient, error) {
options := append(defaultClientOptions(region), opts...)
options := append(streamClientOptions(region), opts...)
return vkit.NewPublisherClient(ctx, options...)
}

func newSubscriberClient(ctx context.Context, region string, opts ...option.ClientOption) (*vkit.SubscriberClient, error) {
options := append(defaultClientOptions(region), opts...)
options := append(streamClientOptions(region), opts...)
return vkit.NewSubscriberClient(ctx, options...)
}

func newCursorClient(ctx context.Context, region string, opts ...option.ClientOption) (*vkit.CursorClient, error) {
options := append(defaultClientOptions(region), opts...)
options := append(streamClientOptions(region), opts...)
return vkit.NewCursorClient(ctx, options...)
}

Expand Down

0 comments on commit b7ce742

Please sign in to comment.