Skip to content

Commit

Permalink
Set the MinOpened of the Spanner Client to 1
Browse files Browse the repository at this point in the history
Since the number of transactions executed by the Client created with wrench is usually small, I set MinOpened to 1.
  • Loading branch information
sinmetal committed Jan 21, 2025
1 parent 8249bb7 commit d71e0ec
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/spanner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@ func NewClient(ctx context.Context, config *Config) (*Client, error) {
opts = append(opts, option.WithCredentialsFile(config.CredentialsFile))
}

spannerClient, err := spanner.NewClient(ctx, config.URL(), opts...)
spannerClient, err := spanner.NewClientWithConfig(ctx, config.URL(),
spanner.ClientConfig{
SessionPoolConfig: spanner.SessionPoolConfig{
MaxOpened: spanner.DefaultSessionPoolConfig.MaxOpened,
MinOpened: 1,
MaxIdle: spanner.DefaultSessionPoolConfig.MaxIdle,
HealthCheckWorkers: spanner.DefaultSessionPoolConfig.HealthCheckWorkers,
HealthCheckInterval: spanner.DefaultSessionPoolConfig.HealthCheckInterval,
TrackSessionHandles: false,
InactiveTransactionRemovalOptions: spanner.DefaultSessionPoolConfig.InactiveTransactionRemovalOptions,
},
},
opts...)
if err != nil {
return nil, &Error{
Code: ErrorCodeCreateClient,
Expand Down

0 comments on commit d71e0ec

Please sign in to comment.