/// <summary> /// Creates a collection of <see cref="ChannelOption"/> instances which can be used to create a <see cref="Channel"/> /// or <see cref="GcpCallInvoker"/> pre-configured based on the specified settings (or the default settings if they /// are null). /// </summary> /// <remarks> /// <para> /// Note that if the options returned are used to create a <see cref="Channel"/>, the <see cref="BigtableServiceApiSettings.MaxChannels"/> /// and <see cref="BigtableServiceApiSettings.PreferredMaxStreamsPerChannel"/> settings values will be ignored. /// </para> /// </remarks> /// <param name="settings"> /// The settings with which to create channel options. May be null, in which case the default settings will be used. /// </param> /// <returns>A collection of <see cref="ChannelOption"/> instances.</returns> public static IEnumerable <ChannelOption> CreateChannelOptions(this BigtableServiceApiSettings settings) { // TODO: Use a cached collection of channel options if settings is null. var effectiveSettings = settings ?? BigtableServiceApiSettings.GetDefault(); var apiConfig = new ApiConfig { ChannelPool = new ChannelPoolConfig { MaxSize = effectiveSettings.MaxChannels, MaxConcurrentStreamsLowWatermark = effectiveSettings.PreferredMaxStreamsPerChannel } }; return(new[] { // Set channel send/recv message size to unlimited. new ChannelOption(ChannelOptions.MaxSendMessageLength, -1), new ChannelOption(ChannelOptions.MaxReceiveMessageLength, -1), // TODO: Figure out if there's a good way to test this new ChannelOption(ChannelOptions.PrimaryUserAgentString, BigtableClient.UserAgent), new ChannelOption(GcpCallInvoker.ApiConfigChannelArg, apiConfig.ToString()) }); }
partial void OnCopy(BigtableServiceApiSettings existing) { MutateRowsRetrySettings = existing.MutateRowsRetrySettings; ReadRowsRetrySettings = existing.ReadRowsRetrySettings; MaxChannels = existing.MaxChannels; PreferredMaxStreamsPerChannel = existing.PreferredMaxStreamsPerChannel; }
/// <summary> /// Creates a collection of <see cref="ChannelOption"/> instances which can be used to create a <see cref="Channel"/> /// or <see cref="GcpCallInvoker"/> pre-configured based on the specified settings (or the default settings if they /// are null). /// </summary> /// <remarks> /// <para> /// Note that if the options returned are used to create a <see cref="Channel"/>, the <see cref="BigtableServiceApiSettings.MaxChannels"/> /// and <see cref="BigtableServiceApiSettings.PreferredMaxStreamsPerChannel"/> settings values will be ignored. /// </para> /// </remarks> /// <param name="settings"> /// The settings with which to create channel options. May be null, in which case the default settings will be used. /// </param> /// <returns>A collection of <see cref="ChannelOption"/> instances.</returns> public static IEnumerable <ChannelOption> CreateChannelOptions(this BigtableServiceApiSettings settings) { if (settings == null) { return(s_defaultChannelOptions.Value); } return(CreateChannelOptionsImpl(settings)); }
/// <summary> /// Instantiate with the specified settings. /// </summary> /// <param name="clientCount">Optional. /// The number of <see cref="BigtableServiceApiClient"/>s to create and use within a <see cref="BigtableClient"/> instance. /// If not set will default to number of processors.</param> /// <param name="bigtableServiceApiSettings">Optional. The settings to use when creating <see cref="BigtableServiceApiClient"/> instances.</param> /// <param name="credentials">Optional. Credentials to use when creating <see cref="BigtableServiceApiClient"/> instances.</param> /// <param name="serviceEndpoint">Optional. /// The <see cref="ServiceEndpoint"/> to use when creating <see cref="BigtableServiceApiClient"/> instances.</param> public ClientCreationSettings( int?clientCount = null, BigtableServiceApiSettings bigtableServiceApiSettings = null, ChannelCredentials credentials = null, ServiceEndpoint serviceEndpoint = null) { ClientCount = clientCount; BigtableServiceApiSettings = bigtableServiceApiSettings; Credentials = credentials; ServiceEndpoint = serviceEndpoint; }
private static GrpcChannelOptions CreateChannelOptionsImpl(this BigtableServiceApiSettings settings) { var apiConfig = new ApiConfig { ChannelPool = new ChannelPoolConfig { MaxSize = settings.MaxChannels, MaxConcurrentStreamsLowWatermark = settings.PreferredMaxStreamsPerChannel } }; return(GrpcChannelOptions.Empty .WithPrimaryUserAgent(BigtableClient.UserAgent) .WithMaxSendMessageSize(-1) .WithMaxReceiveMessageSize(-1) .WithCustomOption(GcpCallInvoker.ApiConfigChannelArg, apiConfig.ToString())); }
private static ChannelOption[] CreateChannelOptionsImpl(this BigtableServiceApiSettings settings) { var apiConfig = new ApiConfig { ChannelPool = new ChannelPoolConfig { MaxSize = settings.MaxChannels, MaxConcurrentStreamsLowWatermark = settings.PreferredMaxStreamsPerChannel } }; return(new[] { // Set channel send/recv message size to unlimited. new ChannelOption(ChannelOptions.MaxSendMessageLength, -1), new ChannelOption(ChannelOptions.MaxReceiveMessageLength, -1), // TODO: Figure out if there's a good way to test this new ChannelOption(ChannelOptions.PrimaryUserAgentString, BigtableClient.UserAgent), new ChannelOption(GcpCallInvoker.ApiConfigChannelArg, apiConfig.ToString()) }); }
partial void OnConstruction( Bigtable.BigtableClient grpcClient, BigtableServiceApiSettings effectiveSettings, ClientHelper clientHelper) => _defaultSettings = effectiveSettings.Clone();
/// <summary> /// Creates a collection of <see cref="ChannelOption"/> instances which can be used to create a <see cref="Channel"/> /// or <see cref="GcpCallInvoker"/> pre-configured based on the specified settings (or the default settings if they /// are null). /// </summary> /// <remarks> /// <para> /// Note that if the options returned are used to create a <see cref="Channel"/>, the <see cref="BigtableServiceApiSettings.MaxChannels"/> /// and <see cref="BigtableServiceApiSettings.PreferredMaxStreamsPerChannel"/> settings values will be ignored. /// </para> /// </remarks> /// <param name="settings"> /// The settings with which to create channel options. May be null, in which case the default settings will be used. /// </param> /// <returns>A collection of <see cref="ChannelOption"/> instances.</returns> public static GrpcChannelOptions CreateChannelOptions(this BigtableServiceApiSettings settings) => settings is null ? s_defaultChannelOptions.Value : CreateChannelOptionsImpl(settings);
partial void OnCopy(BigtableServiceApiSettings existing) { MutateRowsRetrySettings = existing.MutateRowsRetrySettings; ReadRowsRetrySettings = existing.ReadRowsRetrySettings; }
/// <summary> /// Synchronously creates a <see cref="BigtableClient"/>, applying defaults for all unspecified settings, /// using the specified <see cref="CallInvoker"/> for API requests. /// </summary> /// <param name="callInvoker">The <see cref="CallInvoker"/> which performs API requests. Must not be null.</param> /// <param name="settings">Optional <see cref="BigtableServiceApiSettings"/> to control API requests.</param> /// <returns>The created <see cref="BigtableClient"/>.</returns> public static BigtableClient Create(CallInvoker callInvoker, BigtableServiceApiSettings settings = null) => Create(BigtableServiceApiClient.Create(GaxPreconditions.CheckNotNull(callInvoker, nameof(callInvoker)), settings));
/// <summary> /// Synchronously creates a <see cref="BigtableClient"/>, applying defaults for all unspecified settings, /// and creating channels connecting to the given endpoint with application default credentials where /// necessary. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/> to use when connecting to Bigtable.</param> /// <param name="settings">Optional <see cref="BigtableServiceApiSettings"/> to control API requests.</param> /// <returns>The created <see cref="BigtableClient"/>.</returns> public static BigtableClient Create(ServiceEndpoint endpoint = null, BigtableServiceApiSettings settings = null) => Task.Run(() => CreateAsync(endpoint, settings)).ResultWithUnwrappedExceptions();
// TODO: Auto-generate these if possible/easy after multi-channel support is added. /// <summary> /// Asynchronously creates a <see cref="BigtableClient"/>, applying defaults for all unspecified settings, /// and creating channels connecting to the given endpoint with application default credentials where /// necessary. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/> to use when connecting to Bigtable.</param> /// <param name="settings">Optional <see cref="BigtableServiceApiSettings"/> to control API requests.</param> /// <returns>The task representing the created <see cref="BigtableClient"/>.</returns> public static async Task <BigtableClient> CreateAsync(ServiceEndpoint endpoint = null, BigtableServiceApiSettings settings = null) { var client = await BigtableServiceApiClient.CreateAsync(endpoint, settings).ConfigureAwait(false); return(new BigtableClientImpl(client)); }