Esempio n. 1
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));
        }
Esempio n. 2
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);
        }
 /// <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));
 }