protocol

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package protocol implements Olric Binary Protocol.

Index

Constants

View Source
const (
	OpPut = OpCode(iota) + 1
	OpPutEx
	OpPutIf
	OpPutIfEx
	OpGet
	OpDelete
	OpDestroy
	OpLock
	OpLockWithTimeout
	OpUnlock
	OpIncr
	OpDecr
	OpGetPut
	OpUpdateRouting
	OpPutReplica
	OpPutIfReplica
	OpPutExReplica
	OpPutIfExReplica
	OpDeletePrev
	OpGetPrev
	OpGetBackup
	OpDeleteBackup
	OpDestroyDMap
	OpMoveDMap
	OpKeyCountOnPart
	OpPipeline
	OpPing
	OpStats
	OpExpire
	OpExpireReplica
)

ops

View Source
const (
	StatusOK = StatusCode(iota)
	StatusInternalServerError
	StatusBadRequest
	StatusErrKeyNotFound
	StatusErrNoSuchLock
	StatusErrLockNotAcquired
	StatusErrWriteQuorum
	StatusErrReadQuorum
	StatusErrOperationTimeout
	StatusErrKeyFound
	StatusErrClusterQuorum
	StatusErrUnknownOperation
)

status codes

Variables

View Source
var ErrConnClosed = errors.New("connection closed")

ErrConnClosed means that the underlying TCP connection has been closed by the client or operating system.

Functions

This section is empty.

Types

type AtomicExtra

type AtomicExtra struct {
	Timestamp int64
}

AtomicExtra defines extra values for this operation.

type ExpireExtra

type ExpireExtra struct {
	TTL       int64
	Timestamp int64
}

ExpireExtrrea defines extra values for this operation.

type Header struct {
	Magic    MagicCode  // 1
	Op       OpCode     // 1
	DMapLen  uint16     // 2
	KeyLen   uint16     // 2
	ExtraLen uint8      // 1
	Status   StatusCode // 1
	BodyLen  uint32     // 4
}

Header defines a message header for both request and response.

type KeyCountOnPartExtra

type KeyCountOnPartExtra struct {
	PartID uint64
	Backup bool
}

KeyCountOnPartExtra defines extra values for this operation.

type LockExtra

type LockExtra struct {
	Deadline int64
}

LockExtra defines extra values for this operation.

type LockWithTimeoutExtra

type LockWithTimeoutExtra struct {
	Timeout  int64
	Deadline int64
}

LockWithTimeoutExtra defines extra values for this operation.

type MagicCode

type MagicCode uint8

MagicCode defines an unique code to distinguish a request message from a response message in Olric Binary Protocol.

const (
	// MagicReq defines an magic code for REQUEST in Olric Binary Protocol
	MagicReq MagicCode = 0xE2

	// MagicRes defines an magic code for RESPONSE in Olric Binary Protocol
	MagicRes MagicCode = 0xE3
)

type Message

type Message struct {
	Header             // [0..10]
	Extra  interface{} // [11..(m-1)] Command specific extras (In)
	DMap   string      // [m..(n-1)] DMap (as needed, length in Header)
	Key    string      // [n..(x-1)] Key (as needed, length in Header)
	Value  []byte      // [x..y] Value (as needed, length in Header)
}

Message defines a protocol message in Olric Binary Protocol.

func (*Message) Error

func (m *Message) Error(status StatusCode, err interface{}) *Message

Error generates an error message for the request.

func (*Message) Read

func (m *Message) Read(conn io.Reader) error

Read reads a whole protocol message(including the value) from given connection by decoding it.

func (*Message) Success

func (m *Message) Success() *Message

Success generates a success message for the request.

func (*Message) Write

func (m *Message) Write(conn io.Writer) error

Write writes a protocol message to given TCP connection by encoding it.

type OpCode

type OpCode uint8

type PutExExtra

type PutExExtra struct {
	TTL       int64
	Timestamp int64
}

PutExExtra defines extra values for this operation.

type PutExtra

type PutExtra struct {
	Timestamp int64
}

PutExtra defines extra values for this operation.

type PutIfExExtra

type PutIfExExtra struct {
	Flags     int16
	Timestamp int64
	TTL       int64
}

PutIfExExtra defines extra values for this operation.

type PutIfExtra

type PutIfExtra struct {
	Flags     int16
	Timestamp int64
}

PutIfExtra defines extra values for this operation.

type StatusCode

type StatusCode uint8

StatusCode ...

type UpdateRoutingExtra

type UpdateRoutingExtra struct {
	CoordinatorId uint64
}

UpdateRoutingExtra defines extra values for this operation.

Jump to

Keyboard shortcuts

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