protocol

package
Version: v0.0.0-...-d20dd18 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const MaxHeartbeatSize = 1400
View Source
const MinimumMessageSize = 13

MinimumMessageSize is the minimum size of every Message

Variables

This section is empty.

Functions

This section is empty.

Types

type AmAlive

type AmAlive struct {
	KnownChunks          []AmAliveChunk //Chunks known by the server
	RecentlyAddedServers []string
	RecentlyDeadServers  []string
}

AmAlive stores heartbeat information

func AmAliveUnMarshal

func AmAliveUnMarshal(msg []byte) (*AmAlive, error)

AmAliveUnMarshal unserializes s into an AmAlive object

func (*AmAlive) Marshal

func (aa *AmAlive) Marshal() []byte

Marshal serializes aa into a []byte

type AmAliveChunk

type AmAliveChunk struct {
	ID       int
	Checksum uint64
}

type Message

type Message struct {
	Type       Operation
	ID         uint32
	Key, Value []byte
}

Message stores a DB message that can be sent and recieved using a network connection

func Unmarshal

func Unmarshal(src []byte) (m Message)

Unmarshal unserializes a message from a buffer Returned message key and value are copied (src can be reused after calling this)

func (*Message) Marshal

func (m *Message) Marshal(dest []byte) (msgSize int, tooLong bool)

Marshal serializes the message on the destination buffer if the destination buffer has enought size If it doesn't it returns the message size and "true"

type Operation

type Operation uint8

Operation represents a DB operation or result, the Message type

const (
	//Primitives
	OpGet Operation = iota + 1
	OpSet
	OpAsyncSet
	OpDel
	OpCAS
)

These constants represents the different message types

const (
	//Advanced ops
	OpAddServerToGroup Operation = iota + 100
	OpGetConf
	OpGetChunkInfo
	OpProtect
	OpTransfer
	OpSetBuffered
	OpSetNoDelay
	OpDefrag
	OpForgetNode
)
const (
	//Responses
	OpOK Operation = iota + 200
	OpErr
	OpResponse
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL