Documentation
¶
Index ¶
- func CreateTopics(ctx context.Context, adminClient *kafka.AdminClient, topics Topics) error
- type KafkaOptions
- func (opts *KafkaOptions) ConfluentClient() confluent.Client
- func (opts *KafkaOptions) DefaultConfig(overrideConfig kafka.ConfigMap) kafka.ConfigMap
- func (opts *KafkaOptions) Initialize(ctx context.Context)
- func (opts *KafkaOptions) NewConsumer(overrideConfig kafka.ConfigMap) *kafka.Consumer
- func (opts *KafkaOptions) NewProducer(overrideConfig kafka.ConfigMap) *kafka.Producer
- type Topic
- type Topics
- type TopicsFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTopics ¶ added in v2.7.0
CreateTopics creates the given topics, deduplicating by name and treating an already existing topic as success.
Types ¶
type KafkaOptions ¶
type KafkaOptions struct {
// Inputs holds values that are not parsed from the command line but injected
// by the caller before Initialize runs.
Inputs struct {
// Set topics to automatically create topics on startup
Topics TopicsFunc
// Additional configuration options to apply to all clients
DefaultConfig kafka.ConfigMap
}
KafkaAddresses []string `` /* 175-byte string literal not displayed */
KafkaConsumerGroup string `` /* 158-byte string literal not displayed */
KafkaOffsetReset string `` /* 147-byte string literal not displayed */
KafkaReplication int16 `` /* 132-byte string literal not displayed */
KafkaSecurityProtocol string `` /* 138-byte string literal not displayed */
KafkaProperties []string `long:"kafka-property" env:"KAFKA_PROPERTY" description:"Rdkafka properties in key=value format"`
// schema registry is not really kafka, but it is only used with kafka,
// so I guess it is okay to put it here.
ConfluentURL string `` /* 159-byte string literal not displayed */
}
KafkaOptions provides simple flags for to create a kafka consumer or producer, and to create topics on startup
func (*KafkaOptions) ConfluentClient ¶ added in v2.7.0
func (opts *KafkaOptions) ConfluentClient() confluent.Client
ConfluentClient creates a schema registry client pointing at ConfluentURL.
func (*KafkaOptions) DefaultConfig ¶ added in v2.7.0
func (opts *KafkaOptions) DefaultConfig(overrideConfig kafka.ConfigMap) kafka.ConfigMap
DefaultConfig builds the rdkafka config map from the parsed options. The overrideConfig is merged on top of the defaults, and any --kafka-property flags are applied last so they always win.
func (*KafkaOptions) Initialize ¶ added in v2.7.0
func (opts *KafkaOptions) Initialize(ctx context.Context)
Initialize creates the configured topics on startup. It is a no-op unless Inputs.Topics was set, so applications that only consume or produce do not need an admin connection.
func (*KafkaOptions) NewConsumer ¶ added in v2.2.41
func (opts *KafkaOptions) NewConsumer(overrideConfig kafka.ConfigMap) *kafka.Consumer
NewConsumer creates a kafka consumer using DefaultConfig, with the given overrides applied on top of the defaults.
func (*KafkaOptions) NewProducer ¶ added in v2.7.0
func (opts *KafkaOptions) NewProducer(overrideConfig kafka.ConfigMap) *kafka.Producer
NewProducer creates a kafka producer using DefaultConfig, with the given overrides applied on top of the defaults.