command

package
v0.0.0-...-5fa8032 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInputData = errors.New("command: invalid data input for codec")
	ErrCodecNotFound    = errors.New("command: codec not found")
)

Functions

func Encode

func Encode(command *Command) ([]byte, error)

func RegisterCodec

func RegisterCodec(command string, cc codec.Codec)

func RegisterCodecs

func RegisterCodecs(commands map[string]codec.Codec)

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

func NewCodec

func NewCodec() *Codec

func (*Codec) Decode

func (c *Codec) Decode(data []byte) (*Command, error)

func (*Codec) Encode

func (c *Codec) Encode(command *Command) ([]byte, error)

func (*Codec) Register

func (c *Codec) Register(command string, cc codec.Codec)

func (*Codec) RegisterMap

func (c *Codec) RegisterMap(commands map[string]codec.Codec)

type Command

type Command struct {
	// contains filtered or unexported fields
}

func Decode

func Decode(data []byte) (*Command, error)

func New

func New(
	name string,
	streamName string,
	streamID uuid.UUID,
	payload codec.Codec,
) *Command

func (*Command) ID

func (c *Command) ID() uuid.UUID

func (*Command) IsEmptyStreamID

func (c *Command) IsEmptyStreamID() bool

func (*Command) Name

func (c *Command) Name() string

func (*Command) Payload

func (c *Command) Payload() codec.Codec

func (*Command) ReplyErr

func (c *Command) ReplyErr(err error) *Reply

func (*Command) ReplyOk

func (c *Command) ReplyOk(version int) *Reply

func (*Command) StreamID

func (c *Command) StreamID() uuid.UUID

func (*Command) StreamName

func (c *Command) StreamName() string

func (*Command) String

func (c *Command) String() string

func (*Command) Unix

func (c *Command) Unix() int64

type Encoding

type Encoding interface {
	Decode([]byte) (*Command, error)
	Encode(*Command) ([]byte, error)
}

type Reply

type Reply struct {
	// contains filtered or unexported fields
}

func (*Reply) Command

func (r *Reply) Command() uuid.UUID

func (*Reply) Err

func (r *Reply) Err() error

func (*Reply) MarshalBinary

func (r *Reply) MarshalBinary() ([]byte, error)

func (*Reply) StreamVersion

func (r *Reply) StreamVersion() int

func (*Reply) String

func (r *Reply) String() string

func (*Reply) Unix

func (r *Reply) Unix() int64

func (*Reply) UnmarshalBinary

func (r *Reply) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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