protocol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCommand

func ParseCommand(r io.Reader) (any, error)

ParseCommand parses command.

Types

type Command

type Command byte

Command represents the different types of commands.

const (
	// CmdNone represents an empty command.
	CmdNone Command = iota
	// CmdSet represents the Set command.
	CmdSet
	// CmdGet represents the Get command.
	CmdGet
	// CmdDel represents the Delete command.
	CmdDel
	// CmdJoin represents the Join command.
	CmdJoin
)

type CommandDelete

type CommandDelete struct {
	Key []byte
}

CommandDelete represents Delete command.

func (*CommandDelete) Bytes

func (c *CommandDelete) Bytes() ([]byte, error)

Bytes returns byte representation of delete command.

type CommandGet

type CommandGet struct {
	Key []byte
}

CommandGet represents Get command.

func (*CommandGet) Bytes

func (c *CommandGet) Bytes() ([]byte, error)

Bytes returns byte representation of get command.

type CommandJoin

type CommandJoin struct{}

CommandJoin represents Join command.

type CommandSet

type CommandSet struct {
	Key   []byte
	Value []byte
	TTL   int
}

CommandSet represents Set command.

func (*CommandSet) Bytes

func (c *CommandSet) Bytes() ([]byte, error)

Bytes returns byte representation of join command.

type ResponseDelete

type ResponseDelete struct {
	Status Status
}

ResponseDelete represents response for Delete command.

func ParseDeleteResponse

func ParseDeleteResponse(r io.Reader) (*ResponseDelete, error)

ParseDeleteResponse parses response to delete command.

func (*ResponseDelete) Bytes

func (r *ResponseDelete) Bytes() ([]byte, error)

Bytes returns byte representation of response to delete command.

type ResponseGet

type ResponseGet struct {
	Status Status
	Value  []byte
}

ResponseGet represents response for Get command.

func ParseGetResponse

func ParseGetResponse(r io.Reader) (*ResponseGet, error)

ParseGetResponse parses response to get command.

func (*ResponseGet) Bytes

func (r *ResponseGet) Bytes() ([]byte, error)

Bytes returns byte representation of response to get command.

type ResponseSet

type ResponseSet struct {
	Status Status
}

ResponseSet represents response for Set command.

func ParseSetResponse

func ParseSetResponse(r io.Reader) (*ResponseSet, error)

ParseSetResponse parses response to set command.

func (*ResponseSet) Bytes

func (r *ResponseSet) Bytes() ([]byte, error)

Bytes returns byte representation of response to set command.

type Status

type Status byte

Status represents the different status types for responses.

const (
	// StatusNone represents an empty status.
	StatusNone Status = iota
	// StatusOK represents a successful status.
	StatusOK
	// StatusError represents an error status.
	StatusError
	// StatusKeyNotFound represents a key not found status.
	StatusKeyNotFound
	// StatusNotLeader represents a not leader status.
	StatusNotLeader
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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