alkasir: Index | Files

package server

import ""

Entrypoint for running as a service.

Provides pluggble network transports this is the run-as part of the service specification..


Package Files

entrypoint.go server.go


var Stdout io.Writer = shared.SyncWriter{File: os.Stdout}

Writer to which pluggable transports negotiation messages are written. It defaults to a Writer that writes to os.Stdout and calls Sync after each write.

func AddChecker Uses

func AddChecker(check Check)

func CheckServiceEnv Uses

func CheckServiceEnv() bool

checks if it is a good idea to start as a service process

func RunService Uses

func RunService()

start serving t

func ServiceNotFound Uses

func ServiceNotFound() error

func TransportNotFound Uses

func TransportNotFound() error

type Check Uses

type Check func(serviceName *Option) (Parser, error)

type Checker Uses

type Checker interface {
    Check(serviceName *Option) (Parser, error)

Check if service is supported

type MethodHandler Uses

type MethodHandler struct {
    // contains filtered or unexported fields

Handler for a service method

func NewHandler Uses

func NewHandler(method string) *MethodHandler

Create a new Handler

func (*MethodHandler) Fatal Uses

func (h *MethodHandler) Fatal(err error)

Fatal logs an error and exits immediately

func (*MethodHandler) Handles Uses

func (h *MethodHandler) Handles() (handles bool)

Handles returns true if it's Handler handles a service

func (*MethodHandler) Logln Uses

func (h *MethodHandler) Logln(values ...interface{})

func (*MethodHandler) MonitorConn Uses

func (h *MethodHandler) MonitorConn(conn net.Conn) net.Conn

MonitorConn waps a net.Conn for transport usage statistics

func (*MethodHandler) MonitorListener Uses

func (h *MethodHandler) MonitorListener(listener net.Listener) net.Listener

MonitorListener wraps a net.Listener for transport usage statistics

func (*MethodHandler) PrintDone Uses

func (h *MethodHandler) PrintDone()

Echo DONE to client.

This means initiation was successful.

func (*MethodHandler) PrintError Uses

func (h *MethodHandler) PrintError(text string) error

Echo ERROR to the client.

This means the initiation process should abort. func (h *MethodHandler) PrintError(text string) error {

return doError("ERROR", h.method, text)


func (*MethodHandler) PrintExpose Uses

func (h *MethodHandler) PrintExpose(protocol, addr string)

Echo EXPOSE to the client.

This means that the service has exposed a Method requested by the configuration.

func (*MethodHandler) PrintParent Uses

func (h *MethodHandler) PrintParent(proto, addr string)

Echo PARENT to the client.

This means the server has successfully configured itself for connecting thru a parent proxy.

func (*MethodHandler) PrintVersion Uses

func (h *MethodHandler) PrintVersion() error

Start the server initiation

func (*MethodHandler) TrackCloseConn Uses

func (h *MethodHandler) TrackCloseConn(addr string)

TrackCloseConn is to be called after a connection opened and registered with TrackOpenConn is closed again.

func (*MethodHandler) TrackOpenConn Uses

func (h *MethodHandler) TrackOpenConn(addr string)

TrackOpenedConn is to be called when the the transport is used to open a specific address

func (*MethodHandler) Wait Uses

func (h *MethodHandler) Wait()

Wait waits until stdin is closed which is when the transport should terminate

type Option Uses

type Option struct {
    // contains filtered or unexported fields

Option represents an environment variable and is used for parsing and validating the server input.

func NewOption Uses

func NewOption(name string) *Option

func (*Option) BindAddr Uses

func (o *Option) BindAddr() (addr string)

Return argument or replaced by an default netaddr if not set

func (*Option) Default Uses

func (o *Option) Default(value string)

Set default value to be returned by Option.Get() if there is no actual value in the environment variables.

func (*Option) EnvName Uses

func (o *Option) EnvName() string

Returns the option's environment variable name.

func (*Option) Get Uses

func (o *Option) Get() (value string)

Get the value or default value if a default is set.

func (*Option) Has Uses

func (o *Option) Has() (exists bool)

Check if the current environment has this option set.

func (*Option) Is Uses

func (o *Option) Is(value string) (is bool)

Check if the current environment has this option set.

func (*Option) Required Uses

func (o *Option) Required() (err error)

Returns an error if the the variable is not set in the environment.

type Parser Uses

type Parser interface {
    Parse() (Starter, error)

Parse the environment and emit errors if misconfiguration is detected

type Service Uses

type Service struct {
    Name string

type Starter Uses

type Starter interface {
    Start() error // should probably return a channel or similar

Start the service

Package server imports 17 packages (graph) and is imported by 6 packages. Updated 2016-07-24. Refresh now. Tools for package owners.