codec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package codec is an interface for encoding messages

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMessage = errors.New("invalid message")
)

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Reader
	Writer
	Init(io.ReadWriteCloser)
	Close() error
	String() string
}

type LogBody

type LogBody struct {
	Name      string                   `json:"name"`
	Log       string                   `json:"log"`
	Tags      []map[string]interface{} `json:"tags"`
	Timestamp time.Time                `json:"timestamp"`
}

LogBody describe body of a single packets. It contains the name of log with log to store and tags along with timestamp field which contains the time of creation of log

type NewCodec

type NewCodec func(io.ReadWriteCloser) Codec

Takes in a connection/buffer and returns a new Codec

type Packet

type Packet struct {
	// ID of packet
	ID uuid.UUID `json:"id"`
	// Cmd is command containing the packets
	Cmd string `json:"cmd"`
	// Body is body of associated with command
	Body *LogBody `json:"body"`
	// Ack acknowledges for sent request
	Ack bool
	// Error
	Error error
	// Timestamp is time of packet creation.
	Timestamp time.Time `json:"timestamp"`
}

Packet is type of every packet that gets transported from client to server to client.

type Reader

type Reader interface {
	Read(interface{}) error
}

type Writer

type Writer interface {
	Write(interface{}) error
}

Directories

Path Synopsis
Package json provides a json codec
Package json provides a json codec

Jump to

Keyboard shortcuts

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