msg

package
v0.0.0-...-ca996c7 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2015 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ActionHandshake = iota
	ActionGet
	ActionSet
)
View Source
const (
	StatusSuccess = iota
	StatusClientError
	StatusServerError
	StatusKeyNotFound
)

Variables

View Source
var (
	ErrUnknownAction = errors.New("Unknown Action")
)

Errors

Functions

This section is empty.

Types

type Command

type Command struct {
	SubCommand

	Id     string
	Action int
}

Command is the root element for issuing a command from a client to a server.

func DecodeCommand

func DecodeCommand(r io.Reader) (*Command, error)

DecodeCommand reads from an io.Reader and decodes the command.

func NewCommand

func NewCommand(id string, sb SubCommand) *Command

NewCommand constructs and returns a new Command.

func (*Command) Encode

func (c *Command) Encode(wr io.Writer) error

Encode prepares a command to be issued over the wire.

type GetCommand

type GetCommand struct {
	Key string
}

GetCommand is get command that can be issued by a client to a server.

func NewGetCommand

func NewGetCommand(key string) GetCommand

NewGetCommand creates a new GetCommand to be used as a SubCommand on a Command.

type GetResult

type GetResult struct {
	Key    string
	Value  string
	Expiry int64
}

func NewGetResult

func NewGetResult(key, value string, expiry int64) GetResult

type HandshakeCommand

type HandshakeCommand struct {
	UserAgent string
}

HandshakeCommand is the first command that should be issued to a server imediately after opening a new connection.

func NewHandshakeCommand

func NewHandshakeCommand(agent string) HandshakeCommand

NewHandshakeCommand creates a new HandshakeCommand to be used as a SubCommand on a Command.

type HandshakeResult

type HandshakeResult struct {
	ClientId string
}

func NewHandshakeResult

func NewHandshakeResult(clientId string) HandshakeResult

type Result

type Result struct {
	SubResult

	Id     string
	Action int
	Status int
}

func DecodeResult

func DecodeResult(r io.Reader) (*Result, error)

DecodeResult reads from an io.Reader and decodes a result.

func NewResult

func NewResult(id string, status int, sr SubResult) *Result

NewResult constructs and returns a new Result

func (*Result) Encode

func (rs *Result) Encode(wr io.Writer) error

Encode prepares a result and writes it to an io.Writer

type SetCommand

type SetCommand struct {
	Key    string
	Value  string
	Expiry int64 // Todo: Should this be Time instead, does capnp suppor that?
}

func NewSetCommand

func NewSetCommand(key, value string, expiry int64) SetCommand

type SetResult

type SetResult struct{}

func NewSetResult

func NewSetResult() SetResult

type SubCommand

type SubCommand interface {
	// contains filtered or unexported methods
}

type SubResult

type SubResult interface {
	// contains filtered or unexported methods
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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