alkasir: Index | Files | Directories

package service

import ""

Service client api

The service manager is responsiblities are knowing (by name) which services exists, configure them using environment variables, launch them, read status by standard out and then


Package Files

common.go connectionmanager.go connectionstate_string.go misc.go service.go


var Arg = ""

Arg is currently only used for testing to specify which test is run.

var DefaultProxyBindAddr = ""
var ManagedServices = Services{
    items: make(map[string]*Service, 0),

ManagedServices is the central list of running services

func AddListener Uses

func AddListener(c chan ConnectionHistory)

func NewTransportHTTPClient Uses

func NewTransportHTTPClient(timeout time.Duration) (*http.Client, error)

NewTransportHTTPClient returns a http client of the default transport

func StartConnectionManager Uses

func StartConnectionManager(authKey string)

func StopAll Uses

func StopAll()

StopAll stops all services, blocks until everything is shut down.

func StopConnectionManager Uses

func StopConnectionManager()

func TransportOk Uses

func TransportOk() bool

func UpdateConnections Uses

func UpdateConnections(connections []shared.Connection)

func UpdateTransports Uses

func UpdateTransports(transports map[string]shared.Transport)

type BrowserProtocols Uses

type BrowserProtocols int
const (
    SOCKS5 BrowserProtocols = 1 << iota

These are the (currently) allowed protocols metods that are exposed to the end user web browser/os.

func (BrowserProtocols) String Uses

func (b BrowserProtocols) String() string

Returns a string representation of the constant.

type ConnectionEvent Uses

type ConnectionEvent struct {
    State      ConnectionState   // Current state
    Time       time.Time         // Timestamp of the event
    Connection shared.Connection // Associated saved connection
    ServiceID  string            // Service instance id

ConnectionEvent describes the current state of a transport connection.

type ConnectionHistory Uses

type ConnectionHistory struct {
    History []ConnectionEvent // All previous connectionevents from this connection

func (*ConnectionHistory) Current Uses

func (c *ConnectionHistory) Current() ConnectionEvent

Current returns the current state from the connection history

func (ConnectionHistory) IsUp Uses

func (c ConnectionHistory) IsUp() bool

Down returns true if the connection is known to be not up.

type ConnectionState Uses

type ConnectionState int

ConnectionState describes the current known state of the default transport.

const (
    Init ConnectionState = iota // Initial state
    // Service stages
    ServiceInit  //  Service initializing
    ServiceStart // The transport service is starting
    Test         // Waiting for respone from test during start up

    // everything is fine
    Up  // Connected and tested

    // Problems
    Backoff // Backoff because of multiple failed attepmts at using this connection

    // Errors
    WrongProtocol // The expected protocol was not found
    Failed        // One of the previous steps failed
    NotConfigured // No transport has been set up
    TestFailed    // A network test failed
    Ended         // Nothing more can happen

go:generate stringer -type=ConnectionState TODO: Split STATES and ACTIONS

func (ConnectionState) String Uses

func (i ConnectionState) String() string

type Dialer Uses

type Dialer func(network, addr string) (net.Conn, error)

type Method Uses

type Method struct {
    ID       string   // instance id
    Name     string   // method name
    Service  *Service // the owning service
    BindAddr string   // exposed network address
    Protocol string   // exposed exposed protocol

Method holds the runtime configuration of one of

type Methods Uses

type Methods struct {
    // contains filtered or unexported fields

Methods manages a list of methods

func (*Methods) All Uses

func (m *Methods) All() []*Method

All returns all medthods added to current list

type Service Uses

type Service struct {
    ID   string // instance id
    Name string // service name

    Command  string              // command name to launch serice
    Request  map[string](string) // initial input
    Response map[string](string) // initial output
    Methods  *Methods            // methods exposed in Response
    // contains filtered or unexported fields

Service is the central data structure for service client and manager.

func NewService Uses

func NewService(name string) (s *Service)

Create a new service instance. note: name is not yet a decided requirement.

func (*Service) Remove Uses

func (s *Service) Remove() error

Remove the service from the list of manages services, if the service is running it will be stopped first.

func (*Service) Running Uses

func (s *Service) Running() bool

Returns true if the service currently is running.

func (*Service) SetVar Uses

func (s *Service) SetVar(key, value string)

Set a variable in the request context.

func (*Service) Start Uses

func (s *Service) Start() (err error)

Start the service. Currently, this function does validation as well which might need to be reconsidered.

func (*Service) Stop Uses

func (s *Service) Stop()

Stop the service

type Services Uses

type Services struct {
    sync.RWMutex // the mutex
    // contains filtered or unexported fields

A list of services to manage and monitor running services

func (*Services) AllMethods Uses

func (s *Services) AllMethods() []*Method

func (*Services) AllServices Uses

func (s *Services) AllServices() []*Service

Return list of all registered services

func (*Services) Method Uses

func (s *Services) Method(id string) *Method

func (*Services) Service Uses

func (s *Services) Service(id string) (*Service, bool)

Retreive Service by runtime id

type TransportService Uses

type TransportService struct {
    *Service // the related service
    // contains filtered or unexported fields

TransportService adds some features on top of the plain services.

func NewTransportService Uses

func NewTransportService(connection shared.Connection) (transportService *TransportService, err error)

create new transport service from connection details data

func (*TransportService) Dial Uses

func (t *TransportService) Dial() Dialer

Dial returns a

func (*TransportService) HTTPClient Uses

func (t *TransportService) HTTPClient() *http.Client

func (*TransportService) SetBindaddr Uses

func (s *TransportService) SetBindaddr(bindaddr string) error

SetBindAddr sets the net address which the transport service should bind to locally.

func (*TransportService) SetParent Uses

func (s *TransportService) SetParent(parent *TransportService) error

let the transport

func (*TransportService) SetVerbose Uses

func (s *TransportService) SetVerbose() error

set the net address that the transport service should bind to locally


serverEntrypoint for running as a service.

Package service imports 18 packages (graph) and is imported by 2 packages. Updated 2016-09-22. Refresh now. Tools for package owners.