コード例 #1
0
        public HerculesStreamClient([NotNull] HerculesStreamClientSettings <T> settings, [CanBeNull] ILog log)
        {
            this.settings = settings;
            this.log      = log = (log ?? LogProvider.Get()).ForContext <HerculesStreamClient>();

            bufferPool = new BufferPool(settings.MaxPooledBufferSize, settings.MaxPooledBuffersPerBucket);

            client = new StreamApiRequestSender(settings.Cluster, log, bufferPool, settings.AdditionalSetup);
        }
コード例 #2
0
        public BatchesStreamConsumer([NotNull] BatchesStreamConsumerSettings <T> settings, [CanBeNull] ILog log)
        {
            this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
            this.log      = log = (log ?? LogProvider.Get()).ForContext <BatchesStreamConsumer <T> >();
            tracer        = settings.Tracer ?? TracerProvider.Get();

            var bufferPool = new BufferPool(settings.MaxPooledBufferSize, settings.MaxPooledBuffersPerBucket);

            client = new StreamApiRequestSender(settings.StreamApiCluster, log /*.WithErrorsTransformedToWarns()*/, bufferPool, settings.StreamApiClientAdditionalSetup);

            var instanceMetricContext = settings.InstanceMetricContext ?? new DevNullMetricContext();

            eventsMetric = instanceMetricContext.CreateIntegerGauge("events", "type", new IntegerGaugeConfig {
                ResetOnScrape = true
            });
            iterationMetric = instanceMetricContext.CreateSummary("iteration", "type", new SummaryConfig {
                Quantiles = new[] { 0.5, 0.75, 1 }
            });
            instanceMetricContext.CreateFuncGauge("events", "type").For("remaining").SetValueProvider(CountStreamRemainingEvents);
            instanceMetricContext.CreateFuncGauge("buffer", "type").For("rented_reader").SetValueProvider(() => BufferPool.Rented);
        }