kafka

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

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

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 Default

func Default() *Kafka

Default 返回默认Kafka配置的指针,支持链式调用

func DefaultKafka

func DefaultKafka() Kafka

DefaultKafka 返回默认Kafka配置

func NewKafka

func NewKafka(opt *Kafka) *Kafka

NewKafka 创建一个新的 Kafka 实例

func (*Kafka) Clone

func (k *Kafka) Clone() internal.Configurable

Clone 返回 Kafka 配置的副本

func (*Kafka) Get

func (k *Kafka) Get() interface{}

Get 返回 Kafka 配置的所有字段

func (*Kafka) Set

func (k *Kafka) Set(data interface{})

Set 更新 Kafka 配置的字段

func (*Kafka) Validate

func (k *Kafka) Validate() error

Validate 检查 Kafka 配置的有效性

func (*Kafka) WithBrokers

func (k *Kafka) WithBrokers(brokers string) *Kafka

WithBrokers 设置Kafka brokers地址

func (*Kafka) WithGroupID

func (k *Kafka) WithGroupID(groupID string) *Kafka

WithGroupID 设置消费者组ID

func (*Kafka) WithModuleName

func (k *Kafka) WithModuleName(moduleName string) *Kafka

WithModuleName 设置模块名称

func (*Kafka) WithOffset

func (k *Kafka) WithOffset(offset string) *Kafka

WithOffset 设置偏移量策略

func (*Kafka) WithPartition

func (k *Kafka) WithPartition(partition int) *Kafka

WithPartition 设置分区号

func (*Kafka) WithPassword

func (k *Kafka) WithPassword(password string) *Kafka

WithPassword 设置SASL密码

func (*Kafka) WithSyncESTopic

func (k *Kafka) WithSyncESTopic(syncESTopic string) *Kafka

WithSyncESTopic 设置同步ES的主题

func (*Kafka) WithTopic

func (k *Kafka) WithTopic(topic string) *Kafka

WithTopic 设置Kafka主题

func (*Kafka) WithTryTimes

func (k *Kafka) WithTryTimes(tryTimes int) *Kafka

WithTryTimes 设置尝试次数

func (*Kafka) WithUsername

func (k *Kafka) WithUsername(username string) *Kafka

WithUsername 设置SASL用户名

Jump to

Keyboard shortcuts

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