Documentation ¶
Index ¶
- func NewLogger(w io.Writer, debug bool) *zap.Logger
- func TestNewServerAndClient(t TestReporter, w io.Writer) (server *Server, client *Client, executor *TestExecutor, done func())
- func Validate(pp []Process) error
- type Client
- type Environment
- type Executor
- type Process
- type ProcessInfo
- type Proxfile
- type ProxfileProcess
- type Server
- type StructuredOutput
- type TaggingRule
- type TestExecutor
- type TestProcess
- func (p *TestProcess) Fail()
- func (p *TestProcess) Finish()
- func (p *TestProcess) FinishInterrupt()
- func (p *TestProcess) HasBeenInterrupted() bool
- func (p *TestProcess) HasBeenStarted() bool
- func (p *TestProcess) Info() ProcessInfo
- func (p *TestProcess) Name() string
- func (p *TestProcess) Run(ctx context.Context) error
- func (p *TestProcess) ShouldBlockOnInterrupt()
- func (p *TestProcess) ShouldSay(t TestReporter, msg string)
- func (p *TestProcess) String() string
- type TestReporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger creates a *zap.Logger that emits its log messages through the given io.Writer. If debug is true the log level will also include debug and info messages. Otherwise only warning and errors will be logged.
func TestNewServerAndClient ¶
func TestNewServerAndClient(t TestReporter, w io.Writer) (server *Server, client *Client, executor *TestExecutor, done func())
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client connects to a Server via a unix socket to provide access to a running prox server.
func NewClient ¶
NewClient creates a new prox Client and immediately connects it to a prox Server via a unix socket. It is the callers responsibility to eventually close the client to release the underlying socket connection.
func (*Client) List ¶
List fetches a list of running processes from the server and prints it via the given output.
type Environment ¶
Environment is a set of key value pairs that are used to set environment variables for processes.
func NewEnv ¶
func NewEnv(values []string) Environment
NewEnv creates a new Environment and immediately sets all given key=value pairs.
func SystemEnv ¶
func SystemEnv() Environment
SystemEnv creates a new Environment from the operating systems environment variables.
func (Environment) Expand ¶
func (e Environment) Expand(input string) string
Expand replaces ${var} or $var in the input string with the corresponding values of e. If the variable is not found in e then an empty string is returned.
func (Environment) Get ¶ added in v0.3.0
func (e Environment) Get(key, defaultValue string) string
Get retrieves the key from the Environment or returns the given default value if that key was not set
func (Environment) List ¶
func (e Environment) List() []string
List returns all variables of e as a list of key=value pairs.
func (Environment) ParseEnvFile ¶
func (e Environment) ParseEnvFile(r io.Reader) error
ParseEnvFile reads environment variables that should be set on all processes from the ".env" file.
The format of the ".env" file is expected to be a newline separated list of key=value pairs which represent the environment variables that should be used by all started processes. Trimmed lines which are empty or start with a "#" are ignored and can be used to add comments.
All values are expanded using the Environment. Additionally values in the env file can use other values which have been defined in earlier lines above. If a value refers to an unknown variable then it is replaced with the empty string.
func (Environment) Set ¶
func (e Environment) Set(s string)
Set splits the input string at the first "=" character (if any) and sets the resulting key and value on e.
func (Environment) SetAll ¶
func (e Environment) SetAll(vars []string)
SetAll assigns a list of key=value pairs on e.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
An Executor manages a set of processes. It is responsible for running them concurrently and waits until they have finished or an error occurs.
func NewExecutor ¶
NewExecutor creates a new Executor. The debug flag controls whether debug logging should be activated. If debug is false then only warnings and errors will be logged.
func (*Executor) DisableColoredOutput ¶
func (e *Executor) DisableColoredOutput()
DisableColoredOutput disables colored prefixes in the output.
func (*Executor) Info ¶
func (e *Executor) Info(processName string) ProcessInfo
Info returns information about a running process. If there is no such process running process a ProcessInfo with a PID of -1 is returned.
type Process ¶
type Process struct { Name string Script string Env Environment Output StructuredOutput // optional }
Process holds all information about a process that is executed by prox.
func ParseProcFile ¶
func ParseProcFile(reader io.Reader, env Environment) ([]Process, error)
ParseProcFile parses a Procfile from the given reader and returns the corresponding set of Processes, each configured with the given Environment.
A Procfile defines one process per line. TODO: write more about the format TODO: comments and empty lines
func ParseProxFile ¶
func ParseProxFile(reader io.Reader, env Environment) ([]Process, error)
func (Process) CommandLine ¶
CommandLine returns the shell command line that would be executed when the given Process is started.
type ProcessInfo ¶
ProcessInfo contains information about a running process.
type Proxfile ¶
type Proxfile struct { Version string Processes map[string]ProxfileProcess }
type ProxfileProcess ¶
type ProxfileProcess struct { Script string Env []string Format string // e.g. json Fields struct { Message string Level string } Tags map[string]struct { Color string Condition struct { Field string Value string } } }
func (*ProxfileProcess) UnmarshalYAML ¶
func (p *ProxfileProcess) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the gopkg.in/yaml.v2.Unmarshaler interface.
type Server ¶
type Server struct { *Executor // contains filtered or unexported fields }
A Server wraps an Executor to expose its functionality via a unix socket.
func NewExecutorServer ¶
NewExecutorServer creates a new Server. This function does not start the Executor nor does it listen on the unix socket just yet. To start the Server and Executor the Server.Run(…) function must be used.
type StructuredOutput ¶ added in v0.2.0
type StructuredOutput struct { Format string // e.g. "json", the zero value makes prox auto-detect the format MessageField string LevelField string TaggingRules []TaggingRule TagColors map[string]string }
StructuredOutput contains all configuration to setup advanced functionality for structured logs.
func DefaultStructuredOutput ¶ added in v0.2.0
func DefaultStructuredOutput(env Environment) StructuredOutput
DefaultStructuredOutput returns the default configuration for processes that do not specify structured log output specifically.
type TaggingRule ¶
type TaggingRule struct { Field string Value string // either a concrete string or a regex like so: "/error|fatal/i" Tag string }
A TaggingRule may be applied to a structured log message to tag it. These tags can then later be used to change the log lines appearance or to modify its content.
type TestExecutor ¶
func TestNewExecutor ¶
func TestNewExecutor(w io.Writer) *TestExecutor
func (*TestExecutor) IsDone ¶
func (e *TestExecutor) IsDone() bool
func (*TestExecutor) Run ¶
func (e *TestExecutor) Run(processes ...*TestProcess)
func (*TestExecutor) Stop ¶
func (e *TestExecutor) Stop()
type TestProcess ¶
func (*TestProcess) Fail ¶
func (p *TestProcess) Fail()
func (*TestProcess) Finish ¶
func (p *TestProcess) Finish()
func (*TestProcess) FinishInterrupt ¶
func (p *TestProcess) FinishInterrupt()
func (*TestProcess) HasBeenInterrupted ¶
func (p *TestProcess) HasBeenInterrupted() bool
func (*TestProcess) HasBeenStarted ¶
func (p *TestProcess) HasBeenStarted() bool
func (*TestProcess) Info ¶
func (p *TestProcess) Info() ProcessInfo
func (*TestProcess) Name ¶
func (p *TestProcess) Name() string
func (*TestProcess) ShouldBlockOnInterrupt ¶
func (p *TestProcess) ShouldBlockOnInterrupt()
func (*TestProcess) ShouldSay ¶
func (p *TestProcess) ShouldSay(t TestReporter, msg string)
func (*TestProcess) String ¶
func (p *TestProcess) String() string
type TestReporter ¶
type TestReporter interface { Log(args ...interface{}) Fatal(args ...interface{}) }