public static ProducerConfig ToProducerConfig(this INetStreamConfigurationContext config)
 {
     return(new ProducerConfig()
     {
         BootstrapServers = config.BootstrapServers
     });
 }
Exemple #2
0
        public IMessageProducer <TKey, TMessage> Create <TKey, TMessage>(INetStreamConfigurationContext config)
        {
            var producer = new ProducerBuilder <TKey, TMessage>(config.ToProducerConfig())
                           .SetValueSerializer(new HeaderSerializationStrategy <TMessage>())
                           .Build();

            return(new NetStreamProducer <TKey, TMessage>(producer));
        }
Exemple #3
0
        public static ProducerConfig ToProducerConfig(this INetStreamConfigurationContext config)
        {
            var producerConfig = new ProducerConfig()
            {
                BootstrapServers = config.BootstrapServers,
            };

            config.AuthenticationMethod.Apply(producerConfig);
            return(producerConfig);
        }
 public static ConsumerConfig ToConsumerConfig(this INetStreamConfigurationContext config)
 {
     return(new ConsumerConfig()
     {
         BootstrapServers = config.BootstrapServers,
         GroupId = config.ConsumerGroup,
         EnableAutoCommit = true,
         AutoOffsetReset = AutoOffsetReset.Earliest
     });
 }
Exemple #5
0
 public static ProducerConfig ToProducerConfig(this INetStreamConfigurationContext config)
 {
     return(new ProducerConfig()
     {
         BootstrapServers = config.BootstrapServers,
         SecurityProtocol = ParseSecurityProtocol(config),
         SslCertificateLocation = config.SslCertificateLocation,
         SslCaLocation = config.SslCaLocation,
         SslKeyLocation = config.SslKeyLocation,
         SslKeyPassword = config.SslKeyPassword
     });
 }
Exemple #6
0
        public static ConsumerConfig ToConsumerConfig(this INetStreamConfigurationContext config)
        {
            var consumerConfig = new ConsumerConfig()
            {
                BootstrapServers     = config.BootstrapServers,
                GroupId              = config.ConsumerGroup,
                EnableAutoCommit     = config.DeliveryMode.EnableAutoCommit,
                AutoCommitIntervalMs = config.DeliveryMode.AutoCommitIntervalMs,
                AutoOffsetReset      = config.AutoOffsetReset,
            };

            config.AuthenticationMethod.Apply(consumerConfig);
            return(consumerConfig);
        }
        public TopicCreator(INetStreamConfigurationContext configuration, ILog log)
        {
            _log = log;
            var adminConfig = new AdminClientConfig
            {
                BootstrapServers = configuration.BootstrapServers,
            };

            configuration.AuthenticationMethod.Apply(adminConfig);

            var adminClientBuilder = new AdminClientBuilder(adminConfig);

            _adminClient = new Lazy <IAdminClient>(() => adminClientBuilder.Build());
        }
Exemple #8
0
        public static SecurityProtocol?ParseSecurityProtocol(this INetStreamConfigurationContext config)
        {
            if (!string.IsNullOrEmpty(config.SecurityProtocol))
            {
                if (Enum.TryParse <SecurityProtocol>(config.SecurityProtocol, true, out var securityProtocol))
                {
                    return(securityProtocol);
                }
                else
                {
                    throw new ArgumentException(nameof(config.SecurityProtocol));
                }
            }

            return(null);
        }
Exemple #9
0
 public static ConsumerConfig ToConsumerConfig(this INetStreamConfigurationContext config)
 {
     return(new ConsumerConfig()
     {
         BootstrapServers = config.BootstrapServers,
         GroupId = config.ConsumerGroup,
         EnableAutoCommit = config.DeliveryMode.EnableAutoCommit,
         AutoCommitIntervalMs = config.DeliveryMode.AutoCommitIntervalMs,
         AutoOffsetReset = AutoOffsetReset.Earliest,
         SecurityProtocol = ParseSecurityProtocol(config),
         SslCertificateLocation = config.SslCertificateLocation,
         SslCaLocation = config.SslCaLocation,
         SslKeyLocation = config.SslKeyLocation,
         SslKeyPassword = config.SslKeyPassword
     });
 }
Exemple #10
0
        public TopicCreator(INetStreamConfigurationContext configuration, ILog log)
        {
            _log = log;
            var adminConfig = new AdminClientConfig
            {
                BootstrapServers       = configuration.BootstrapServers,
                SslCertificateLocation = configuration.SslCertificateLocation,
                SslCaLocation          = configuration.SslCaLocation,
                SslKeyLocation         = configuration.SslKeyLocation,
                SslKeyPassword         = configuration.SslKeyPassword,
                SecurityProtocol       = configuration.ParseSecurityProtocol()
            };

            var adminClientBuilder = new AdminClientBuilder(adminConfig);

            _adminClient = new Lazy <IAdminClient>(() => adminClientBuilder.Build());
        }
Exemple #11
0
 public IConsumer <TKey, T> Create <TKey, T>(INetStreamConfigurationContext config)
 {
     return(((Mock <IConsumer <TKey, T> >)_mock).Object);
 }
Exemple #12
0
 public IMessageProducer <TKey, TMessage> Create <TKey, TMessage>(string topic, INetStreamConfigurationContext config)
 {
     return(((Mock <IMessageProducer <TKey, TMessage> >)_mock).Object);
 }
 public IConsumer <TKey, TValue> Create <TKey, TValue>(INetStreamConfigurationContext config)
 {
     return(new ConsumerBuilder <TKey, TValue>(config.ToConsumerConfig())
            .SetValueDeserializer(new HeaderSerializationStrategy <TValue>())
            .Build());
 }