Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        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();
        }