cubeserver

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgPrefixFail for failed operation replies
	MsgPrefixFail = byte(0)
	// MsgPrefixSuccess for successful operation replies
	MsgPrefixSuccess = byte(1)
)
View Source
const OK = ""

OK is a reply for successful but idempotent operations

View Source
const (
	// Version for server
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

func ParseCommandInput

func ParseCommandInput(input string) (command string, args []string)

ParseCommandInput parses command returns command and its argument array separately.

Types

type Command

type Command struct {
	ShortDescription string   `json:"short"`
	Description      string   `json:"description"`
	Executor         Executor `json:"-"`
}

Command is a constituent of server language

type Executor

type Executor func(server *Server, args ...string) (string, error)

Executor function does all the work for command.

type Interpreter

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

Interpreter interprets given string command and executes it on the server. Interpreter are not thread safe intentionally, so each routine must own an interpreter.

func (*Interpreter) Interpret

func (interpreter *Interpreter) Interpret(server *Server, input string) (string, error)

Interpret parses given command and run it on server then returns the result.

type Lexicon

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

A Lexicon consists of all commands of server

func (*Lexicon) AsJSON

func (l *Lexicon) AsJSON() (string, error)

AsJSON Converts whole lexicon to a JSON string

func (*Lexicon) CreateInterpreter

func (l *Lexicon) CreateInterpreter() *Interpreter

CreateInterpreter creates new interpreter from clone of lexicon Note that interpreters not thread safe intentionally

func (*Lexicon) Put

func (l *Lexicon) Put(name string, cmd *Command)

Put adds a new command to lexicon

type Message

type Message struct {
	Route   []byte
	Message []byte
}

Message between client and server

type Server

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

Server is Cardinality Cube Server

func NewServer

func NewServer(cubeToServe *cube.Cube, endPoints string, processQueueSize int, responseQueueSize int, numProcessWorkers int) *Server

NewServer creates new server

func (*Server) Dump added in v0.3.1

func (s *Server) Dump() ([]byte, error)

Dump returns server data serialized to bytes

func (*Server) Load added in v0.3.1

func (s *Server) Load(data []byte) error

Load loads serialized data into server. Existing data will be replaced.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown gracefully stops server

func (*Server) Start

func (s *Server) Start() error

Start initiates the server routines and waits for outputs.

Jump to

Keyboard shortcuts

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