Exemplo n.º 1
0
 public static IServiceCollection AddElasticSearchTelemetryReplicator(
     this IServiceCollection services,
     Action <ElasticSearchTelemetryReplicatorOptions> configure)
 {
     services.AddSingleton(provider =>
     {
         var options = new ElasticSearchTelemetryReplicatorOptions();
         configure?.Invoke(options);
         return(options);
     });
     services.AddSingleton <ElasticSearchTelemetryReplicator>();
     services.AddSingleton <ITelemetryReplicator, ElasticSearchTelemetryReplicator>();
     return(services);
 }
Exemplo n.º 2
0
 public ElasticSearchTelemetryReplicator(
     ElasticSearchTelemetryReplicatorOptions options,
     ILoggerFactory loggerFactory)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (loggerFactory == null)
     {
         throw new ArgumentNullException(nameof(loggerFactory));
     }
     if (options.BulkEndPoint == null)
     {
         throw new ArgumentException("EndPoint is required.");
     }
     if (false == options.BulkEndPoint.IsAbsoluteUri)
     {
         throw new ArgumentException("EndPoint must be an absolute uri.");
     }
     if (options.IndexSelector == null)
     {
         throw new ArgumentException("IndexSelector is required.");
     }
     if (options.HttpClientFactory == null)
     {
         options.HttpClientFactory = CreateDefaultHttpClient;
     }
     if (options.JsonSerializerSettings == null)
     {
         options.JsonSerializerSettings = GetDefaultSerializationSettings();
     }
     this.options = options;
     httpClient   = options.HttpClientFactory();
     logger       = loggerFactory.CreateLogger <ElasticSearchTelemetryReplicator>();
 }