Exemple #1
0
        public MetricsServiceV2ClientImpl(MetricsServiceV2.IMetricsServiceV2Client grpcClient, MetricsServiceV2Settings settings)
        {
            this.GrpcClient = grpcClient;
            MetricsServiceV2Settings effectiveSettings = settings ?? MetricsServiceV2Settings.GetDefault();
            IClock effectiveClock = effectiveSettings.Clock ?? SystemClock.Instance;

            _clientHelper       = new ClientHelper(effectiveSettings);
            _callListLogMetrics = _clientHelper.BuildApiCall <ListLogMetricsRequest, ListLogMetricsResponse>(GrpcClient.ListLogMetricsAsync, GrpcClient.ListLogMetrics)
                                  .WithRetry(effectiveSettings.ListLogMetricsRetry, effectiveClock, null);
            _callGetLogMetric = _clientHelper.BuildApiCall <GetLogMetricRequest, LogMetric>(GrpcClient.GetLogMetricAsync, GrpcClient.GetLogMetric)
                                .WithRetry(effectiveSettings.GetLogMetricRetry, effectiveClock, null);
            _callCreateLogMetric = _clientHelper.BuildApiCall <CreateLogMetricRequest, LogMetric>(GrpcClient.CreateLogMetricAsync, GrpcClient.CreateLogMetric)
                                   .WithRetry(effectiveSettings.CreateLogMetricRetry, effectiveClock, null);
            _callUpdateLogMetric = _clientHelper.BuildApiCall <UpdateLogMetricRequest, LogMetric>(GrpcClient.UpdateLogMetricAsync, GrpcClient.UpdateLogMetric)
                                   .WithRetry(effectiveSettings.UpdateLogMetricRetry, effectiveClock, null);
            _callDeleteLogMetric = _clientHelper.BuildApiCall <DeleteLogMetricRequest, Empty>(GrpcClient.DeleteLogMetricAsync, GrpcClient.DeleteLogMetric)
                                   .WithRetry(effectiveSettings.DeleteLogMetricRetry, effectiveClock, null);
        }
Exemple #2
0
 /// <summary>
 /// Wrap a GRPC MetricsServiceV2 client for more convenient use.
 /// </summary>
 /// <param name="grpcClient">A GRPC client to wrap.</param>
 /// <param name="settings">
 /// An optional <see cref="MetricsServiceV2Settings"/> to configure this wrapper.
 /// If null or not specified, then the default settings are used.
 /// </param>
 /// <returns>A <see cref="MetricsServiceV2Client"/> that wraps the specified GRPC client.</returns>
 public static MetricsServiceV2Client ToClient(
     this MetricsServiceV2.IMetricsServiceV2Client grpcClient,
     MetricsServiceV2Settings settings = null
     ) => new MetricsServiceV2ClientImpl(grpcClient, settings);