internal void ReleaseClient(SpannerClient spannerClient, SpannerConnectionStringBuilder connectionStringBuilder) { if (spannerClient != null) { var key = new ClientCredentialKey(connectionStringBuilder); CredentialClientPool poolEntry; if (_clientPoolByCredential.TryGetValue(key, out poolEntry)) { poolEntry.ReleaseClient(spannerClient); } else { Logger.Error(() => "An attempt was made to release an unrecognized spanner client to the pool."); } } }
internal SpannerClientCreationOptions(SpannerConnectionStringBuilder builder) { var emulatorBuilder = new SpannerClientBuilder { EmulatorDetection = builder.EmulatorDetection, EnvironmentVariableProvider = builder.EnvironmentVariableProvider }.MaybeCreateEmulatorClientBuilder(); UsesEmulator = emulatorBuilder is object; // If the client connects to the emulator use its endpoint (regardless of builder.Endpoint) Endpoint = emulatorBuilder?.Endpoint ?? builder.EndPoint; _credentialsFile = builder.CredentialFile; // If the client connects to the emulator, use its credentials (regardless of builder.CredentialOverride) _credentialsOverride = emulatorBuilder?.ChannelCredentials ?? builder.CredentialOverride; MaximumGrpcChannels = builder.MaximumGrpcChannels; MaximumConcurrentStreamsLowWatermark = (uint)builder.MaxConcurrentStreamsLowWatermark; }
public ClientCredentialKey(SpannerConnectionStringBuilder connectionStringBuilder) { Credentials = connectionStringBuilder.GetCredentials(); Endpoint = connectionStringBuilder.EndPoint ?? SpannerClient.DefaultEndpoint; AdditionalOptions = connectionStringBuilder; }
/// <summary> /// Creates a SpannerConnection with a datasource contained in connectionString. /// </summary> /// <param name="connectionStringBuilder"> /// A SpannerConnectionStringBuilder containing a formatted connection string. Must not be null. /// </param> public SpannerConnection(SpannerConnectionStringBuilder connectionStringBuilder) { GaxPreconditions.CheckNotNull(connectionStringBuilder, nameof(connectionStringBuilder)); TrySetNewConnectionInfo(connectionStringBuilder); }