fix(pubsublite): disable grpc stream retries (#5019)
Disable grpc-go automatically recreating streams. The Pub/Sub Lite library must reinitialize state when a new stream instance is created.
diff --git a/pubsublite/internal/wire/rpc.go b/pubsublite/internal/wire/rpc.go
index b164686..8512e7a 100644
--- a/pubsublite/internal/wire/rpc.go
+++ b/pubsublite/internal/wire/rpc.go
@@ -193,9 +193,13 @@
}
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))
+ return append(defaultClientOptions(region),
+ // To ensure most users don't hit the limit of 100 streams per connection, if
+ // they have a high number of topic partitions.
+ option.WithGRPCConnectionPool(8),
+ // Stream reconnections must be handled here in order to reinitialize state,
+ // rather than in grpc-go.
+ option.WithGRPCDialOption(grpc.WithDisableRetry()))
}
// NewAdminClient creates a new gapic AdminClient for a region.