示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Producer&lt;TKey, TData&gt;"/> class.
 /// </summary>
 /// <param name="config">The config object.</param>
 /// <remarks>
 /// Can be used when all config parameters will be specified through the config object
 /// and will be instantiated via reflection
 /// </remarks>
 public Producer(ProducerConfiguration config)
     : this(
         config,
         ReflectionHelper.Instantiate <IPartitioner <TKey> >(config.PartitionerClass),
         ProducerPool <TData> .CreatePool(config, ReflectionHelper.Instantiate <IEncoder <TData> >(config.SerializerClass)))
 {
     Guard.NotNull(config, "config");
 }
示例#2
0
        public BrokerPartitionInfo(ProducerConfig producerConfig, ProducerPool producerPool, Dictionary<string, TopicMetadata> topicPartitionInfo)
        {
            this.producerConfig = producerConfig;
            this.producerPool = producerPool;
            this.topicPartitionInfo = topicPartitionInfo;

            this.brokerList = producerConfig.Brokers;
            this.brokers = ClientUtils.ParseBrokerList(this.brokerList);
        }
示例#3
0
        public BrokerPartitionInfo(ProducerConfig producerConfig, ProducerPool producerPool, Dictionary <string, TopicMetadata> topicPartitionInfo)
        {
            this.producerConfig     = producerConfig;
            this.producerPool       = producerPool;
            this.topicPartitionInfo = topicPartitionInfo;

            this.brokerList = producerConfig.Brokers;
            this.brokers    = ClientUtils.ParseBrokerList(this.brokerList);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Producer&lt;TKey, TData&gt;"/> class.
 /// </summary>
 /// <param name="config">The config object.</param>
 /// <param name="partitioner">The partitioner that implements <see cref="IPartitioner&lt;TKey&gt;" />
 /// used to supply a custom partitioning strategy based on the message key.</param>
 /// <param name="encoder">The encoder that implements <see cref="IEncoder&lt;TData&gt;" />
 /// used to convert an object of type TData to <see cref="Message" />.</param>
 /// <remarks>
 /// Can be used to provide pre-instantiated objects for all config parameters
 /// that would otherwise be instantiated via reflection.
 /// </remarks>
 public Producer(
     ProducerConfiguration config,
     IPartitioner <TKey> partitioner,
     IEncoder <TData> encoder)
     : this(
         config,
         partitioner,
         ProducerPool <TData> .CreatePool(config, encoder, null))
 {
     Guard.NotNull(config, "config");
     Guard.NotNull(encoder, "encoder");
 }