Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Add TLS configuration #74

Merged
merged 1 commit into from
May 3, 2019
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
2 changes: 2 additions & 0 deletions consumerBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ func buildSaramaConfig(options *consumer.Options) *cluster.Config {
}
// TODO: make a cluster-wise kafkaVersion assignment. this hard coded assignment is used for enabling dlq consumer message timestamp injection.
config.Config.Version = sarama.V0_10_2_0
config.Config.Net.TLS.Enable = options.TLSConfig != nil
config.Config.Net.TLS.Config = options.TLSConfig
config.Config.Producer.MaxMessageBytes = options.ProducerMaxMessageByes
config.Config.Producer.RequiredAcks = sarama.WaitForAll
config.Config.Producer.Return.Successes = true
Expand Down
2 changes: 2 additions & 0 deletions internal/consumer/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package consumer

import (
"crypto/tls"
"time"

"github.com/Shopify/sarama"
Expand All @@ -42,6 +43,7 @@ type (
ProducerMaxMessageByes int
FetchDefaultBytes int32
OtherConsumerTopics []Topic
TLSConfig *tls.Config // TLSConfig is the configuration to use for secure connections, not nil -> enable, nil -> disabled
}
)

Expand Down
6 changes: 6 additions & 0 deletions kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package kafka

import (
"crypto/tls"
"fmt"
"time"

Expand Down Expand Up @@ -94,6 +95,11 @@ type (
// When using the handler based API, this corresponds to the number of concurrent go
// routines handler functions the library will run. Default is 1.
Concurrency int


// TLSConfig is the configuration to use for secure connections if
// enabled (not nil) (defaults to disabled, nil).
TLSConfig *tls.Config
}
)

Expand Down