Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple brokers in kafka executor #1037

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions builtin/bins/dkron-executor-kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"errors"
"log"
"strings"

"github.com/Shopify/sarama"
"github.com/armon/circbuf"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (s *Kafka) ExecuteImpl(args *dktypes.ExecuteRequest) ([]byte, error) {
config.Producer.Return.Successes = true
config.Producer.Return.Errors = true

brokers := []string{args.Config["brokerAddress"]}
brokers := strings.Split(args.Config["brokerAddress"], ",")
yvanoers marked this conversation as resolved.
Show resolved Hide resolved
producer, err := sarama.NewSyncProducer(brokers, config)
if err != nil {
// Should not reach here
Expand All @@ -79,7 +80,7 @@ func (s *Kafka) ExecuteImpl(args *dktypes.ExecuteRequest) ([]byte, error) {

msg := &sarama.ProducerMessage{
Topic: args.Config["topic"],
Key: sarama.StringEncoder(args.Config["key"]),
Key: sarama.StringEncoder(args.Config["key"]),
Value: sarama.StringEncoder(args.Config["message"]),
}

Expand Down
4 changes: 2 additions & 2 deletions website/content/usage/executors/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A basic Kafka executor that produces a message on a Kafka broker.
Params

```
brokerAddress: "IP:port" of the broker
brokerAddress: Comma separated string containing "IP:port" of the brokers
key: The key of the message to produce
message: The body of the message to produce
topic: The Kafka topic for this message
Expand All @@ -22,7 +22,7 @@ Example
```json
"executor": "kafka",
"executor_config": {
"brokerAddress": "localhost:9092",
"brokerAddress": "localhost:9092,another.host:9092",
"key": "My key",
"message": "My message",
"topic": "my_topic"
Expand Down