transport

package
v0.0.0-...-766f130 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolName    = "quibe"
	ProtocolVersion = "0.1"

	ClientTypeProducer = "P"
	ClientTypeConsumer = "C"

	Success              = "OK"
	ErrUnknownProtocol   = "UnknownProtocol"
	ErrInvalidVersion    = "InvalidVersion"
	ErrUnsupportedClient = "UnsupportedClient"
	ErrInvalidClientID   = "InvalidClientID"
	ErrInvalidQueueName  = "InvalidQueueName"
	ErrUnknownQueue      = "UnknownQueue"
	ErrInternal          = "InternalError"
)

Variables

View Source
var (
	EmptyMessage = NewMessage([]byte(emptyBody))
)

Functions

func ReadFrame

func ReadFrame(r io.Reader) ([]byte, error)

TODO accept frame type as parameter and return that instead of []byte. It depends on having a common interface for frames.

func WriteFrame

func WriteFrame(frame interface{}, w io.Writer) error

TODO interface{} here sucks!

func WriteMessage

func WriteMessage(clientID string, msg *Message, w io.Writer) error

func WriteResponse

func WriteResponse(clientID string, response string, w io.Writer) error

Types

type ConsumeRequestFrame

type ConsumeRequestFrame struct {
	ClientID string
	Queue    string
}

func ReadConsumeRequestFrame

func ReadConsumeRequestFrame(r io.Reader) (*ConsumeRequestFrame, error)

type HandshakeRequestFrame

type HandshakeRequestFrame struct {
	Protocol   string
	Version    string
	ClientType string
	Queue      string
}

func ReadHandshakeRequest

func ReadHandshakeRequest(r io.Reader) (*HandshakeRequestFrame, error)

func (*HandshakeRequestFrame) Verify

func (f *HandshakeRequestFrame) Verify() error
type Header struct{}

type Message

type Message struct {
	Headers map[string]Header
	Body    []byte
}

func NewMessage

func NewMessage(body []byte) Message

func (*Message) BodyString

func (m *Message) BodyString() string

func (*Message) IsEmpty

func (m *Message) IsEmpty() bool

type MessageFrame

type MessageFrame struct {
	ClientID string
	Message  Message
}

type ProduceRequestFrame

type ProduceRequestFrame struct {
	ClientID string
	Queue    string
	Message  Message
}

func ReadProduceRequestFrame

func ReadProduceRequestFrame(r io.Reader) (*ProduceRequestFrame, error)

type ResponseFrame

type ResponseFrame struct {
	Protocol     string
	Version      string
	ClientID     string
	Success      bool
	Response     string
	ResponseCode uint32
}

type UUID

type UUID [16]byte

Code taken from https://github.com/gorilla/feeds/blob/master/uuid.go

func NewUUID

func NewUUID() *UUID

create a new uuid v4

func (*UUID) String

func (u *UUID) String() string

Jump to

Keyboard shortcuts

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