Documentation ¶
Index ¶
- Constants
- func DelClient(names ...string)
- func Init(conf Config, opts ...Option) (err error)
- type Config
- type ConsumerError
- type ConsumerHandler
- type ConsumerMessage
- type GoKafka
- func (cli *GoKafka) Close()
- func (cli *GoKafka) Consumer() IConsumer
- func (cli *GoKafka) CreateTopicsRequest(topicName string, partitions int, replicationFactors int) error
- func (c *GoKafka) GetKey(topic, msg string) string
- func (c *GoKafka) OffsetInfo(topic, groupId string) (data []map[string]int64)
- func (c *GoKafka) Partitions(topic string) []int32
- func (cli *GoKafka) Producer(opts ...Option) IProducer
- func (c *GoKafka) Redis() *goredis.GoRedis
- func (c *GoKafka) Topics() []string
- type IConsumer
- type IMessage
- type IProducer
- type MessageHandler
- type Option
- type ProducerMessage
Constants ¶
View Source
const ( FocusName = "focus" RedisName = "redis" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { User string `json:"user,optional" yaml:"User"` Name string `json:"name,optional" yaml:"Name"` Password string `json:"password,optional" yaml:"Password"` Addrs []string `json:"addrs,optional" yaml:"Addrs"` Timeout int `json:"timeout,optional" yaml:"Timeout"` HeartbeatInterval int `json:"heartbeatInterval,optional" yaml:"HeartbeatInterval"` SessionTimeout int `json:"sessionTimeout,optional" yaml:"SessionTimeout"` RebalanceTimeout int `json:"rebalanceTimeout,optional" yaml:"RebalanceTimeout"` OffsetNewest bool `json:"offsetNewest,optional" yaml:"OffsetNewest"` GroupId string `json:"groupId,optional" yaml:"GroupId"` Version string `json:"version,optional" yaml:"Version"` RedisConfig goredis.Config `json:"redisConfig,optional" yaml:"RedisConfig"` }
type ConsumerError ¶
type ConsumerError struct {
*sarama.ConsumerError
}
type ConsumerHandler ¶
type ConsumerHandler func(ctx *gocontext.Context, msg *ConsumerMessage, consumerErr *ConsumerError) error
type ConsumerMessage ¶
type ConsumerMessage struct { *sarama.ConsumerMessage GroupSession sarama.ConsumerGroupSession }
func (ConsumerMessage) Commit ¶ added in v1.2.146
func (msg ConsumerMessage) Commit()
type GoKafka ¶ added in v1.2.142
func (*GoKafka) CreateTopicsRequest ¶ added in v1.2.142
func (*GoKafka) OffsetInfo ¶ added in v1.2.146
分区数量
func (*GoKafka) Partitions ¶ added in v1.2.146
分区数量
type IConsumer ¶ added in v1.2.146
type IConsumer interface { Client() sarama.Client // 从指定分区消费 WithPartition(partition int32) IConsumer // 从指定位置开始 WithOffset(offset int64) IConsumer // 从最新位置开始 WithOffsetNewest() IConsumer // 从头开始 WithOffsetOldest() IConsumer // 消费 Consume(topic string, handler ConsumerHandler) // 分组topic ConsumeGroup(groupId string, topics []string, handler ConsumerHandler) }
消费者
type IMessage ¶ added in v1.2.146
type IMessage interface { Topic() string Key() string Headers() map[string]string Serialize() []byte Deserialize(b []byte) }
消息
type IProducer ¶ added in v1.2.146
type IProducer interface { Client() sarama.Client // 发送消息 - 同步 SendMessage(msg IMessage) (partition int32, offset int64, err error) // 发送消息 - 异步 SendAsyncMessage(msg IMessage, cb MessageHandler) (err error) }
生产者
type MessageHandler ¶
type MessageHandler func(msg *ProducerMessage, err error)
type ProducerMessage ¶
type ProducerMessage struct {
*sarama.ProducerMessage
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.