pool

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoggerStream

func NewLoggerStream(logger LogInterface, prefix string) io.WriteCloser

func ParseEnvironmentFile added in v0.1.14

func ParseEnvironmentFile(fileName string) (map[string]string, error)

func ParseEnvironmentStream added in v0.1.14

func ParseEnvironmentStream(stream io.Reader) map[string]string

Environment variables file format: pair: KEY=VALUE comment: line started with # empty lines or invalid (without = symbol) ignored there is no way to escape new line symbol

Types

type EventHandler

type EventHandler interface {
	OnSpawned(ctx context.Context, in Instance)
	OnStarted(ctx context.Context, in Instance)
	OnStopped(ctx context.Context, in Instance, err error)
	OnFinished(ctx context.Context, in Instance)
}

type Executable

type Executable struct {
	Name           string            `yaml:"label,omitempty"`         // Human-readable label for process. If not set - command used
	Command        string            `yaml:"command"`                 // Executable
	Args           []string          `yaml:"args,omitempty"`          // Arguments to command
	Environment    map[string]string `yaml:"environment,omitempty"`   // Additional environment variables
	EnvFiles       []string          `yaml:"envFiles"`                // Additional environment variables from files (not found files ignored). Format key=value
	WorkDir        string            `yaml:"workdir,omitempty"`       // Working directory. If not set - current dir used
	StopTimeout    time.Duration     `yaml:"stop_timeout,omitempty"`  // Timeout before terminate process
	RestartTimeout time.Duration     `yaml:"restart_delay,omitempty"` // Restart delay
	Restart        int               `yaml:"restart,omitempty"`       // How much restart allowed. -1 infinite
	LogFile        string            `yaml:"logFile,omitempty"`       // if empty - only to log. If not absolute - relative to workdir
	RawOutput      bool              `yaml:"raw,omitempty"`           // print stdout as-is without prefixes
	// contains filtered or unexported fields
}

Executable - basic information about process.

func (*Executable) Arg

func (b *Executable) Arg(arg string) *Executable

Arg adds additional positional argument

func (*Executable) Config

func (exe *Executable) Config() *Executable

func (*Executable) Env

func (b *Executable) Env(arg, value string) *Executable

Env adds additional environment key-value pair

func (*Executable) Start

func (exe *Executable) Start(ctx context.Context, pool *Pool) Instance

func (*Executable) WithName

func (b *Executable) WithName(name string) *Executable

type Instance

type Instance interface {
	Stop()
	Config() *Executable
	Supervisor() Supervisor
	Pool() *Pool
}

type LogInterface

type LogInterface interface {
	Println(v ...interface{})
}

type Pool

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

func (*Pool) Add

func (p *Pool) Add(sv Supervisor)

func (*Pool) Done

func (p *Pool) Done() <-chan struct{}

func (*Pool) Instances

func (p *Pool) Instances() []Instance

func (*Pool) OnFinished

func (p *Pool) OnFinished(ctx context.Context, sv Instance)

func (*Pool) OnSpawned

func (p *Pool) OnSpawned(ctx context.Context, sv Instance)

func (*Pool) OnStarted

func (p *Pool) OnStarted(ctx context.Context, sv Instance)

func (*Pool) OnStopped

func (p *Pool) OnStopped(ctx context.Context, sv Instance, err error)

func (*Pool) Start

func (p *Pool) Start(ctx context.Context, sv Supervisor) Instance

func (*Pool) StartAll

func (p *Pool) StartAll(ctx context.Context)

func (*Pool) Stop

func (p *Pool) Stop(in Instance)

func (*Pool) StopAll

func (p *Pool) StopAll()

func (*Pool) Supervisors

func (p *Pool) Supervisors() []Supervisor

func (*Pool) Terminate

func (p *Pool) Terminate()

func (*Pool) Watch

func (p *Pool) Watch(handler EventHandler)

type Supervisor

type Supervisor interface {
	Start(ctx context.Context, pool *Pool) Instance
	Config() *Executable
}

Jump to

Keyboard shortcuts

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