kafka

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallMiddleware added in v1.8.4

func InstallMiddleware(handle ...ProducerHandler)

InstallMiddleware Install the middleware.. You can control the publishing of messages by installing middleware.

Types

type Consumer

type Consumer interface {
	// Start 使用配置结构体启动消费者
	Start(config *ConsumerConfig)
	// Restart the connection.
	Restart() error
	// Close the connection.
	Close() error
}

Consumer Kafka Consumer interface definition.

func GetConsumer added in v1.8.8

func GetConsumer() Consumer

GetConsumer Returns the Consumer instance.

type ConsumerConfig added in v1.9.8

type ConsumerConfig struct {
	// Kafka 服务器地址
	Addrs []string
	// 消费者组ID
	GroupID string
	// Sarama 配置
	Config *sarama.Config
	// 代理地址
	ProxyAddr string
	// 是否使用 H2C 代理
	ProxyH2C bool
	// HTTP 请求超时时间
	RequestTimeout time.Duration
	// 并发限制(并行模式下最大同时处理的消息数,默认500)
	RateLimit int
	// 优雅关闭超时时间(默认3秒)
	CloseTimeout time.Duration
}

ConsumerConfig 消费者配置结构体

type ConsumerImpl added in v1.8.8

type ConsumerImpl struct {
	freedom.Infra
	// contains filtered or unexported fields
}

ConsumerImpl Kafka Consumer implementation.

func (*ConsumerImpl) Booting added in v1.8.8

func (c *ConsumerImpl) Booting(bootManager freedom.BootManager)

Booting The method of overriding the component . The single-case component initiates a callback.

func (*ConsumerImpl) Close added in v1.8.8

func (c *ConsumerImpl) Close() error

Close the connection.

func (*ConsumerImpl) Restart added in v1.8.8

func (c *ConsumerImpl) Restart() error

Restart the connection.

func (*ConsumerImpl) Start added in v1.8.8

func (c *ConsumerImpl) Start(config *ConsumerConfig)

Start

type Msg

type Msg struct {
	Topic string

	Content []byte
	// contains filtered or unexported fields
}

Msg Kafka Message.

func (*Msg) GetExecution added in v1.8.4

func (msg *Msg) GetExecution() error

GetExecution Get the results of the execution .

func (*Msg) GetHeader added in v1.8.4

func (msg *Msg) GetHeader() map[string]interface{}

GetHeader .

func (*Msg) GetMessageKey added in v1.8.4

func (msg *Msg) GetMessageKey() string

GetMessageKey Get kafka key.

func (*Msg) IsStopped added in v1.8.4

func (msg *Msg) IsStopped() bool

IsStopped whether it has stopped.

func (*Msg) Next added in v1.8.4

func (msg *Msg) Next()

Next Perform the next step, typically for the control of middleware.

func (*Msg) Publish added in v1.3.5

func (msg *Msg) Publish() error

Publish this message.

func (*Msg) SetHeader added in v1.8.4

func (msg *Msg) SetHeader(head map[string]interface{}) *Msg

SetHeader set up HTTP Header.

func (*Msg) SetMessageKey added in v1.8.4

func (msg *Msg) SetMessageKey(key string) *Msg

SetMessageKey Set kafka key.

func (*Msg) Stop added in v1.8.4

func (msg *Msg) Stop() *Msg

Stop execution, typically used for middleware control

type Producer

type Producer interface {
	// Create a new message
	NewMsg(topic string, content []byte) *Msg
	// Start pass in the relevant address, configuration.
	Start(addrs []string, config *sarama.Config)
	// Restart the connection.
	Restart() error
}

Producer The producer's interface definition.

func GetProducer added in v1.8.8

func GetProducer() Producer

GetProducer Gets an instance of the producer.

type ProducerHandler added in v1.8.4

type ProducerHandler func(*Msg)

ProducerHandler The function declaration of the Kafka Producer middleware..

type ProducerImpl added in v1.4.3

type ProducerImpl struct {
	freedom.Infra
	// contains filtered or unexported fields
}

ProducerImpl The realization of the producer.

func (*ProducerImpl) Booting added in v1.4.3

func (pi *ProducerImpl) Booting(bootManager freedom.BootManager)

Booting The method of overriding the component . The single-case component initiates a callback.

func (*ProducerImpl) Close added in v1.8.8

func (pi *ProducerImpl) Close() error

Close .

func (*ProducerImpl) NewMsg added in v1.4.3

func (pi *ProducerImpl) NewMsg(topic string, content []byte) *Msg

NewMsg Create a new message.

func (*ProducerImpl) Restart added in v1.8.8

func (pi *ProducerImpl) Restart() error

Restart the connection.

func (*ProducerImpl) Start added in v1.8.8

func (pi *ProducerImpl) Start(addrs []string, config *sarama.Config)

Start pass in the relevant address, configuration.

type WorkerPool added in v1.9.11

type WorkerPool struct {
	// contains filtered or unexported fields
}

WorkerPool

func NewWorkerPool added in v1.9.11

func NewWorkerPool(maxWorkers int) *WorkerPool

NewWorkerPool

func (*WorkerPool) Close added in v1.9.11

func (p *WorkerPool) Close(timeout time.Duration) error

Close

func (*WorkerPool) Submit added in v1.9.11

func (p *WorkerPool) Submit(task func())

Submit

Jump to

Keyboard shortcuts

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