protocol

package
v0.0.0-...-10a1ecf Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2016 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultParser = NewParser(map[string]func() Message{
	"delete":  func() Message { return &DeleteMessage{} },
	"error":   func() Message { return &ErrorMessage{} },
	"job":     func() Message { return &JobMessage{} },
	"peek":    func() Message { return &PeekMessage{} },
	"ping":    func() Message { return &PingMessage{} },
	"reserve": func() Message { return &ReserveMessage{} },
	"success": func() Message { return &SuccessMessage{} },
})
View Source
var (
	MessageSize = 1024 * 16
)

Functions

func Serialise

func Serialise(m Message) []byte

Types

type DeleteMessage

type DeleteMessage struct {
	Key   string
	Queue string
	ID    string
}

func (DeleteMessage) GetKey

func (m DeleteMessage) GetKey() string

func (DeleteMessage) Serialise

func (m DeleteMessage) Serialise() []byte

func (*DeleteMessage) SetKey

func (m *DeleteMessage) SetKey(key string)

type ErrUnknownType

type ErrUnknownType error

type ErrorMessage

type ErrorMessage struct {
	Key    string
	Reason string
}

func (ErrorMessage) GetKey

func (m ErrorMessage) GetKey() string

func (ErrorMessage) Serialise

func (m ErrorMessage) Serialise() []byte

func (*ErrorMessage) SetKey

func (m *ErrorMessage) SetKey(key string)

type JobMessage

type JobMessage struct {
	Key       string
	ID        string
	Queue     string
	Priority  float64
	HoldUntil int64
	TTR       uint64
	Content   string
}

func (JobMessage) GetKey

func (m JobMessage) GetKey() string

func (JobMessage) Serialise

func (m JobMessage) Serialise() []byte

func (*JobMessage) SetKey

func (m *JobMessage) SetKey(key string)

type Message

type Message interface {
	GetKey() string
	SetKey(key string)
	Serialise() []byte
}

func Parse

func Parse(d []byte) (Message, error)

type Parser

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

func NewParser

func NewParser(types map[string]func() Message) *Parser

func (*Parser) Parse

func (p *Parser) Parse(d []byte) (Message, error)

func (*Parser) Types

func (p *Parser) Types() []string

type PeekMessage

type PeekMessage struct {
	Key   string
	Queue string
}

func (PeekMessage) GetKey

func (m PeekMessage) GetKey() string

func (PeekMessage) Serialise

func (m PeekMessage) Serialise() []byte

func (*PeekMessage) SetKey

func (m *PeekMessage) SetKey(key string)

type PingMessage

type PingMessage struct {
	Key string
}

func (PingMessage) GetKey

func (m PingMessage) GetKey() string

func (PingMessage) Serialise

func (m PingMessage) Serialise() []byte

func (*PingMessage) SetKey

func (m *PingMessage) SetKey(key string)

type ReserveMessage

type ReserveMessage struct {
	Key   string
	Queue string
}

func (ReserveMessage) GetKey

func (m ReserveMessage) GetKey() string

func (ReserveMessage) Serialise

func (m ReserveMessage) Serialise() []byte

func (*ReserveMessage) SetKey

func (m *ReserveMessage) SetKey(key string)

type SuccessMessage

type SuccessMessage struct {
	Key string
}

func (SuccessMessage) GetKey

func (m SuccessMessage) GetKey() string

func (SuccessMessage) Serialise

func (m SuccessMessage) Serialise() []byte

func (*SuccessMessage) SetKey

func (m *SuccessMessage) SetKey(key string)

Jump to

Keyboard shortcuts

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