simplemq/lib/types/lib.go

28 lines
645 B
Go
Raw Permalink Normal View History

2021-11-15 23:06:05 +00:00
package types
import "encoding/json"
const (
CMD_SUB = "sub"
CMD_UNSUB = "unsub"
CMD_PUB = "pub"
CMD_RPC = "rpc"
CMD_RPCREPLY = "rpcreply"
CMD_CLOSE = "close"
)
type Msg struct {
Cmd string `json:"cmd,omitempty"`
Id string `json:"id,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
Topic string `json:"topic,omitempty"`
Src string `json:"src,omitempty"`
Header map[string]string `json:"header,omitempty"`
Payload []byte `json:"payload,omitempty"`
}
func (m *Msg) Bytes() []byte {
bs, _ := json.Marshal(m)
return bs
}