public ConsumerConfiguration(
            ConsumerConfig consumerConfig,
            IEnumerable <string> topics,
            string consumerName,
            int workersCount,
            int bufferSize,
            Factory <IDistributionStrategy> distributionStrategyFactory,
            MiddlewareConfiguration middlewareConfiguration)
        {
            this.consumerConfig = consumerConfig ?? throw new ArgumentNullException(nameof(consumerConfig));

            if (string.IsNullOrEmpty(this.consumerConfig.GroupId))
            {
                throw new ArgumentNullException(nameof(consumerConfig.GroupId));
            }

            this.DistributionStrategyFactory = distributionStrategyFactory ?? throw new ArgumentNullException(nameof(distributionStrategyFactory));
            this.MiddlewareConfiguration     = middlewareConfiguration ?? throw new ArgumentNullException(nameof(middlewareConfiguration));
            this.Topics       = topics ?? throw new ArgumentNullException(nameof(topics));
            this.ConsumerName = consumerName ?? Guid.NewGuid().ToString();

            this.WorkersCount = workersCount > 0 ?
                                workersCount :
                                throw new ArgumentOutOfRangeException(
                                          nameof(workersCount),
                                          workersCount,
                                          "The value must be greater than 0");

            this.BufferSize = bufferSize > 0 ?
                              bufferSize :
                              throw new ArgumentOutOfRangeException(
                                        nameof(bufferSize),
                                        bufferSize,
                                        "The value must be greater than 0");
        }
 public ProducerConfiguration(
     ClusterConfiguration cluster,
     string topic,
     Acks?acks,
     MiddlewareConfiguration middlewareConfiguration,
     ProducerConfig baseProducerConfig)
 {
     this.Cluster = cluster ?? throw new ArgumentNullException(nameof(cluster));
     this.Topic   = string.IsNullOrWhiteSpace(topic) ? throw new ArgumentNullException(nameof(topic)) : topic;
     this.Acks    = acks;
     this.MiddlewareConfiguration = middlewareConfiguration;
     this.BaseProducerConfig      = baseProducerConfig;
 }
 public ProducerConfiguration(
     ClusterConfiguration cluster,
     string name,
     string defaultTopic,
     Acks?acks,
     MiddlewareConfiguration middlewareConfiguration,
     ProducerConfig baseProducerConfig)
 {
     this.Cluster                 = cluster ?? throw new ArgumentNullException(nameof(cluster));
     this.Name                    = name;
     this.DefaultTopic            = defaultTopic;
     this.Acks                    = acks;
     this.MiddlewareConfiguration = middlewareConfiguration;
     this.BaseProducerConfig      = baseProducerConfig;
 }
Esempio n. 4
0
        public ConsumerConfiguration(
            ConsumerConfig consumerConfig,
            IEnumerable <string> topics,
            string consumerName,
            ClusterConfiguration clusterConfiguration,
            bool managementDisabled,
            int workersCount,
            int bufferSize,
            Factory <IDistributionStrategy> distributionStrategyFactory,
            MiddlewareConfiguration middlewareConfiguration,
            bool autoStoreOffsets,
            TimeSpan autoCommitInterval,
            IReadOnlyList <Action <string> > statisticsHandlers,
            IReadOnlyList <Action <IDependencyResolver, List <TopicPartition> > > partitionsAssignedHandlers,
            IReadOnlyList <Action <IDependencyResolver, List <TopicPartitionOffset> > > partitionsRevokedHandlers,
            ConsumerCustomFactory customFactory)
        {
            this.consumerConfig = consumerConfig ?? throw new ArgumentNullException(nameof(consumerConfig));

            if (string.IsNullOrEmpty(this.consumerConfig.GroupId))
            {
                throw new ArgumentNullException(nameof(consumerConfig.GroupId));
            }

            this.DistributionStrategyFactory =
                distributionStrategyFactory ?? throw new ArgumentNullException(nameof(distributionStrategyFactory));
            this.MiddlewareConfiguration = middlewareConfiguration ?? throw new ArgumentNullException(nameof(middlewareConfiguration));
            this.AutoStoreOffsets        = autoStoreOffsets;
            this.AutoCommitInterval      = autoCommitInterval;
            this.Topics                     = topics ?? throw new ArgumentNullException(nameof(topics));
            this.ConsumerName               = consumerName ?? Guid.NewGuid().ToString();
            this.ClusterConfiguration       = clusterConfiguration;
            this.ManagementDisabled         = managementDisabled;
            this.WorkersCount               = workersCount;
            this.StatisticsHandlers         = statisticsHandlers;
            this.PartitionsAssignedHandlers = partitionsAssignedHandlers;
            this.PartitionsRevokedHandlers  = partitionsRevokedHandlers;
            this.CustomFactory              = customFactory;

            this.BufferSize = bufferSize > 0 ?
                              bufferSize :
                              throw new ArgumentOutOfRangeException(
                                        nameof(bufferSize),
                                        bufferSize,
                                        "The value must be greater than 0");
        }
Esempio n. 5
0
 public ProducerConfiguration(
     ClusterConfiguration cluster,
     string name,
     string defaultTopic,
     Acks?acks,
     MiddlewareConfiguration middlewareConfiguration,
     ProducerConfig baseProducerConfig,
     IReadOnlyList <Action <string> > statisticsHandlers)
 {
     this.Cluster                 = cluster ?? throw new ArgumentNullException(nameof(cluster));
     this.Name                    = name;
     this.DefaultTopic            = defaultTopic;
     this.Acks                    = acks;
     this.MiddlewareConfiguration = middlewareConfiguration;
     this.BaseProducerConfig      = baseProducerConfig;
     this.StatisticsHandlers      = statisticsHandlers;
 }
Esempio n. 6
0
        public ConsumerConfiguration(
            ConsumerConfig consumerConfig,
            IEnumerable <string> topics,
            string consumerName,
            int workerCount,
            int bufferSize,
            Factory <IDistributionStrategy> distributionStrategyFactory,
            MiddlewareConfiguration middlewareConfiguration,
            bool autoStoreOffsets,
            TimeSpan autoCommitInterval,
            IReadOnlyList <Action <string> > statisticsHandlers)
        {
            this.consumerConfig = consumerConfig ?? throw new ArgumentNullException(nameof(consumerConfig));

            if (string.IsNullOrEmpty(this.consumerConfig.GroupId))
            {
                throw new ArgumentNullException(nameof(consumerConfig.GroupId));
            }

            base.DistributionStrategyFactory =
                distributionStrategyFactory ?? throw new ArgumentNullException(nameof(distributionStrategyFactory));
            this.MiddlewareConfiguration = middlewareConfiguration ?? throw new ArgumentNullException(nameof(middlewareConfiguration));
            this.AutoStoreOffsets        = autoStoreOffsets;
            this.AutoCommitInterval      = autoCommitInterval;
            this.Topics             = topics ?? throw new ArgumentNullException(nameof(topics));
            this.ConsumerName       = consumerName ?? Guid.NewGuid().ToString();
            this.WorkerCount        = workerCount;
            this.StatisticsHandlers = statisticsHandlers;
            this.GroupId            = this.consumerConfig.GroupId;

            this.BufferSize = bufferSize > 0 ?
                              bufferSize :
                              throw new ArgumentOutOfRangeException(
                                        nameof(bufferSize),
                                        bufferSize,
                                        "The value must be greater than 0");
        }