kafkax

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const SASLTypePlaintext = sarama.SASLTypePlaintext

Variables

This section is empty.

Functions

func NewSaramaConfig

func NewSaramaConfig(c *ProducerConfig) *sarama.Config

Types

type Consumer

type Consumer interface {
	transport.Server                          //跟着gin框架一起启动
	RegisterHandles(MsgHandleFunc, ...string) //注册处理方法
	Subscribe(ctx context.Context)            //开始处理消息,手动开启
}

func NewConsumerService

func NewConsumerService(conf *ConsumerConfig) Consumer

type ConsumerConfig

type ConsumerConfig struct {
	Addr      string
	Channel   string
	ClientID  string
	GroupID   string
	UserName  string
	Password  string
	Mechanism string
	Version   string
	Trace     trace.Tracer
}

type CustomMessage

type CustomMessage struct {
	Header  RawMessage `json:"header"`
	Payload RawMessage `json:"payload"`
}

func NewMessage

func NewMessage(ms ...map[string]any) *CustomMessage

func (*CustomMessage) NewPubMsg

func (m *CustomMessage) NewPubMsg(key []byte) *PubMsg

type Message

type Message struct {
	Topic     string
	Key       string
	Value     []byte
	Timestamp time.Time
}

type MessageHandleDef

type MessageHandleDef struct {
	Topic   []string
	Handle  MsgHandleFunc
	Options []Option
}

type MsgHandleFunc

type MsgHandleFunc func(ctx context.Context, msg *Message) bool

func Wrap

func Wrap(handler func(ctx context.Context, msg *Message) error) MsgHandleFunc

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAutoCommit

func WithAutoCommit(auto bool) Option

func WithCleanup

func WithCleanup(f func(sarama.ConsumerGroupSession) error) Option

func WithErrHandle

func WithErrHandle(f func(error)) Option

func WithSetup

func WithSetup(f func(sarama.ConsumerGroupSession) error) Option

type OptionFunc

type OptionFunc func(*optionConfig)

type Producer

type Producer interface {
	Send(topic string, value []byte) error
	SendWithKey(topic string, key []byte, value []byte) error
	RetrySend(ctx context.Context, topic string, messageBody []byte) error
	ListTopicGroupIds(topic string) ([]string, error)
	Close() error
}

func NewSyncProducer

func NewSyncProducer(c *ProducerConfig) (p Producer, err error)

type ProducerConfig

type ProducerConfig struct {
	Addr      string
	UserName  string
	Password  string
	Mechanism string
	RecSize   int
}

type PubMsg

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

func MQMsgBuilder

func MQMsgBuilder(key, value []byte) *PubMsg

func (*PubMsg) Key

func (pm *PubMsg) Key() []byte

func (*PubMsg) Value

func (pm *PubMsg) Value() []byte

type PubResult

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

func (*PubResult) Error

func (pr *PubResult) Error() error

func (*PubResult) SetError

func (pr *PubResult) SetError(err error)

func (*PubResult) SetSrcMsg

func (pr *PubResult) SetSrcMsg(key, value []byte)

func (*PubResult) SrcMsg

func (pr *PubResult) SrcMsg() *PubMsg

type RawMessage

type RawMessage map[string]any

func NewRawMessage

func NewRawMessage() RawMessage

func (*RawMessage) Marshal

func (m *RawMessage) Marshal() []byte

func (*RawMessage) RawMessageInject

func (m *RawMessage) RawMessageInject(ctx context.Context)

Jump to

Keyboard shortcuts

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