43 lines
691 B
Go
43 lines
691 B
Go
package kafka
|
|
|
|
import (
|
|
"ultone/internal/interfaces"
|
|
|
|
"github.com/segmentio/kafka-go/sasl/plain"
|
|
)
|
|
|
|
type OptionFn func(*client)
|
|
|
|
func WithPlainAuth(username, password string) OptionFn {
|
|
return func(c *client) {
|
|
c.mechanism = plain.Mechanism{
|
|
Username: username,
|
|
Password: password,
|
|
}
|
|
}
|
|
}
|
|
|
|
func WithTopic(topic string) OptionFn {
|
|
return func(c *client) {
|
|
c.topic = topic
|
|
}
|
|
}
|
|
|
|
func WithPartition(partition int) OptionFn {
|
|
return func(c *client) {
|
|
c.partition = partition
|
|
}
|
|
}
|
|
|
|
func WithReconnection() OptionFn {
|
|
return func(c *client) {
|
|
c.reconnection = true
|
|
}
|
|
}
|
|
|
|
func WithLogger(logger interfaces.Logger) OptionFn {
|
|
return func(c *client) {
|
|
c.logger = logger
|
|
}
|
|
}
|