kafka

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConnections

func GetConnections() []*kafkaLib.Conn

GetConnections 获取连接

调用此方法前需要先调用 Init 进行初始化

func GetReader

func GetReader() *kafkaLib.Reader

GetReader 获取读实例

调用此方法前需要先调用 Init 进行初始化

func GetWriter

func GetWriter() *kafkaLib.Writer

GetWriter 获取写实例

调用此方法前需要先调用 Init 进行初始化

func Init

func Init(conf Conf, topic, groupID string)

Init 初始化连接

该方法会初始化连接、读实例、写实例

初始化后,可调用 GetInstance 方法获取完整实例

func InitConnections

func InitConnections(conf Conf)

InitConnections 初始化连接

func InitReader

func InitReader(conf Conf, topic, groupID string)

InitReader 初始化读实例

func InitWriter

func InitWriter(conf Conf, topic string)

InitWriter 初始化写实例

func New

func New(conf Conf, topic, groupID string) ([]*kafkaLib.Conn, *kafkaLib.Writer, *kafkaLib.Reader)

New 初始化连接

该方法会初始化连接、读实例、写实例

func NewConnections

func NewConnections(conf Conf) []*kafkaLib.Conn

NewConnections 实例化新的连接

func NewReader

func NewReader(conf Conf, topic, groupID string) *kafkaLib.Reader

NewReader 实例化新的读实例

func NewWriter

func NewWriter(conf Conf, topic string) *kafkaLib.Writer

NewWriter 实例化新的写实例

Types

type Conf

type Conf struct {
	Enable       bool        `yaml:"enable" toml:"enable" json:"enable" default:"false"`   //是否启用
	Endpoints    []string    `yaml:"endpoints" toml:"endpoints" json:"endpoints"`          //地址列表,如: localhost:9092
	SASLAuthType string      `yaml:"SASLAuthType" toml:"SASLAuthType" json:"SASLAuthType"` //认证加密方式:plain、sha256、sha512
	Username     string      `yaml:"username" toml:"username" json:"username"`             //账号
	Password     string      `yaml:"password" toml:"password" json:"password"`             //密码
	Timeout      int         `yaml:"timeout" toml:"timeout" json:"timeout"`                //连接超时时间(毫秒)默认10000ms
	Tls          *tls.Config `yaml:"-" toml:"-" json:"-"`                                  //tls配置//tls配置
}

type Instance

type Instance struct {
	Connections []*kafkaLib.Conn
	Writer      *kafkaLib.Writer
	Reader      *kafkaLib.Reader
}

Instance 连接实例

func GetInstance

func GetInstance() *Instance

GetInstance 获取完整实例

包含连接、读实例、写实例

Jump to

Keyboard shortcuts

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