Пример #1
0
        public static ProducerConfig ToProducerProperties(this KafkaStreamOptions options)
        {
            var config = CreateCommonProperties <ProducerConfig>(options);

            config.MessageTimeoutMs = (int)options.ProducerTimeout.TotalMilliseconds;

            return(config);
        }
Пример #2
0
        public static IDictionary <string, string> ToProducerProperties(this KafkaStreamOptions options)
        {
            var config = CreateCommonProperties(options);

            config.TryAdd("message.timeout.ms", options.ProducerTimeout.TotalMilliseconds.ToString(CultureInfo.InvariantCulture));

            return(config);
        }
Пример #3
0
        public static IDictionary <string, string> ToConsumerProperties(this KafkaStreamOptions options)
        {
            var config = CreateCommonProperties(options);

            config.TryAdd("group.id", options.ConsumerGroupId);
            config.TryAdd("enable.auto.commit", "false");

            return(config);
        }
Пример #4
0
        public static ConsumerConfig ToConsumerProperties(this KafkaStreamOptions options)
        {
            var config = CreateCommonProperties <ConsumerConfig>(options);

            config.GroupId          = options.ConsumerGroupId;
            config.EnableAutoCommit = false;

            return(config);
        }
        public static KafkaStreamOptions WithConfluentCloudOptions(this KafkaStreamOptions options, Credentials credentials)
        {
            options.ApiVersionRequest     = true;
            options.BrokerVersionFallback = "0.10.0.0";
            options.ApiVersionFallbackMs  = 0;
            options.SaslMechanisms        = "PLAIN";
            options.SecurityProtocol      = "SASL_SSL";
            options.SaslUserName          = credentials.UserName;
            options.SaslPassword          = credentials.Password;
            options.SslCaLocation         = Path.Combine(".", "cacert.pem");

            return(options);
        }
Пример #6
0
        public static KafkaStreamOptions WithSaslOptions(
            this KafkaStreamOptions options,
            Credentials credentials,
            string saslMechanism = "PLAIN"
            )
        {
            options.SaslMechanisms   = saslMechanism;
            options.SecurityProtocol = "SASL_SSL";
            options.SaslUserName     = credentials.UserName;
            options.SaslPassword     = credentials.Password;
            options.SslCaLocation    = credentials.SslCaLocation;

            return(options);
        }
Пример #7
0
        public static KafkaStreamOptions WithSaslOptions(
            this KafkaStreamOptions options,
            Credentials credentials,
            SaslMechanism saslMechanism = SaslMechanism.Plain
            )
        {
            options.SaslMechanism    = saslMechanism;
            options.SecurityProtocol = SecurityProtocol.SaslSsl;
            options.SaslUserName     = credentials.UserName;
            options.SaslPassword     = credentials.Password;
            options.SslCaLocation    = credentials.SslCaLocation;

            return(options);
        }
Пример #8
0
 private static TClientConfig CreateCommonProperties <TClientConfig>(KafkaStreamOptions options)
     where TClientConfig : ClientConfig, new()
 => new TClientConfig
 {
     BootstrapServers           = string.Join(",", options.BrokerList),
     BrokerVersionFallback      = options.BrokerVersionFallback,
     ApiVersionRequest          = options.ApiVersionRequest,
     ApiVersionRequestTimeoutMs = options.ApiVersionFallbackMs,
     SaslMechanism    = (Confluent.Kafka.SaslMechanism)(int) options.SaslMechanism,
     SecurityProtocol = (Confluent.Kafka.SecurityProtocol)(int) options.SecurityProtocol,
     SslCaLocation    = options.SslCaLocation,
     SaslUsername     = options.SaslUserName,
     SaslPassword     = options.SaslPassword
 };
Пример #9
0
        private static IDictionary <string, string> CreateCommonProperties(KafkaStreamOptions options)
        {
            var config = new Dictionary <string, string>
            {
                { "bootstrap.servers", string.Join(",", options.BrokerList) }
            };

            config.TryAdd("api.version.request", options.ApiVersionRequest.ToString());
            config.TryAdd("broker.version.fallback", options.BrokerVersionFallback);
            config.TryAdd("api.version.fallback.ms", options.ApiVersionFallbackMs.ToString());
            config.TryAdd("sasl.mechanisms", options.SaslMechanisms);
            config.TryAdd("security.protocol", options.SecurityProtocol);
            config.TryAdd("ssl.ca.location", options.SslCaLocation);
            config.TryAdd("sasl.username", options.SaslUserName);
            config.TryAdd("sasl.password", options.SaslPassword);

            return(config);
        }
Пример #10
0
 public static IDictionary <string, string> ToAdminProperties(this KafkaStreamOptions options)
 => CreateCommonProperties(options);
Пример #11
0
 public static AdminClientConfig ToAdminProperties(this KafkaStreamOptions options)
 => CreateCommonProperties <AdminClientConfig>(options);