private static ElasticsearchChannelOptions <LogEvent> CreateChannelOptions(ElasticsearchLoggerOptions options, IChannelSetup[] channelConfigurations) { var channelOptions = new ElasticsearchChannelOptions <LogEvent> { Index = options.Index, IndexOffset = options.IndexOffset, ConnectionPoolType = options.ShipTo.ConnectionPoolType, WriteEvent = async(stream, ctx, logEvent) => await logEvent.SerializeAsync(stream, ctx).ConfigureAwait(false), TimestampLookup = l => l.Timestamp }; if (options.ShipTo.ConnectionPoolType == ConnectionPoolType.Cloud || options.ShipTo.ConnectionPoolType == ConnectionPoolType.Unknown && !string.IsNullOrEmpty(options.ShipTo.CloudId)) { channelOptions.ShipTo = !string.IsNullOrWhiteSpace(options.ShipTo.Username) ? new ShipTo(options.ShipTo.CloudId, options.ShipTo.Username, options.ShipTo.Password) : new ShipTo(options.ShipTo.CloudId, options.ShipTo.ApiKey); } else { channelOptions.ShipTo = new ShipTo(options.ShipTo.NodeUris, options.ShipTo.ConnectionPoolType); } foreach (var channelSetup in channelConfigurations) { channelSetup.ConfigureChannel(channelOptions); } return(channelOptions); }
public TestSession(ITransport <ITransportConfiguration> transport) { Transport = transport; BufferOptions = new BufferOptions <Base>() { ConcurrentConsumers = 1, MaxConsumerBufferSize = 2, MaxConsumerBufferLifetime = TimeSpan.FromSeconds(10), WaitHandle = WaitHandle, MaxRetries = 3, BackoffPeriod = times => TimeSpan.FromMilliseconds(1), ServerRejectionCallback = (list) => Interlocked.Increment(ref _rejections), BulkAttemptCallback = (c, a) => Interlocked.Increment(ref _requests), ElasticsearchResponseCallback = (r, b) => Interlocked.Increment(ref _responses), MaxRetriesExceededCallback = (list) => Interlocked.Increment(ref _maxRetriesExceeded), RetryCallBack = (list) => Interlocked.Increment(ref _retries), ExceptionCallback = (e) => LastException = e }; ChannelOptions = new ElasticsearchChannelOptions <Base>(transport) { BufferOptions = BufferOptions }; Channel = new ElasticsearchChannel <Base>(ChannelOptions); }