Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-15 13:26:00 * @FilePath: \go-config\pkg\kafka\kafka.go * @Description: * * Copyright (j) 2024 by kamalyes, All Rights Reserved.
Index ¶
- type Kafka
- func (k *Kafka) Clone() internal.Configurable
- func (k *Kafka) Get() interface{}
- func (k *Kafka) Set(data interface{})
- func (k *Kafka) Validate() error
- func (k *Kafka) WithBrokers(brokers string) *Kafka
- func (k *Kafka) WithGroupID(groupID string) *Kafka
- func (k *Kafka) WithModuleName(moduleName string) *Kafka
- func (k *Kafka) WithOffset(offset string) *Kafka
- func (k *Kafka) WithPartition(partition int) *Kafka
- func (k *Kafka) WithPassword(password string) *Kafka
- func (k *Kafka) WithSyncESTopic(syncESTopic string) *Kafka
- func (k *Kafka) WithTopic(topic string) *Kafka
- func (k *Kafka) WithTryTimes(tryTimes int) *Kafka
- func (k *Kafka) WithUsername(username string) *Kafka
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kafka ¶
type Kafka struct {
Brokers string `mapstructure:"brokers" yaml:"brokers" json:"brokers" validate:"required"` // Kafka brokers地址
Topic string `mapstructure:"topic" yaml:"topic" json:"topic" validate:"required"` // Kafka主题
GroupID string `mapstructure:"group-id" yaml:"group-id" json:"groupId"` // 消费者组ID
Username string `mapstructure:"username" yaml:"username" json:"username"` // SASL用户名
Password string `mapstructure:"password" yaml:"password" json:"password"` // SASL密码
Partition int `mapstructure:"partition" yaml:"partition" json:"partition"` // 分区号
Offset string `mapstructure:"offset" yaml:"offset" json:"offset"` // 偏移量策略(earliest/latest)
TryTimes int `mapstructure:"try-times" yaml:"try-times" json:"tryTimes" validate:"required,min=1"` // 尝试次数
SyncESTopic string `mapstructure:"sync-es-topic" yaml:"sync-es-topic" json:"syncEsTopic" validate:"required"` // 同步到 ES 的主题
ModuleName string `mapstructure:"module-name" yaml:"module-name" json:"moduleName"` // 模块名称
}
Kafka 结构体
func (*Kafka) WithBrokers ¶
WithBrokers 设置Kafka brokers地址
func (*Kafka) WithModuleName ¶
WithModuleName 设置模块名称
func (*Kafka) WithPartition ¶
WithPartition 设置分区号
func (*Kafka) WithPassword ¶
WithPassword 设置SASL密码
func (*Kafka) WithSyncESTopic ¶
WithSyncESTopic 设置同步ES的主题
func (*Kafka) WithUsername ¶
WithUsername 设置SASL用户名
Click to show internal directories.
Click to hide internal directories.