Ejemplo n.º 1
0
        void CreateProducer(IAsyncPipeContextAgent <ProducerContext <TKey, TValue> > asyncContext, CancellationToken cancellationToken)
        {
            Task <ProducerContext <TKey, TValue> > Create(ClientContext clientContext, CancellationToken createCancellationToken)
            {
                ProducerBuilder <TKey, TValue> producerBuilder = _producerBuilderFactory();
                ProducerContext <TKey, TValue> context         = new KafkaProducerContext <TKey, TValue>(producerBuilder, _headersSerializer, cancellationToken);

                return(Task.FromResult(context));
            }

            _clientContextSupervisor.CreateAgent(asyncContext, Create, cancellationToken);
        }
        void CreateConsumer(IAsyncPipeContextAgent <ConsumerContext <TKey, TValue> > asyncContext, CancellationToken cancellationToken)
        {
            Task <ConsumerContext <TKey, TValue> > Create(ClientContext clientContext, CancellationToken createCancellationToken)
            {
                ConsumerBuilder <TKey, TValue> consumerBuilder = _consumerBuilderFactory();
                ConsumerContext <TKey, TValue> context         = new KafkaConsumerContext <TKey, TValue>(_hostConfiguration, _receiveSettings,
                                                                                                         _headersDeserializer, consumerBuilder, cancellationToken);

                return(Task.FromResult(context));
            }

            _clientContextSupervisor.CreateAgent(asyncContext, Create, cancellationToken);
        }