server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoServiceError     = xrr.Xrror("no service named %s available").Out
	UnknownActionError = xrr.Xrror("unknown action %s").Out
)
View Source
var (
	NONE   = []byte("none")
	SYSTEM = []byte("system")
	QUERY  = []byte("query")
	DATA   = []byte("data")
)
View Source
var (
	UNKNOWN           = []byte("unknown")
	PING              = []byte("ping")
	QUIT              = []byte("quit")
	STATUS            = []byte("status")
	QUERYFEATURE      = []byte("query_feature")
	QUERYCOMPONENT    = []byte("query_component")
	QUERYENTITY       = []byte("query_entity")
	POPULATEFROMFILES = []byte("populate_from_files")
	DEPOPULATE        = []byte("depopulate")
	APPLYFEATURE      = []byte("apply_feature")
	APPLYCOMPONENT    = []byte("apply_component")
	APPLYENTITY       = []byte("apply_entity")
)
View Source
var NullResponse []byte
View Source
var Sep []byte = []byte("++")

Functions

This section is empty.

Types

type Action

type Action []byte

func ByteAction

func ByteAction(s string) Action

func (Action) String

func (a Action) String() string

type Config

type Config interface {
	Order() int
	Configure(*Server) error
}

func DefaultConfig

func DefaultConfig(fn ConfigFn) Config

func NewConfig

func NewConfig(order int, fn ConfigFn) Config

func SetConstructorPluginDirs

func SetConstructorPluginDirs(dirs ...string) Config

func SetFeatureEnvironment

func SetFeatureEnvironment(f env.Env) Config

func SetFeaturePluginDirs

func SetFeaturePluginDirs(groups []string, dirs ...string) Config

func SetHandler

func SetHandler(hs ...*Handler) Config

func SetLogger

func SetLogger(l log.Logger) Config

func SetPopulateComponents

func SetPopulateComponents(groups []string, files ...string) Config

func SetPopulateEntities

func SetPopulateEntities(groups []string, files ...string) Config

func SetPopulateFeatures

func SetPopulateFeatures(groups []string, files ...string) Config

func SetSocketPath

func SetSocketPath(p string) Config

type ConfigFn

type ConfigFn func(*Server) error

type Configuration

type Configuration interface {
	Add(...Config)
	AddFn(...ConfigFn)
	Configure() error
	Configured() bool
}

type Handler

type Handler struct {
	Service, Action string
	Fn              HandlerFunc
}

func NewHandler

func NewHandler(service, action string, fn HandlerFunc) *Handler

type HandlerFunc

type HandlerFunc func(*Server, *Request) []byte

type Handlers

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

func NewHandlers

func NewHandlers(hn ...*Handler) *Handlers

func (*Handlers) GetHandle

func (h *Handlers) GetHandle(service, action string) (HandlerFunc, error)

func (*Handlers) GetRequestedHandle

func (h *Handlers) GetRequestedHandle(r *Request) (HandlerFunc, error)

func (*Handlers) SetHandle

func (h *Handlers) SetHandle(hs ...*Handler)

type Listener

type Listener struct {
	Error error
	*net.UnixListener
	// contains filtered or unexported fields
}

func NewListener

func NewListener(socket string, fn ProcessFunc) *Listener

type ProcessFunc

type ProcessFunc func([]byte) []byte

type Request

type Request struct {
	Service Service
	Action  Action
	Data    *data.Vector
}

func NewRequest

func NewRequest(s Service, a Action, d *data.Vector) *Request

func (*Request) ToByte

func (r *Request) ToByte() []byte

type Response

type Response struct {
	Error string
	Data  *data.Vector
}

func EmptyResponse

func EmptyResponse() *Response

func ErrorResponse

func ErrorResponse(e error) *Response

func NewResponse

func NewResponse(b []byte) *Response

func (*Response) ToByte

func (r *Response) ToByte() []byte

type Server

type Server struct {
	Configuration

	log.Logger
	env.Env
	*Listener

	*Handlers
	// contains filtered or unexported fields
}

func New

func New(c ...Config) *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) Quit

func (s *Server) Quit()

func (*Server) Serve

func (s *Server) Serve()

func (*Server) SignalHandler

func (s *Server) SignalHandler(sig os.Signal)

type Service

type Service []byte

func ByteService

func ByteService(s string) Service

func (Service) String

func (s Service) String() string

type Space

type Space [][]byte

func NewSpace

func NewSpace(in []byte) Space

func (Space) Action

func (s Space) Action() Action

func (Space) Data

func (s Space) Data() *data.Vector

func (Space) Service

func (s Space) Service() Service

Jump to

Keyboard shortcuts

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