You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
636 B

package mq
import "time"
type Message struct {
Id string
Body []byte
Time int64
}
type Producer interface {
Publish(topic string, msg []byte) error
MultiPublish(topic string, msgs [][]byte) error
DelayPublish(topic string, delay time.Duration, body []byte) error
Stop()
}
type Consumer interface {
// Subscribe 订阅
// channel topic下多个相同channel只收到一次, 不同channel会各收到一次消息副本
Subscribe(topic string, channel string, handler func(*Message) error) error
// SubscribeBroadcast 订阅广播消息
SubscribeBroadcast(topic string, handler func(*Message) error) error
Stop()
}