private LoggingServiceV2Settings(LoggingServiceV2Settings existing) : base(existing)
 {
     GaxPreconditions.CheckNotNull(existing, nameof(existing));
     DeleteLogSettings       = existing.DeleteLogSettings?.Clone();
     WriteLogEntriesSettings = existing.WriteLogEntriesSettings?.Clone();
     ListLogEntriesSettings  = existing.ListLogEntriesSettings?.Clone();
 }
        public LoggingServiceV2ClientImpl(LoggingServiceV2.ILoggingServiceV2Client grpcClient, LoggingServiceV2Settings settings)
        {
            this.GrpcClient = grpcClient;
            LoggingServiceV2Settings effectiveSettings = settings ?? LoggingServiceV2Settings.GetDefault();

            _clientHelper = new ClientHelper(effectiveSettings);
        }
Ejemplo n.º 3
0
 private LoggingServiceV2Settings(LoggingServiceV2Settings existing) : base(existing)
 {
     GaxPreconditions.CheckNotNull(existing, nameof(existing));
     DeleteLogRetry       = existing.DeleteLogRetry?.Clone();
     WriteLogEntriesRetry = existing.WriteLogEntriesRetry?.Clone();
     ListLogEntriesRetry  = existing.ListLogEntriesRetry?.Clone();
     ListMonitoredResourceDescriptorsRetry = existing.ListMonitoredResourceDescriptorsRetry?.Clone();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Synchronously creates a <see cref="LoggingServiceV2Client"/>, applying defaults for all unspecified settings.
        /// </summary>
        /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param>
        /// <param name="settings">Optional <see cref="LoggingServiceV2Settings"/>.</param>
        /// <param name="credentials">Optional <see cref="ChannelCredentials"/>.</param>
        /// <returns>The created <see cref="LoggingServiceV2Client"/>.</returns>
        public static LoggingServiceV2Client Create(
            ServiceEndpoint endpoint          = null,
            LoggingServiceV2Settings settings = null,
            ChannelCredentials credentials    = null)
        {
            Channel channel = ClientHelper.CreateChannel(endpoint ?? DefaultEndpoint, credentials);

            LoggingServiceV2.LoggingServiceV2Client grpcClient = new LoggingServiceV2.LoggingServiceV2Client(channel);
            return(new LoggingServiceV2ClientImpl(grpcClient, settings));
        }
Ejemplo n.º 5
0
        // 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="LoggingServiceV2Client"/>, applying defaults for all unspecified settings.
        /// </summary>
        /// <param name="endpoint">Optional <see cref="ServiceEndpoint"/>.</param>
        /// <param name="settings">Optional <see cref="LoggingServiceV2Settings"/>.</param>
        /// <param name="credentials">Optional <see cref="ChannelCredentials"/>.</param>
        /// <returns>The task representing the created <see cref="LoggingServiceV2Client"/>.</returns>
        public static async Task <LoggingServiceV2Client> CreateAsync(
            ServiceEndpoint endpoint          = null,
            LoggingServiceV2Settings settings = null,
            ChannelCredentials credentials    = null)
        {
            Channel channel = await ClientHelper.CreateChannelAsync(endpoint ?? DefaultEndpoint, credentials).ConfigureAwait(false);

            LoggingServiceV2.LoggingServiceV2Client grpcClient = new LoggingServiceV2.LoggingServiceV2Client(channel);
            return(new LoggingServiceV2ClientImpl(grpcClient, settings));
        }
        public LoggingServiceV2ClientImpl(LoggingServiceV2.LoggingServiceV2Client grpcClient, LoggingServiceV2Settings settings)
        {
            this.GrpcClient = grpcClient;
            LoggingServiceV2Settings effectiveSettings = settings ?? LoggingServiceV2Settings.GetDefault();

            _clientHelper  = new ClientHelper(effectiveSettings);
            _callDeleteLog = _clientHelper.BuildApiCall <DeleteLogRequest, Empty>(
                GrpcClient.DeleteLogAsync, GrpcClient.DeleteLog, effectiveSettings.DeleteLogSettings);
            _callWriteLogEntries = _clientHelper.BuildApiCall <WriteLogEntriesRequest, WriteLogEntriesResponse>(
                GrpcClient.WriteLogEntriesAsync, GrpcClient.WriteLogEntries, effectiveSettings.WriteLogEntriesSettings);
            _callListLogEntries = _clientHelper.BuildApiCall <ListLogEntriesRequest, ListLogEntriesResponse>(
                GrpcClient.ListLogEntriesAsync, GrpcClient.ListLogEntries, effectiveSettings.ListLogEntriesSettings);
        }
Ejemplo n.º 7
0
        public LoggingServiceV2ClientImpl(LoggingServiceV2.ILoggingServiceV2Client grpcClient, LoggingServiceV2Settings settings)
        {
            this.GrpcClient = grpcClient;
            LoggingServiceV2Settings effectiveSettings = settings ?? LoggingServiceV2Settings.GetDefault();
            IClock effectiveClock = effectiveSettings.Clock ?? SystemClock.Instance;

            _clientHelper  = new ClientHelper(effectiveSettings);
            _callDeleteLog = _clientHelper.BuildApiCall <DeleteLogRequest, Empty>(GrpcClient.DeleteLogAsync, GrpcClient.DeleteLog)
                             .WithRetry(effectiveSettings.DeleteLogRetry, effectiveClock, null);
            _callWriteLogEntries = _clientHelper.BuildApiCall <WriteLogEntriesRequest, WriteLogEntriesResponse>(GrpcClient.WriteLogEntriesAsync, GrpcClient.WriteLogEntries)
                                   .WithRetry(effectiveSettings.WriteLogEntriesRetry, effectiveClock, null);
            _callListLogEntries = _clientHelper.BuildApiCall <ListLogEntriesRequest, ListLogEntriesResponse>(GrpcClient.ListLogEntriesAsync, GrpcClient.ListLogEntries)
                                  .WithRetry(effectiveSettings.ListLogEntriesRetry, effectiveClock, null);
            _callListMonitoredResourceDescriptors = _clientHelper.BuildApiCall <ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>(GrpcClient.ListMonitoredResourceDescriptorsAsync, GrpcClient.ListMonitoredResourceDescriptors)
                                                    .WithRetry(effectiveSettings.ListMonitoredResourceDescriptorsRetry, effectiveClock, null);
        }
 /// <summary>
 /// Wrap a GRPC LoggingServiceV2 client for more convenient use.
 /// </summary>
 /// <param name="grpcClient">A GRPC client to wrap.</param>
 /// <param name="settings">
 /// An optional <see cref="LoggingServiceV2Settings"/> to configure this wrapper.
 /// If null or not specified, then the default settings are used.
 /// </param>
 /// <returns>A <see cref="LoggingServiceV2Client"/> that wraps the specified GRPC client.</returns>
 public static LoggingServiceV2Client ToClient(
     this LoggingServiceV2.LoggingServiceV2Client grpcClient,
     LoggingServiceV2Settings settings = null
     ) => new LoggingServiceV2ClientImpl(grpcClient, settings);
 /// <summary>
 /// Creates a <see cref="LoggingServiceV2Client"/> 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="LoggingServiceV2Settings"/>.</param>
 /// <returns>The created <see cref="LoggingServiceV2Client"/>.</returns>
 public static LoggingServiceV2Client Create(Channel channel, LoggingServiceV2Settings settings = null)
 {
     GaxPreconditions.CheckNotNull(channel, nameof(channel));
     LoggingServiceV2.LoggingServiceV2Client grpcClient = new LoggingServiceV2.LoggingServiceV2Client(channel);
     return(new LoggingServiceV2ClientImpl(grpcClient, settings));
 }
        /// <summary>
        /// Synchronously creates a <see cref="LoggingServiceV2Client"/>, 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="LoggingServiceV2Settings"/>.</param>
        /// <returns>The created <see cref="LoggingServiceV2Client"/>.</returns>
        public static LoggingServiceV2Client Create(ServiceEndpoint endpoint = null, LoggingServiceV2Settings settings = null)
        {
            Channel channel = s_channelPool.GetChannel(endpoint ?? DefaultEndpoint);

            return(Create(channel, 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="LoggingServiceV2Client"/>, 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="LoggingServiceV2Settings"/>.</param>
        /// <returns>The task representing the created <see cref="LoggingServiceV2Client"/>.</returns>
        public static async Task <LoggingServiceV2Client> CreateAsync(ServiceEndpoint endpoint = null, LoggingServiceV2Settings settings = null)
        {
            Channel channel = await s_channelPool.GetChannelAsync(endpoint ?? DefaultEndpoint).ConfigureAwait(false);

            return(Create(channel, settings));
        }