kafka

package
v0.0.0-...-ecc5721 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MQMsgPool = &sync.Pool{
		New: func() interface{} {
			return &pb.MQData{}
		},
	}
)

Functions

func JsonSerialize

func JsonSerialize(v interface{}) ([]byte, error)

JsonSerialize

func PBSerialize

func PBSerialize(v proto.Message) ([]byte, error)

PBSerialize

Types

type Consumer

type Consumer struct {
	Consumer sarama.Consumer
	Topic    string
}

Consumer 消费者

func NewConsumer

func NewConsumer(addrs []string, topic string) (*Consumer, error)

func NewConsumerWithLog

func NewConsumerWithLog(addrs []string, topic string, logPath string) (*Consumer, error)

NewProducer creates kafka async producer

func (*Consumer) StartConsume

func (c *Consumer) StartConsume()

type Producer

type Producer struct {
	Producer sarama.AsyncProducer
	Topic    string
}

Producer represents the kafka async producer

func NewProducer

func NewProducer(addrs []string, topic string, clientID string) (*Producer, error)

NewProducer creates kafka async producer

func NewProducerWithLog

func NewProducerWithLog(addrs []string, topic, clientID, logPath, userName, passWord string, enableAuth bool) (*Producer, error)

NewProducer creates kafka async producer

func (*Producer) SendJsonWithKey

func (p *Producer) SendJsonWithKey(key string, msg interface{})

Send 发送

func (*Producer) SendPBWithKey

func (p *Producer) SendPBWithKey(key string, msg proto.Message)

Send 发送

Jump to

Keyboard shortcuts

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