Documentation ¶
Overview ¶
Package queue chain33底层消息队列模块
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrIsQueueClosed = errors.New("ErrIsQueueClosed") ErrQueueTimeout = errors.New("ErrQueueTimeout") ErrQueueChannelFull = errors.New("ErrQueueChannelFull") )
消息队列的错误
Functions ¶
Types ¶
type Client ¶
type Client interface { Send(msg *Message, waitReply bool) (err error) //同步发送消息 SendTimeout(msg *Message, waitReply bool, timeout time.Duration) (err error) Wait(msg *Message) (*Message, error) //等待消息处理完成 WaitTimeout(msg *Message, timeout time.Duration) (*Message, error) //等待消息处理完成 Recv() chan *Message Reply(msg *Message) Sub(topic string) //订阅消息 Close() CloseQueue() (*types.Reply, error) NewMessage(topic string, ty int64, data interface{}) (msg *Message) FreeMessage(msg ...*Message) //回收msg, 需要注意回收时上下文不再引用 GetConfig() *types.Chain33Config }
Client 消息队列的接口,每个模块都需要一个发送接受client
type Message ¶
type Message struct { Topic string Ty int64 ID int64 Data interface{} // contains filtered or unexported fields }
Message message struct
func NewMessage ¶
NewMessage new message
func NewMessageCallback ¶
func NewMessageCallback(id int64, topic string, ty int64, data interface{}, callback func(msg *Message)) (msg *Message)
NewMessageCallback reply block
type Module ¶
type Module interface { SetQueueClient(client Client) //wait for ready Wait() Close() }
Module be used for module interface
type Queue ¶
type Queue interface { Close() Start() Client() Client Name() string SetConfig(cfg *types.Chain33Config) GetConfig() *types.Chain33Config }
Queue only one obj in project Queue only generate Client and start、Close operate, if you send massage or receive massage on Queue, please use Client.
Click to show internal directories.
Click to hide internal directories.