Documentation ¶
Index ¶
- Constants
- Variables
- func Marshal(p *Proto) ([]byte, error)
- func Unmarshal(buf []byte, p *Proto) error
- type AckProto
- type BindOKProto
- type BindProto
- type Coder
- type Decoder
- type Encoder
- type HeartbeatProto
- type Proto
- type ProtoError
- type PublishOKProto
- type PublishProto
- type PushProto
- type UnbindOKProto
- type UnbindProto
Constants ¶
View Source
const ( Publish uint32 = 10 Publish_OK uint32 = 11 Bind uint32 = 20 Bind_OK uint32 = 21 Unbind uint32 = 30 Unbind_OK uint32 = 31 //asynchronous > 10000 Error uint32 = 10010 Heartbeat uint32 = 10020 Push uint32 = 10030 Ack uint32 = 10040 )
View Source
const ( MsgIdStr = "msg_id" VersionStr = "version" PubTypeStr = "pub_type" QueueStr = "queue" RoutingKeyStr = "routing_key" NoAckStr = "no_ack" CodeStr = "code" )
View Source
const ( DirectType uint8 = 0 FanoutType uint8 = 1 )
View Source
const ( DirectPubTypeStr = "direct" FanoutPubTypeStr = "fanout" )
View Source
const ( MaxQueueName = 200 MaxRoutingKeyName = 200 )
Variables ¶
View Source
var ( ErrInvalidBuf = errors.New("invalid decode buf") ErrBufShort = errors.New("decode buf is too short") )
View Source
var PublishTypeMap = map[string]uint8{ DirectPubTypeStr: DirectType, FanoutPubTypeStr: FanoutType, }
Functions ¶
Types ¶
type AckProto ¶
type AckProto struct {
P *Proto
}
Method: Ack Fields:
queue: xxx msg_id: xxx (int64 string)
func NewAckProto ¶
type BindOKProto ¶
type BindOKProto struct {
P *Proto
}
Method: Bind_OK Fields:
queue: xxx
func NewBindOKProto ¶
func NewBindOKProto(queue string) *BindOKProto
type BindProto ¶
type BindProto struct {
P *Proto
}
Method: Bind Fields:
queue: xxx routing_key: xxx no_ack: 1 or none
Body: nil
type Coder ¶
type Coder struct {
// contains filtered or unexported fields
}
func NewCoder ¶
func NewCoder(rb io.ReadWriter) *Coder
type HeartbeatProto ¶
type HeartbeatProto struct {
P *Proto
}
Method: Heartbeat Fields: nil Body: nil
func NewHeartbeatProto ¶
func NewHeartbeatProto() *HeartbeatProto
type Proto ¶
type Proto struct { Method uint32 `json:"method"` Fields map[string]string `json:"fields"` Body []byte `json:"-"` }
func (*Proto) RoutingKey ¶
type ProtoError ¶
type ProtoError struct {
P *Proto
}
Method: Error Fields:
code: xxx (http error code, int string)
Body: message
func NewProtoError ¶
func NewProtoError(code int, message string) *ProtoError
func (*ProtoError) Error ¶
func (p *ProtoError) Error() string
type PublishOKProto ¶
type PublishOKProto struct {
P *Proto
}
Method: Publish_OK Fields: nil Body: msg id (int64 string)
func NewPublishOKProto ¶
func NewPublishOKProto(msgId string) *PublishOKProto
type PublishProto ¶
type PublishProto struct {
P *Proto
}
Method: Publish Fields:
queue: xxx routing_key: xxx //type: direct|fanout //direct select a consumer to push using round-robin //fanout broadcast to all consumers, ignore routing key pub_type: xxx
Body:
body
func NewPublishProto ¶
func NewPublishProto(queue string, routingKey string, pubType string, body []byte) *PublishProto
type PushProto ¶
type PushProto struct {
P *Proto
}
Method: Push Fields:
queue: xxx msg_id: xxx
Body:
body
type UnbindOKProto ¶
type UnbindOKProto struct {
P *Proto
}
Method: Unbind_OK Fields:
//if queue is empty, we will unbind all queues queue: xxx
func NewUnbindOKProto ¶
func NewUnbindOKProto(queue string) *UnbindOKProto
type UnbindProto ¶
type UnbindProto struct {
P *Proto
}
Method: Unbind Fields:
queue: xxx
Body: nil
func NewUnbindProto ¶
func NewUnbindProto(queue string) *UnbindProto
Click to show internal directories.
Click to hide internal directories.