Documentation ¶
Index ¶
- Constants
- func Client() *client
- func Init(conf Config, opts ...Option) error
- func OffsetInfo(topic, groupId string) (data []map[string]int64)
- func Partitions(topic string) []int32
- func Topics() []string
- type Config
- type ConsumerError
- type ConsumerHandler
- type ConsumerMessage
- 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 ¶
func OffsetInfo ¶ added in v1.1.153
分区数量
Types ¶
type Config ¶ added in v1.1.2
type Config struct { User string `json:"user" yaml:"user"` Password string `json:"password" yaml:"password"` Addrs []string `json:"addrs" yaml:"addrs"` Timeout int `json:"timeout" yaml:"timeout"` HeartbeatInterval int `json:"heartbeat_interval" yaml:"heartbeat_interval"` SessionTimeout int `json:"session_timeout" yaml:"session_timeout"` RebalanceTimeout int `json:"rebalance_timeout" yaml:"rebalance_timeout"` RedisConfig goo_redis.Config `json:"redis_config" yaml:"redis_config"` }
type ConsumerError ¶
type ConsumerError struct {
*sarama.ConsumerError
}
type ConsumerHandler ¶
type ConsumerHandler func(ctx *goo_context.Context, msg *ConsumerMessage, consumerErr *ConsumerError) error
type ConsumerMessage ¶
type ConsumerMessage struct { *sarama.ConsumerMessage GroupSession sarama.ConsumerGroupSession }
func (ConsumerMessage) Commit ¶ added in v1.1.218
func (msg ConsumerMessage) Commit()
type IConsumer ¶ added in v1.1.1
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.1.235
type IMessage interface { Topic() string Key() string Headers() map[string]string Serialize() []byte Deserialize(b []byte) }
消息
type IProducer ¶ added in v1.1.1
type IProducer interface { Client() sarama.Client // 发送消息 - 同步 SendMessage(msg IMessage) (partition int32, offset int64, err error) // 发送消息 - 异步 SendAsyncMessage(msg IMessage, cb MessageHandler) (err error) }
生产者
type MessageHandler ¶ added in v1.1.66
type MessageHandler func(msg *ProducerMessage, err error)
type ProducerMessage ¶ added in v1.1.66
type ProducerMessage struct {
*sarama.ProducerMessage
}
Click to show internal directories.
Click to hide internal directories.