server

package
v0.0.0-...-fc15ddb Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: MPL-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdRouter

type CmdRouter struct {
	Handlers       map[string]Handler
	UnknownHandler Handler
}

Command Router Implementation

func (*CmdRouter) Handler

func (c *CmdRouter) Handler(cmd string) Handler

Handler by command name

type Handler

type Handler interface {
	Exec(cmd *prot.Cmd) ([]byte, error)
}

Handler interface for a Command Handlers are responsible for executing a command

type Router

type Router interface {
	Handler(cmd string) Handler
}

Command Router takes in a command name and returns a handler

type Server

type Server struct {
	Addr   string // Network Address to listen on
	Router Router
	Prot   prot.Interface
	// contains filtered or unexported fields
}

Workq Server listens on a TCP Address Requires a Command Router and a Protocol Implementation

func New

func New(addr string, router Router, protocol prot.Interface) *Server

New returns a initialized, but unstarted Server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

Start a Workq Server, listening on the specified TCP address

func (*Server) Stats

func (s *Server) Stats() Stats

Stats returns stats for the server at the current time.

func (*Server) Stop

func (s *Server) Stop() error

Stops listening while maintaining all active connections

type Stats

type Stats struct {
	// Number of active clients current connected.
	ActiveClients uint64

	// Started represents the time immediately after the server starts listening.
	Started time.Time
}

Stats Data

Jump to

Keyboard shortcuts

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