proto

package
v0.0.0-...-65c615f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2014 License: MIT Imports: 6 Imported by: 8

Documentation

Index

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")
)

Functions

func Marshal

func Marshal(p *Proto) ([]byte, error)

func Unmarshal

func Unmarshal(buf []byte, p *Proto) error

Types

type AckProto

type AckProto struct {
	P *Proto
}

Method: Ack Fields:

queue: xxx
msg_id: xxx (int64 string)

func NewAckProto

func NewAckProto(queue string, msgId string) *AckProto

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

func NewBindProto

func NewBindProto(queue string, routingKey string, noAck bool) *BindProto

type Coder

type Coder struct {
	// contains filtered or unexported fields
}

func NewCoder

func NewCoder(rb io.ReadWriter) *Coder

func (*Coder) Decode

func (c *Coder) Decode() (*Proto, error)

func (*Coder) Encode

func (c *Coder) Encode(p *Proto) error

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode() (*Proto, error)

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(p *Proto) error

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 NewProto

func NewProto(method uint32, fields map[string]string, body []byte) *Proto

func (*Proto) MsgId

func (p *Proto) MsgId() string

func (*Proto) PubType

func (p *Proto) PubType() string

func (*Proto) Queue

func (p *Proto) Queue() string

func (*Proto) RoutingKey

func (p *Proto) RoutingKey() string

func (*Proto) Value

func (p *Proto) Value(key string) string

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

func NewPushProto

func NewPushProto(queue string, msgId string, body []byte) *PushProto

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL