Documentation ¶
Index ¶
- type ConsumerGroupHandler
- type ConsumerGroupHandlerInterface
- type HandleGroupMessage
- type Kafka
- func (k *Kafka) AsyncProducer(topic string, msg <-chan string)
- func (k *Kafka) Close()
- func (k *Kafka) ConsumePartition(topic string, partition int) (sarama.PartitionConsumer, error)
- func (k *Kafka) GroupConsumer(groupName string, topics []string, handler ConsumerGroupHandlerInterface)
- func (k *Kafka) IsDebug() bool
- func (k *Kafka) Partitions(topic string) ([]int32, error)
- func (k *Kafka) SendMessage(topic, value string) (partition int32, offset int64)
- func (k *Kafka) SetDebug(debug bool)
- type KafkaConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsumerGroupHandler ¶
消费组处理器
func (ConsumerGroupHandler) Cleanup ¶
func (ConsumerGroupHandler) Cleanup(sarama.ConsumerGroupSession) error
func (ConsumerGroupHandler) ConsumeClaim ¶
func (c ConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
ConsumeClaim 消费者组的处理器
func (ConsumerGroupHandler) Setup ¶
func (ConsumerGroupHandler) Setup(sarama.ConsumerGroupSession) error
type ConsumerGroupHandlerInterface ¶
type ConsumerGroupHandlerInterface interface { ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error Setup(sarama.ConsumerGroupSession) error Cleanup(sarama.ConsumerGroupSession) error }
消息处理接口
type HandleGroupMessage ¶
type HandleGroupMessage func(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim)
处理消息
type Kafka ¶
type Kafka struct { Consumer *sarama.Consumer // 消费者 Producer *sarama.SyncProducer // 生成者 // contains filtered or unexported fields }
核心类
func (*Kafka) AsyncProducer ¶
异步生产者Goroutines
func (*Kafka) ConsumePartition ¶
根据分区创建消费者
func (*Kafka) GroupConsumer ¶
func (k *Kafka) GroupConsumer(groupName string, topics []string, handler ConsumerGroupHandlerInterface)
消费者组
func (*Kafka) SendMessage ¶
生产者发送消息
Source Files ¶
Click to show internal directories.
Click to hide internal directories.