public void TestSetup() { state = Substitute.For <IStreamState>(); state.Name.Returns(StreamName); state.BufferPool.Returns(pool = Substitute.For <IBufferPool>()); state.Statistics.Returns(stats = Substitute.For <IStatisticsCollector>()); state.Settings.Returns(settings = new StreamSettings()); batcher = new BufferSnapshotBatcher(1); contentFactory = new RequestContentFactory(new BufferPool()); responseAnalyzer = new ResponseAnalyzer(ResponseAnalysisContext.Stream); statusAnalyzer = new StatusAnalyzer(); requestSender = Substitute.For <IGateRequestSender>(); sender = new StreamSender( () => GlobalApiKey, state, batcher, contentFactory, requestSender, responseAnalyzer, statusAnalyzer, new SynchronousConsoleLog()); cancellation = new CancellationTokenSource(); SetupBuffers(50, 100, 150); SetupResponses(HerculesStatus.Success); }
public HerculesGateClient([NotNull] HerculesGateClientSettings settings, [CanBeNull] ILog log) { this.settings = settings ?? throw new ArgumentNullException(nameof(settings)); this.log = log = (log ?? LogProvider.Get()).ForContext <HerculesGateClient>(); var bufferPool = new BufferPool(settings.MaxPooledBufferSize, settings.MaxPooledBuffersPerBucket); sender = new GateRequestSender(settings.Cluster, log, bufferPool, settings.AdditionalSetup); }
public StreamSender( [NotNull] Func <string> globalApiKeyProvider, [NotNull] IStreamState streamState, [NotNull] IBufferSnapshotBatcher snapshotBatcher, [NotNull] IRequestContentFactory contentFactory, [NotNull] IGateRequestSender gateRequestSender, [NotNull] IResponseAnalyzer responseAnalyzer, [NotNull] IStatusAnalyzer statusAnalyzer, [NotNull] ILog log) { this.globalApiKeyProvider = globalApiKeyProvider; this.streamState = streamState; this.snapshotBatcher = snapshotBatcher; this.contentFactory = contentFactory; this.gateRequestSender = gateRequestSender; this.responseAnalyzer = responseAnalyzer; this.statusAnalyzer = statusAnalyzer; this.log = log; }
public StreamSenderFactory(HerculesSinkSettings settings, ILog log) { this.log = log; var bufferPool = new BufferPool(settings.MaximumBatchSize * 2, settings.MaxParallelStreams * 8); apiKeyProvider = settings.ApiKeyProvider; contentFactory = new RequestContentFactory(bufferPool); snapshotBatcher = new BufferSnapshotBatcher(settings.MaximumBatchSize); requestSender = new GateRequestSender( settings.Cluster, settings.SuppressVerboseLogging ? log.WithMinimumLevel(LogLevel.Warn).WithLevelsTransformation(SuppressVerboseLoggingLevelsTransformation) : log, bufferPool, settings.AdditionalSetup); responseAnalyzer = new ResponseAnalyzer(ResponseAnalysisContext.Stream); statusAnalyzer = new StatusAnalyzer(); }