Documentation ¶
Index ¶
- Constants
- func DefaultErrFn(err *sarama.ProducerError)
- func DefaultSuccessFn(msg *sarama.ProducerMessage)
- func Publish(host []string, topic, msg string, key sarama.Encoder, s SuccessFn, e ErrFn) (sourceMsg string, err error)
- func StartConsumer(consumerGroupHandler ConsumerGroupHandler, version sarama.KafkaVersion, ...)
- type BaseHandlerConsumer
- type ConsumerGroupHandler
- type ErrFn
- type IHandlerConsumer
- type SuccessFn
Constants ¶
View Source
const (
DEFAULTINSTANCE = iota //默认kafka实例
)
Variables ¶
This section is empty.
Functions ¶
func Publish ¶
func Publish(host []string, topic, msg string, key sarama.Encoder, s SuccessFn, e ErrFn) (sourceMsg string, err error)
* * 发送消息 * @param:topic string 所属topic * @param:msg string 消息 * @param:key sarama.Encoder
func StartConsumer ¶
func StartConsumer(consumerGroupHandler ConsumerGroupHandler, version sarama.KafkaVersion, kafkaHosts []string, saslEnable bool, userName, password, group, topic string)
* * @param consumerGroupHandler 结构体ConsumerGroupHandler的子类 * @param client kafka集群 * @param group 消费者组 * @param topic 消费者topic
Types ¶
type BaseHandlerConsumer ¶
type BaseHandlerConsumer struct { }
func (*BaseHandlerConsumer) CallBack ¶
func (b *BaseHandlerConsumer) CallBack(msg *sarama.ConsumerMessage) error
func (*BaseHandlerConsumer) DealErrCallBack ¶
func (b *BaseHandlerConsumer) DealErrCallBack(errMsg string)
func (*BaseHandlerConsumer) PostCallBack ¶
func (b *BaseHandlerConsumer) PostCallBack(msg []byte) error
func (*BaseHandlerConsumer) PreCallBack ¶
func (b *BaseHandlerConsumer) PreCallBack(msg []byte) error
* * 调用前接口
type ConsumerGroupHandler ¶
type ConsumerGroupHandler struct {
Fn IHandlerConsumer
}
func (ConsumerGroupHandler) Cleanup ¶
func (ConsumerGroupHandler) Cleanup(_ sarama.ConsumerGroupSession) error
func (ConsumerGroupHandler) ConsumeClaim ¶
func (h ConsumerGroupHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
func (ConsumerGroupHandler) Setup ¶
func (ConsumerGroupHandler) Setup(_ sarama.ConsumerGroupSession) error
type ErrFn ¶
type ErrFn func(err *sarama.ProducerError)
type IHandlerConsumer ¶
type SuccessFn ¶
type SuccessFn func(msg *sarama.ProducerMessage)
Click to show internal directories.
Click to hide internal directories.