Пример #1
0
        public void Init(IProviderConfiguration config, string providerName, Logger logger, IServiceProvider serviceProvider)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (String.IsNullOrEmpty(providerName))
            {
                throw new ArgumentNullException(nameof(providerName));
            }

            // Creating an options object with all the config values
            _options = new KafkaStreamProviderOptions(config);

            if (!_options.UsingExternalMetrics)
            {
                Metric.Config.WithHttpEndpoint($"http://localhost:{_options.MetricsPort}/");
            }

            if (!_options.IncludeMetrics)
            {
                Metric.Context("KafkaStreamProvider").Advanced.CompletelyDisableMetrics();
            }

            _providerName      = providerName;
            _streamQueueMapper = new HashRingBasedStreamQueueMapper(_options.NumOfQueues, providerName);
            _logger            = logger;
            _adapter           = new KafkaQueueAdapter(_streamQueueMapper, _options, providerName, new KafkaBatchFactory(), _logger);
            _adapterCache      = new TimedQueueAdapterCache(this, TimeSpan.FromSeconds(_options.CacheTimespanInSeconds), _options.CacheSize, _options.CacheNumOfBuckets, logger);
        }
Пример #2
0
        public Task <IQueueAdapter> CreateAdapter()
        {
            if (_adapter == null)
            {
                _adapter = new KafkaQueueAdapter(_streamQueueMapper, _options, _providerName, new KafkaBatchFactory(_dataAdapterFactory()), _logger);
            }

            return(Task.FromResult <IQueueAdapter>(_adapter));
        }