server

package
v0.0.0-...-81a0ef2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2015 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package server implements a publisher/consumer ring-buffer experiment.

Index

Constants

View Source
const (
	DefaultHostname         = "localhost" // The hostname of the server.
	DefaultPort             = 6660        // Port to receive requests: see IANA Port Numbers.
	DefaultProfPort         = 0           // Profiler port to receive requests. *
	DefaultConsumerHostname = "localhost" // The hostname of the remote consumer server.
	DefaultConsumerPort     = 6660        // The port of the remote consumer server.
	DefaultIsPublisher      = true        // Is the server a publisher? true = pub; false = consumer.
	DefaultMaxConns         = 0           // Maximum number of incoming connections allowed (ws and/or web). *
	DefaultMaxWorkers       = 1024        // Maximum number of outgoing worker connections allowed ( to consumer).
	DefaultRingSize         = 4096        // Ring buffer size. Note this should be a power of 2. Ignored if consumer.
	DefaultMaxProcs         = 0           // Maximum number of computer processors to utilize. *

)

Variables

This section is empty.

Functions

func PrintUsageAndExit

func PrintUsageAndExit()

PrintUsageAndExit is used to print out command line options.

func PrintVersionAndExit

func PrintVersionAndExit()

PrintVersionAndExit prints the version of the server then exits.

Types

type Info

type Info struct {
	Version          string `json:"version"`          // Version of the server.
	UUID             string `json:"UUID"`             // Unique ID of the server.
	Name             string `json:"name"`             // The name of the server.
	Hostname         string `json:"hostname"`         // The hostname of the server.
	Port             int    `json:"port"`             // Port the server is listening on.
	MaxConns         int    `json:"maxConns"`         // The maximum concurrent clients accepted.
	IsPublisher      bool   `json:"isPublisher"`      // Is the server a publisher (true) or a consumer (false)?
	RingSize         int    `json:"ringSize"`         // The ring buffer size in slots, if publisher else ignored.
	ConsumerHostname string `json:"consumerHostname"` // The hostname of the consumer server if this is a publisher.
	ConsumerPort     int    `json:"consumerPort"`     // The port of the consumer server if this is a publisher.
	MaxWorkers       int    `json:"maxWorkers"`       // The maximum outgoing workers allowed if publisher.
	ProfPort         int    `json:"profPort"`         // Profiler port the server is listening on.
	Debug            bool   `json:"debugEnabled"`     // Is debugging enabled on the server.
}

Info provides basic config information to/about the running server.

func InfoNew

func InfoNew(opts ...func(*Info)) *Info

InfoNew is a factory function that returns a new instance of Info. opts is an optional list of functions that initialize the structure

func (*Info) String

func (i *Info) String() string

String is an implentation of the Stringer interface so the structure is returned as a string to fmt.Print() etc.

type Ingest

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

Ingest is a wrapper around an incoming connection to a publishing/consuming server.

func IngestNew

func IngestNew(w *websocket.Conn, q chan bool, l *RingoExpLogger, swg *sync.WaitGroup) *Ingest

IngestNew is a factory function that returns a new Ingest instance

func (*Ingest) Run

func (i *Ingest) Run()

Run starts the event loop that manages the receiving of information from the remote client.

type IngestConsumer

type IngestConsumer struct {
	*Ingest
}

IngestConsumer is a wrapper around an incoming connection to a publishing server.

func IngestConsumerNew

func IngestConsumerNew(w *websocket.Conn, q chan bool, l *RingoExpLogger, swg *sync.WaitGroup) *IngestConsumer

IngestConsumerNew is a factory function that returns a new IngestConsumer instance

type IngestPublisher

type IngestPublisher struct {
	*Ingest
	// contains filtered or unexported fields
}

IngestPublisher is a wrapper around an incoming connection to a publishing server.

func IngestPublisherNew

func IngestPublisherNew(w *websocket.Conn, q chan bool, r []int, m *ringbuffer.Manager,
	l *RingoExpLogger, swg *sync.WaitGroup) *IngestPublisher

IngestPublisherrNew is a factory function that returns a new IngestPublisher instance

type Ingester

type Ingester interface {
	Run()
	// contains filtered or unexported methods
}

type Options

type Options struct {
	Name             string `json:"name"`             // The name of the server.
	Hostname         string `json:"hostname"`         // The hostname of the server.
	Port             int    `json:"port"`             // The default port of the server.
	MaxConns         int    `json:"maxConns"`         // The maximum incoming connections allowed.
	IsPublisher      bool   `json:"isPublisher"`      // Is the server a publisher (true) or a consumer (false)?
	RingSize         int    `json:"ringSize"`         // The ring buffer size in slots, if publisher else ignored.
	ConsumerHostname string `json:"consumerHostname"` // The hostname of the consumer server if this is a publisher.
	ConsumerPort     int    `json:"consumerPort"`     // The port of the consumer server if this is a publisher.
	MaxWorkers       int    `json:"maxWorkers"`       // The maximum outgoing workers allowed if publisher.
	MaxProcs         int    `json:"maxProcs"`         // The maximum number of processor cores available.
	ProfPort         int    `json:"profPort"`         // The profiler port of the server.
	Debug            bool   `json:"debugEnabled"`     // Is debugging enabled in the application or server.
}

Options represents parameters that are passed to the application to be used in constructing the server.

func (*Options) String

func (o *Options) String() string

String is an implentation of the Stringer interface so the structure is returned as a string to fmt.Print() etc.

type RingoExpLogger

type RingoExpLogger struct {
	*logger.Logger
}

RingoExpLogger is an enhancement over the base logger for application logging patterns.

func RingoExpLoggerNew

func RingoExpLoggerNew() *RingoExpLogger

RingoExpLoggerNew is a factory function that returns a new RingoExpLogger instance.

func (*RingoExpLogger) LogConnect

func (l *RingoExpLogger) LogConnect(r *http.Request)

LogConnect is used to log request information when the client first connects to the server.

func (*RingoExpLogger) LogError

func (l *RingoExpLogger) LogError(addr string, msg string)

LogError is used to record misc session error information between server and client.

func (*RingoExpLogger) LogSession

func (l *RingoExpLogger) LogSession(tp string, addr string, msg string)

LogSession is used to record information received during the client's session.

type Server

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

Server is the main structure that represents a server instance.

func New

func New(ops *Options) *Server

New is a factory function that returns a new server instance.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown takes down the server gracefully back to an initialize state.

func (*Server) Start

func (s *Server) Start() error

Start spins up the server to accept incoming connections.

func (*Server) StartProfiler

func (s *Server) StartProfiler()

StartProfiler is called to enable dynamic profiling.

type Stats

type Stats struct {
	Start time.Time `json:"startTime"` // The start time of the server.
}

Stats contains runtime statistics for the server.

func StatsNew

func StatsNew(opts ...func(*Stats)) *Stats

StatsNew is a factory function that returns a new instance of statistics. options is an optional list of functions that initialize the structure

func (*Stats) String

func (s *Stats) String() string

String is an implentation of the Stringer interface so the structure is returned as a string to fmt.Print() etc.

Jump to

Keyboard shortcuts

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