control

package
v0.0.0-...-f4dfc87 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIGet

type APIGet struct {
	Config     Config `json:"config"`
	ConfigText string `json:"config_text"`

	Clients []ClientStatus `json:"clients"`
	Workers []WorkerStatus `json:"workers"`
}

type Client

type Client struct {
	Config   *ClientConfig
	Instance string
	// contains filtered or unexported fields
}

func (*Client) GetStatus

func (client *Client) GetStatus(dockerCache *docker.Cache) (ClientStatus, error)

func (Client) String

func (self Client) String() string

type ClientConfig

type ClientConfig struct {
	Count uint

	Image      string
	Privileged bool

	Volume         string
	VolumePath     string
	VolumeFmtID    string
	VolumeReadonly bool
	// contains filtered or unexported fields
}

func (ClientConfig) String

func (self ClientConfig) String() string

type ClientState

type ClientState string
var ClientDown ClientState = "down"
var ClientError ClientState = "error"
var ClientUp ClientState = "up"

type ClientStatus

type ClientStatus struct {
	Config   string `json:"config"`
	Instance string `json:"instance"`

	Docker       string `json:"docker"`
	DockerStatus string `json:"docker_status"`
	DockerNode   string `json:"docker_node"`

	Up    bool        `json:"up"`
	State ClientState `json:"state"`
}

type Config

type Config struct {
	Clients map[string]*ClientConfig
	Workers map[string]*WorkerConfig
}

full-system configuration

type ConfigItem

type ConfigItem struct {
	config.ID

	TTL float64 `json:"ttl"` // seconds
}

type JsonApp

type JsonApp interface {
	RestApp() (rest.App, error)
}

type Manager

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

func New

func New(options Options) (*Manager, error)

func (*Manager) Clean

func (self *Manager) Clean() (errs []error)

Clean unused workers

func (*Manager) ClientClean

func (self *Manager) ClientClean() (errs []error)

Cleanup down'd clients

func (*Manager) ClientDelete

func (self *Manager) ClientDelete(configName string, instance string) error

func (*Manager) ClientDown

func (self *Manager) ClientDown(config *ClientConfig) (errs []error)

Stop running clients clients for given config

Call with config=nil to stop all clients

func (*Manager) ClientUp

func (self *Manager) ClientUp(config *ClientConfig) (errs []error)

Start up all configured clients

func (*Manager) ConfigGet

func (self *Manager) ConfigGet(id config.ID) (config.Config, error)

func (*Manager) ConfigList

func (self *Manager) ConfigList(filter config.ID) (configs []ConfigItem, err error)

func (*Manager) ConfigPush

func (self *Manager) ConfigPush(id config.ID, pushConfig config.Config) error

func (*Manager) Discover

func (self *Manager) Discover() (err error)

Discover any existing running docker containers before initial Start() Must be run after loadConfig() to recognize any containers.. Allows Start() to re-use existing containers, and cleanup undesired containers

func (*Manager) DumpConfig

func (self *Manager) DumpConfig() (string, error)

Get running configuration

func (*Manager) GetClient

func (self *Manager) GetClient(config string, instance string) (*Client, error)

func (*Manager) ListClients

func (self *Manager) ListClients() (clients []ClientStatus, err error)

func (*Manager) ListWorkers

func (self *Manager) ListWorkers() (workers []WorkerStatus, err error)

func (*Manager) LoadConfigFile

func (self *Manager) LoadConfigFile(filePath string) error

func (*Manager) LoadConfigReader

func (self *Manager) LoadConfigReader(reader io.Reader) error

func (*Manager) LoadConfigString

func (self *Manager) LoadConfigString(data string) error

func (*Manager) NewAuth

func (m *Manager) NewAuth(filePath string) (*rest.AuthBasicMiddleware, error)

func (*Manager) Panic

func (self *Manager) Panic() error

Kill any running containers and reset state

func (*Manager) RestApp

func (self *Manager) RestApp() (rest.App, error)

func (*Manager) Start

func (self *Manager) Start() (errs []error)

Start new configuration

func (*Manager) Stop

func (self *Manager) Stop() (errs []error)

Stop current configuration

func (*Manager) WorkerClean

func (self *Manager) WorkerClean() (errs []error)

Cleanup down'd workers

func (*Manager) WorkerDelete

func (self *Manager) WorkerDelete(configName string, instance string) error

func (*Manager) WorkerDown

func (self *Manager) WorkerDown(config *WorkerConfig) (errs []error)

Stop running workers for given config

Call with config=nil to stop all workers.

func (*Manager) WorkerGet

func (self *Manager) WorkerGet(configName string, instance string) (*WorkerStatus, error)

func (*Manager) WorkerUp

func (self *Manager) WorkerUp(workerConfig *WorkerConfig) (errs []error)

Setup workers from config

type ManagerAPI

type ManagerAPI interface {
	Start() []error
	Stop() []error
	Clean() []error
	DumpConfig() (string, error)
	ConfigList(config.ID) ([]ConfigItem, error)
	ConfigGet(config.ID) (config.Config, error)
	ConfigPush(config.ID, config.Config) error
	ListClients() ([]ClientStatus, error)
	ListWorkers() ([]WorkerStatus, error)
	WorkerGet(string, string) (*WorkerStatus, error)
	WorkerDelete(string, string) error
	ClientDelete(string, string) error
	LoadConfigReader(io.Reader) error
	Panic() error
}

type Options

type Options struct {
	Stats  stats.ReaderOptions `group:"Stats Reader"`
	Config config.Options      `group:"Config"`
	Docker docker.Options      `group:"Docker"`

	Logger *log.Logger
}

type WebApp

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

func (*WebApp) Delete

func (self *WebApp) Delete(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) DeleteClients

func (self *WebApp) DeleteClients(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) DeleteWorkers

func (self *WebApp) DeleteWorkers(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) Get

func (self *WebApp) Get(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetConfig

func (self *WebApp) GetConfig(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetConfigList

func (self *WebApp) GetConfigList(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetDocker

func (self *WebApp) GetDocker(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetDockerInfo

func (self *WebApp) GetDockerInfo(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetDockerList

func (self *WebApp) GetDockerList(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetDockerLogs

func (self *WebApp) GetDockerLogs(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) GetStats

func (self *WebApp) GetStats(w rest.ResponseWriter, req *rest.Request)
  • Query stats series for data points, for either a given field or all fields. *
  • Each field is returned separately. *
  • This information is temporal, it changes continuously for active series.

[

{
  "type": "udp_send",
  "hostname": "close-client-openvpn-1",
  "instance": "15042208547977655843",
  "field": "rate",
  "points": [
    {
      "time": "2016-01-26T10:01:12.108997292Z",
      "value": 10.00012210149086
    }
  ]
}

]

func (*WebApp) GetStatsList

func (self *WebApp) GetStatsList(w rest.ResponseWriter, req *rest.Request)
  • Query a list of stats series, optionally for a given type (InfluxDB series (tag-sets), for a given measurement). *
  • This information is dynamic, it changes if new workers are started. *
  • TODO: cleanup/hide old series that are no longer active, i.e. expire after some time?

[

{
  "type": "udp_recv",
  "hostname": "catcp-terom-dev",
  "instance": "127.0.0.1:1337"
},

]

func (*WebApp) GetStatsTypes

func (self *WebApp) GetStatsTypes(w rest.ResponseWriter, req *rest.Request)

* Query a list of available stats types (InfluxDB measurements and their fields). * * This information is static, it only changes if the code changes to introduce new types/fields (or old measurememts are dropped). *

[
  {
    "type": "icmp_latency",
    "fields": [
      "rtt"
    ]
  }
]

func (*WebApp) GetWorker

func (self *WebApp) GetWorker(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) Post

func (self *WebApp) Post(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) PostClean

func (self *WebApp) PostClean(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) PostConfig

func (self *WebApp) PostConfig(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) PostPanic

func (self *WebApp) PostPanic(w rest.ResponseWriter, req *rest.Request)

func (*WebApp) PostStop

func (self *WebApp) PostStop(w rest.ResponseWriter, req *rest.Request)

type Worker

type Worker struct {
	Config   *WorkerConfig
	Instance string
	// contains filtered or unexported fields
}

track state of managed workers

func (Worker) String

func (self Worker) String() string

type WorkerConfig

type WorkerConfig struct {
	Count  uint
	Client string // ClientConfig.name

	// Docker
	Constraints []string
	Image       string
	Privileged  bool
	Command     string
	Args        []string

	// worker
	Type         string
	InstanceFlag string

	/*
	 * Stats URL: type [ "/" field ] [ "?" ("instance=" ("$" | "$" configName ) ) [ "&" ... ] ]
	 */
	Stats string

	RateConfig string
	RateStats  string

	LatencyStats string
	// contains filtered or unexported fields
}

func (WorkerConfig) String

func (self WorkerConfig) String() string

type WorkerState

type WorkerState string
var WorkerDown WorkerState = "down" // not running, clean exit
var WorkerError WorkerState = "error" // not running, unclean exit
var WorkerUnknown WorkerState = "unknown" // running, unknown
var WorkerUp WorkerState = "up" // running, ready
var WorkerWait WorkerState = "wait" // running, pending

type WorkerStatus

type WorkerStatus struct {
	Config   string `json:"config"` // WorkerConfig.name
	Instance string `json:"instance"`

	WorkerConfig *WorkerConfig `json:"worker_config,omitempty"` // detail

	Docker          string            `json:"docker"`
	DockerStatus    string            `json:"docker_status"`
	DockerNode      string            `json:"docker_node"`
	DockerContainer *docker.Container `json:"docker_container,omitempty"` // detail

	Up    bool        `json:"up"`
	State WorkerState `json:"state"`

	ConfigInstance string           `json:"config_instance"`
	ConfigError    string           `json:"config_error,omitempty"`
	ConfigTTL      float64          `json:"config_ttl"`           // seconds
	ConfigMap      config.ConfigMap `json:"config_map,omitempty"` // detail

	StatsMeta stats.SeriesKey `json:"stats_meta"`

	RateConfig uint               `json:"rate_config,omitempty"` // config
	RateStats  *stats.SeriesStats `json:"rate_stats,omitempty"`

	LatencyStats *stats.SeriesStats `json:"latency_stats,omitempty"`
}

Jump to

Keyboard shortcuts

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