Documentation ¶
Index ¶
- Constants
- Variables
- func AddLogHook(f LogHook)
- func CreateMessage(topic string, body []byte, setter ...MessageSetter) *primitive.Message
- func DefaultErrorCallback(err error, msg *primitive.MessageExt)
- func StringSet(ss []string) []string
- type Consumer
- type ConsumerOption
- type ConsumerSetter
- func WithBroadcasting(broadcast bool) ConsumerSetter
- func WithConsumeOrderly(orderly bool) ConsumerSetter
- func WithConsumeTimeout(n int) ConsumerSetter
- func WithConsumerLokHook(f LogHook) ConsumerSetter
- func WithInstanceName(name string) ConsumerSetter
- func WithMaxTopicCount(count int) ConsumerSetter
- func WithReconsumerTime(n int32) ConsumerSetter
- type CreateTopicError
- type ErrorCallback
- type GroupInfo
- type Handler
- type LogHook
- type M
- type Message
- type MessageSetter
- type Monitor
- type MultiSubscription
- type OnsClient
- func (c *OnsClient) ClearConsumerAllTopicMessage(group string) error
- func (c *OnsClient) ClearConsumerTopicMessage(group, topic string) error
- func (c *OnsClient) ConsumerResetOffset(group, topic string, resetTimeStamp int64) error
- func (c *OnsClient) CreateGroup(group, remark string) error
- func (c *OnsClient) CreateOnsConsumerStatusRequest(group string) (response *ons.OnsConsumerStatusResponse, err error)
- func (c *OnsClient) CreateTopic(topic, remark string, messageType int) error
- func (c *OnsClient) DeleteGroup(group string) error
- func (c *OnsClient) DeleteTopic(topic string) error
- func (c *OnsClient) ListConsumerGroupSub(group string) ([]*Sub, error)
- func (c *OnsClient) ListGroup() ([]*GroupInfo, error)
- func (c *OnsClient) ListTopic() ([]*TopicInfo, error)
- type Producer
- func (p *Producer) CreateTopic(topics ...string) []*CreateTopicError
- func (p *Producer) RawProducer() *rocketmq.Producer
- func (p *Producer) Send(topic string, body []byte, setter ...MessageSetter) SendResult
- func (p *Producer) SendAsync(topic string, body []byte, ...) error
- func (p *Producer) Start() error
- func (p *Producer) Stop() error
- type ProducerOption
- type ProducerSetter
- type RocketMQCredentials
- type SendResult
- type Sub
- type Subscription
- type TopicInfo
Constants ¶
View Source
const ( OnsDomainFormatUrl = "ons.%s.aliyuncs.com" NormalMessageType = 0 PartitionOrderMessageType = 1 GlobalOrderMessageType = 2 TransactionMessageType = 4 DelayMessageType = 5 )
Variables ¶
View Source
var Logger = logrus.New()
Functions ¶
func AddLogHook ¶ added in v0.1.5
func AddLogHook(f LogHook)
func CreateMessage ¶ added in v0.1.5
func CreateMessage(topic string, body []byte, setter ...MessageSetter) *primitive.Message
func DefaultErrorCallback ¶
func DefaultErrorCallback(err error, msg *primitive.MessageExt)
Types ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
func NewConsumer ¶
func NewConsumer(cred *RocketMQCredentials, setter ...ConsumerSetter) (*Consumer, error)
func (*Consumer) CheckSubRelation ¶ added in v0.1.5
func (*Consumer) SetErrorCallback ¶
func (c *Consumer) SetErrorCallback(fn func(err error, msg *primitive.MessageExt))
type ConsumerOption ¶
type ConsumerSetter ¶
type ConsumerSetter func(option *ConsumerOption)
func WithBroadcasting ¶
func WithBroadcasting(broadcast bool) ConsumerSetter
func WithConsumeOrderly ¶
func WithConsumeOrderly(orderly bool) ConsumerSetter
func WithConsumeTimeout ¶
func WithConsumeTimeout(n int) ConsumerSetter
func WithConsumerLokHook ¶ added in v0.1.5
func WithConsumerLokHook(f LogHook) ConsumerSetter
func WithInstanceName ¶
func WithInstanceName(name string) ConsumerSetter
func WithMaxTopicCount ¶
func WithMaxTopicCount(count int) ConsumerSetter
func WithReconsumerTime ¶
func WithReconsumerTime(n int32) ConsumerSetter
type CreateTopicError ¶ added in v0.1.5
type ErrorCallback ¶
type ErrorCallback func(err error, msg *primitive.MessageExt)
type MessageSetter ¶
type MessageSetter func(message *Message)
func WithKey ¶
func WithKey(key string) MessageSetter
func WithProperty ¶
func WithProperty(key, value string) MessageSetter
func WithTag ¶
func WithTag(tag string) MessageSetter
type Monitor ¶ added in v0.1.5
type Monitor struct {
Callback LogHook
}
Monitor 信息监控
type MultiSubscription ¶ added in v0.1.5
type OnsClient ¶ added in v0.1.5
type OnsClient struct { Region string AccessKey string SecretKey string InstanceId string Domain string // contains filtered or unexported fields }
func NewOnsClient ¶ added in v0.1.5
func (*OnsClient) ClearConsumerAllTopicMessage ¶ added in v0.1.5
清空消费者组堆积的所有消息, 耗时可能比较久
func (*OnsClient) ClearConsumerTopicMessage ¶ added in v0.1.5
清空消费者组某个topic的消息
func (*OnsClient) ConsumerResetOffset ¶ added in v0.1.5
回溯消息
func (*OnsClient) CreateGroup ¶ added in v0.1.5
创建组
func (*OnsClient) CreateOnsConsumerStatusRequest ¶ added in v0.1.5
func (c *OnsClient) CreateOnsConsumerStatusRequest(group string) (response *ons.OnsConsumerStatusResponse, err error)
回溯消息
func (*OnsClient) CreateTopic ¶ added in v0.1.5
func (*OnsClient) DeleteGroup ¶ added in v0.1.5
删除组
func (*OnsClient) DeleteTopic ¶ added in v0.1.5
func (*OnsClient) ListConsumerGroupSub ¶ added in v0.1.5
获取消费者组订阅的topic
type Producer ¶ added in v0.1.5
type Producer struct {
// contains filtered or unexported fields
}
func NewProducer ¶
func NewProducer(cred *RocketMQCredentials, setter ...ProducerSetter) (*Producer, error)
func (*Producer) CreateTopic ¶ added in v0.1.5
func (p *Producer) CreateTopic(topics ...string) []*CreateTopicError
func (*Producer) RawProducer ¶ added in v0.1.5
func (p *Producer) RawProducer() *rocketmq.Producer
func (*Producer) Send ¶ added in v0.1.5
func (p *Producer) Send(topic string, body []byte, setter ...MessageSetter) SendResult
func (*Producer) SendAsync ¶ added in v0.1.5
func (p *Producer) SendAsync(topic string, body []byte, callback func(ctx context.Context, result *SendResult), setter ...MessageSetter) error
type ProducerOption ¶
type ProducerSetter ¶
type ProducerSetter func(option *ProducerOption)
func WithProducerGroupName ¶
func WithProducerGroupName(name string) ProducerSetter
func WithProducerInstanceName ¶
func WithProducerInstanceName(name string) ProducerSetter
func WithProducerLokHook ¶ added in v0.1.5
func WithProducerLokHook(f LogHook) ProducerSetter
func WithRetry ¶ added in v0.1.5
func WithRetry(retry int) ProducerSetter
func WithSendMessageTimeout ¶
func WithSendMessageTimeout(timeout int) ProducerSetter
type RocketMQCredentials ¶
type RocketMQCredentials struct { NameServer string AccessKey string SecretKey string NameSpace string GroupName string Region string RetryTime int SubCallback []Subscription MultiSubCallback []MultiSubscription }
rocket mq connection config
type SendResult ¶
type SendResult struct { Result *primitive.SendResult Err error }
func (*SendResult) MessageId ¶
func (r *SendResult) MessageId() string
func (*SendResult) Success ¶
func (r *SendResult) Success() bool
type Subscription ¶ added in v0.1.5
Source Files ¶
Click to show internal directories.
Click to hide internal directories.