Skip to content

Commit a2799b5

Browse files
committed
Add SASLMechanism config option with default to PLAIN
1 parent aee27ea commit a2799b5

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

docs/config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ ACHGateway:
7272
Topic: <string>
7373
TLS: <boolean>
7474
AutoCommit: <boolean>
75+
[ SASLMechanism: <string> | default = "PLAIN" ]
7576
Transform:
7677
Encoding:
7778
[ Base64: <boolean> | default = false ]
@@ -156,6 +157,7 @@ ACHGateway:
156157
Topic: <string>
157158
[ TLS: <boolean> | default = false ]
158159
[ AutoCommit: <boolean> | default = false ]
160+
[ SASLMechanism: <string> | default = "PLAIN" ]
159161
Webhook:
160162
[ Endpoint: <string> | default = "" ]
161163
```

internal/kafka/kafka.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ func OpenTopic(logger log.Logger, cfg *service.KafkaConfig) (*pubsub.Topic, erro
2121
config.Net.TLS.Enable = cfg.TLS
2222

2323
config.Net.SASL.Enable = cfg.Key != ""
24-
config.Net.SASL.Mechanism = sarama.SASLMechanism("PLAIN")
24+
config.Net.SASL.Mechanism = sarama.SASLMechanism(cfg.SASLMechanism)
25+
if config.Net.SASL.Mechanism == "" {
26+
config.Net.SASL.Mechanism = sarama.SASLMechanism("PLAIN")
27+
}
2528
config.Net.SASL.User = cfg.Key
2629
config.Net.SASL.Password = cfg.Secret
2730

@@ -46,7 +49,10 @@ func OpenSubscription(logger log.Logger, cfg *service.KafkaConfig) (*pubsub.Subs
4649
config.Net.TLS.Enable = cfg.TLS
4750

4851
config.Net.SASL.Enable = cfg.Key != ""
49-
config.Net.SASL.Mechanism = sarama.SASLMechanism("PLAIN")
52+
config.Net.SASL.Mechanism = sarama.SASLMechanism(cfg.SASLMechanism)
53+
if config.Net.SASL.Mechanism == "" {
54+
config.Net.SASL.Mechanism = sarama.SASLMechanism("PLAIN")
55+
}
5056
config.Net.SASL.User = cfg.Key
5157
config.Net.SASL.Password = cfg.Secret
5258

internal/service/model_inbound.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ type KafkaConfig struct {
7777
// AutoCommit in Sarama refers to "automated publishing of consumer offsets
7878
// to the broker" rather than a Kafka broker's meaning of "commit consumer
7979
// offsets on read" which leads to "at-most-once" delivery.
80-
AutoCommit bool
80+
AutoCommit bool
81+
SASLMechanism string
8182

8283
Consumer KafkaConsumerConfig
8384
Producer KafkaProducerConfig

0 commit comments

Comments
 (0)