private ConfigServiceV2Settings(ConfigServiceV2Settings existing) : base(existing) { GaxPreconditions.CheckNotNull(existing, nameof(existing)); ListSinksSettings = existing.ListSinksSettings?.Clone(); GetSinkSettings = existing.GetSinkSettings?.Clone(); CreateSinkSettings = existing.CreateSinkSettings?.Clone(); UpdateSinkSettings = existing.UpdateSinkSettings?.Clone(); DeleteSinkSettings = existing.DeleteSinkSettings?.Clone(); }
/// <summary> /// Synchronously creates a <see cref="ConfigServiceV2Client"/>, applying defaults for all unspecified settings. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="ConfigServiceV2Settings"/>.</param> /// <param name="credentials">Optional <see cref="ChannelCredentials"/>.</param> /// <returns>The created <see cref="ConfigServiceV2Client"/>.</returns> public static ConfigServiceV2Client Create( ServiceEndpoint endpoint = null, ConfigServiceV2Settings settings = null, ChannelCredentials credentials = null) { Channel channel = ClientHelper.CreateChannel(endpoint ?? DefaultEndpoint, credentials); ConfigServiceV2.ConfigServiceV2Client grpcClient = new ConfigServiceV2.ConfigServiceV2Client(channel); return(new ConfigServiceV2ClientImpl(grpcClient, settings)); }
// Note: we could have parameterless overloads of Create and CreateAsync, // documented to just use the default endpoint, settings and credentials. // Pros: // - Might be more reassuring on first use // - Allows method group conversions // Con: overloads! /// <summary> /// Asynchronously creates a <see cref="ConfigServiceV2Client"/>, applying defaults for all unspecified settings. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="ConfigServiceV2Settings"/>.</param> /// <param name="credentials">Optional <see cref="ChannelCredentials"/>.</param> /// <returns>The task representing the created <see cref="ConfigServiceV2Client"/>.</returns> public static async Task <ConfigServiceV2Client> CreateAsync( ServiceEndpoint endpoint = null, ConfigServiceV2Settings settings = null, ChannelCredentials credentials = null) { Channel channel = await ClientHelper.CreateChannelAsync(endpoint ?? DefaultEndpoint, credentials).ConfigureAwait(false); ConfigServiceV2.ConfigServiceV2Client grpcClient = new ConfigServiceV2.ConfigServiceV2Client(channel); return(new ConfigServiceV2ClientImpl(grpcClient, settings)); }
public ConfigServiceV2ClientImpl(ConfigServiceV2.ConfigServiceV2Client grpcClient, ConfigServiceV2Settings settings) { this.GrpcClient = grpcClient; ConfigServiceV2Settings effectiveSettings = settings ?? ConfigServiceV2Settings.GetDefault(); _clientHelper = new ClientHelper(effectiveSettings); _callListSinks = _clientHelper.BuildApiCall <ListSinksRequest, ListSinksResponse>( GrpcClient.ListSinksAsync, GrpcClient.ListSinks, effectiveSettings.ListSinksSettings); _callGetSink = _clientHelper.BuildApiCall <GetSinkRequest, LogSink>( GrpcClient.GetSinkAsync, GrpcClient.GetSink, effectiveSettings.GetSinkSettings); _callCreateSink = _clientHelper.BuildApiCall <CreateSinkRequest, LogSink>( GrpcClient.CreateSinkAsync, GrpcClient.CreateSink, effectiveSettings.CreateSinkSettings); _callUpdateSink = _clientHelper.BuildApiCall <UpdateSinkRequest, LogSink>( GrpcClient.UpdateSinkAsync, GrpcClient.UpdateSink, effectiveSettings.UpdateSinkSettings); _callDeleteSink = _clientHelper.BuildApiCall <DeleteSinkRequest, Empty>( GrpcClient.DeleteSinkAsync, GrpcClient.DeleteSink, effectiveSettings.DeleteSinkSettings); }
public ConfigServiceV2ClientImpl(ConfigServiceV2.IConfigServiceV2Client grpcClient, ConfigServiceV2Settings settings) { this.GrpcClient = grpcClient; ConfigServiceV2Settings effectiveSettings = settings ?? ConfigServiceV2Settings.GetDefault(); IClock effectiveClock = effectiveSettings.Clock ?? SystemClock.Instance; _clientHelper = new ClientHelper(effectiveSettings); _callListSinks = _clientHelper.BuildApiCall <ListSinksRequest, ListSinksResponse>(GrpcClient.ListSinksAsync, GrpcClient.ListSinks) .WithRetry(effectiveSettings.ListSinksRetry, effectiveClock, null); _callGetSink = _clientHelper.BuildApiCall <GetSinkRequest, LogSink>(GrpcClient.GetSinkAsync, GrpcClient.GetSink) .WithRetry(effectiveSettings.GetSinkRetry, effectiveClock, null); _callCreateSink = _clientHelper.BuildApiCall <CreateSinkRequest, LogSink>(GrpcClient.CreateSinkAsync, GrpcClient.CreateSink) .WithRetry(effectiveSettings.CreateSinkRetry, effectiveClock, null); _callUpdateSink = _clientHelper.BuildApiCall <UpdateSinkRequest, LogSink>(GrpcClient.UpdateSinkAsync, GrpcClient.UpdateSink) .WithRetry(effectiveSettings.UpdateSinkRetry, effectiveClock, null); _callDeleteSink = _clientHelper.BuildApiCall <DeleteSinkRequest, Empty>(GrpcClient.DeleteSinkAsync, GrpcClient.DeleteSink) .WithRetry(effectiveSettings.DeleteSinkRetry, effectiveClock, null); }
/// <summary> /// Creates a <see cref="ConfigServiceV2Client"/> which uses the specified channel for remote operations. /// </summary> /// <param name="channel">The <see cref="Channel"/> for remote operations. Must not be null.</param> /// <param name="settings">Optional <see cref="ConfigServiceV2Settings"/>.</param> /// <returns>The created <see cref="ConfigServiceV2Client"/>.</returns> public static ConfigServiceV2Client Create(Channel channel, ConfigServiceV2Settings settings = null) { GaxPreconditions.CheckNotNull(channel, nameof(channel)); ConfigServiceV2.ConfigServiceV2Client grpcClient = new ConfigServiceV2.ConfigServiceV2Client(channel); return(new ConfigServiceV2ClientImpl(grpcClient, settings)); }
/// <summary> /// Synchronously creates a <see cref="ConfigServiceV2Client"/>, applying defaults for all unspecified settings, /// and creating a channel connecting to the given endpoint with application default credentials where /// necessary. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="ConfigServiceV2Settings"/>.</param> /// <returns>The created <see cref="ConfigServiceV2Client"/>.</returns> public static ConfigServiceV2Client Create(ServiceEndpoint endpoint = null, ConfigServiceV2Settings settings = null) { Channel channel = s_channelPool.GetChannel(endpoint ?? DefaultEndpoint); return(Create(channel, settings)); }
/// <summary> /// Wrap a GRPC ConfigServiceV2 client for more convenient use. /// </summary> /// <param name="grpcClient">A GRPC client to wrap.</param> /// <param name="settings"> /// An optional <see cref="ConfigServiceV2Settings"/> to configure this wrapper. /// If null or not specified, then the default settings are used. /// </param> /// <returns>A <see cref="ConfigServiceV2Client"/> that wraps the specified GRPC client.</returns> public static ConfigServiceV2Client ToClient( this ConfigServiceV2.ConfigServiceV2Client grpcClient, ConfigServiceV2Settings settings = null ) => new ConfigServiceV2ClientImpl(grpcClient, settings);
// Note: we could have parameterless overloads of Create and CreateAsync, // documented to just use the default endpoint, settings and credentials. // Pros: // - Might be more reassuring on first use // - Allows method group conversions // Con: overloads! /// <summary> /// Asynchronously creates a <see cref="ConfigServiceV2Client"/>, applying defaults for all unspecified settings, /// and creating a channel connecting to the given endpoint with application default credentials where /// necessary. /// </summary> /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param> /// <param name="settings">Optional <see cref="ConfigServiceV2Settings"/>.</param> /// <returns>The task representing the created <see cref="ConfigServiceV2Client"/>.</returns> public static async Task <ConfigServiceV2Client> CreateAsync(ServiceEndpoint endpoint = null, ConfigServiceV2Settings settings = null) { Channel channel = await s_channelPool.GetChannelAsync(endpoint ?? DefaultEndpoint).ConfigureAwait(false); return(Create(channel, settings)); }