startup_kafka

package
v2.7.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTopics added in v2.7.0

func CreateTopics(ctx context.Context, adminClient *kafka.AdminClient, topics Topics) error

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.

type Topic added in v2.7.1

type Topic struct {
	Name              string
	NumPartitions     int32
	ReplicationFactor int16

	// https://docs.confluent.io/platform/current/installation/configuration/topic-configs.html
	Config map[string]string
}

type Topics added in v2.7.1

type Topics []Topic

type TopicsFunc added in v2.7.1

type TopicsFunc func(replicationFactor int16) Topics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL