Documentation ¶
Index ¶
- Constants
- func Run(runner Runner, conditionRunner Runner, commandChecker Checker, ...) error
- func RunWithTestChan(runner Runner, conditionRunner Runner, commandChecker Checker, ...) error
- func SetBasePath(newPath string)
- func WriteBPMscript() error
- type Checker
- type CmdRun
- type Command
- type CommandChecker
- type ConditionRunner
- type ContainerProcess
- type ContainerRunner
- type ExecCommandContext
- type ListenPacketFunc
- type NetPacketListener
- type OSProcess
- type PacketConnection
- type PacketListener
- type Process
- type ProcessRegistry
- func (pr *ProcessRegistry) Count() int
- func (pr *ProcessRegistry) HandleSignals(sigs <-chan os.Signal, sigterm chan<- struct{}, errors chan<- error)
- func (pr *ProcessRegistry) KillAll()
- func (pr *ProcessRegistry) Register(p Process) int
- func (pr *ProcessRegistry) SignalAll(sig os.Signal) []error
- func (pr *ProcessRegistry) Unregister(p Process) int
- type Runner
- type Stdio
Constants ¶
const ( // ProcessStart is the command to restart the suspended child processes. ProcessStart = "START" // ProcessStop is the command to stop and suspend the child processes. ProcessStop = "STOP" // SignalQuit is the command to send a QUIT signal to the child processes. SignalQuit = "QUIT" )
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run( runner Runner, conditionRunner Runner, commandChecker Checker, listener PacketListener, stdio Stdio, args []string, jobName string, processName string, postStartCommandName string, postStartCommandArgs []string, postStartConditionCommandName string, postStartConditionCommandArgs []string, ) error
func RunWithTestChan ¶ added in v0.0.2
func RunWithTestChan( runner Runner, conditionRunner Runner, commandChecker Checker, listener PacketListener, stdio Stdio, args []string, jobName string, processName string, postStartCommandName string, postStartCommandArgs []string, postStartConditionCommandName string, postStartConditionCommandArgs []string, testSigTermChan chan struct{}, ) error
Run implements the logic for the container-run CLI command.
func SetBasePath ¶ added in v0.0.3
func SetBasePath(newPath string)
func WriteBPMscript ¶ added in v0.0.2
func WriteBPMscript() error
WriteBPMscript creates a bpm script for drain script compatibility.
Types ¶
type CmdRun ¶
type CmdRun func( runner Runner, conditionRunner Runner, commandChecker Checker, listener PacketListener, stdio Stdio, args []string, jobName string, processName string, postStartCommandName string, postStartCommandArgs []string, postStartConditionCommandName string, postStartConditionCommandArgs []string, ) error
CmdRun represents the signature for the top-level Run command.
type CommandChecker ¶
type CommandChecker struct {
// contains filtered or unexported fields
}
CommandChecker satisfies the Checker interface.
func NewCommandChecker ¶
func NewCommandChecker( osStat func(string) (os.FileInfo, error), execLookPath func(file string) (string, error), ) *CommandChecker
NewCommandChecker constructs a new CommandChecker.
func (*CommandChecker) Check ¶
func (cc *CommandChecker) Check(command string) bool
Check checks if command exists as a file or in $PATH.
type ConditionRunner ¶
type ConditionRunner struct {
// contains filtered or unexported fields
}
ConditionRunner satisfies the Runner interface. It represents a runner for a post-start pre-condition.
func NewConditionRunner ¶
func NewConditionRunner( sleep func(time.Duration), execCommandContext func(context.Context, string, ...string) *exec.Cmd, ) *ConditionRunner
NewConditionRunner constructs a new ConditionRunner.
func (*ConditionRunner) Run ¶
func (cr *ConditionRunner) Run( command Command, stdio Stdio, ) (Process, error)
Run is not implemented.
func (*ConditionRunner) RunContext ¶
func (cr *ConditionRunner) RunContext( ctx context.Context, command Command, _ Stdio, ) (Process, error)
RunContext runs a condition until it succeeds or the context times out. The process is never returned. A context timeout makes RunContext to return the error.
type ContainerProcess ¶
type ContainerProcess struct {
// contains filtered or unexported fields
}
ContainerProcess satisfies the Process interface.
func NewContainerProcess ¶
func NewContainerProcess(process OSProcess, pid int) *ContainerProcess
NewContainerProcess constructs a new ContainerProcess.
func (*ContainerProcess) Pid ¶ added in v0.0.3
func (p *ContainerProcess) Pid() int
type ContainerRunner ¶
type ContainerRunner struct { }
ContainerRunner satisfies the Runner interface.
func NewContainerRunner ¶
func NewContainerRunner() *ContainerRunner
NewContainerRunner constructs a new ContainerRunner.
func (*ContainerRunner) Run ¶
func (cr *ContainerRunner) Run( command Command, stdio Stdio, ) (Process, error)
Run runs a command async.
func (*ContainerRunner) RunContext ¶
func (cr *ContainerRunner) RunContext( ctx context.Context, command Command, stdio Stdio, ) (Process, error)
RunContext runs a command async with a context.
type ExecCommandContext ¶
type ExecCommandContext interface {
CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd
}
ExecCommandContext wraps exec.CommandContext.
type ListenPacketFunc ¶
type ListenPacketFunc func(network, address string) (net.PacketConn, error)
ListenPacketFunc is a type alias to the net.ListenPacket function.
type NetPacketListener ¶
type NetPacketListener struct {
// contains filtered or unexported fields
}
NetPacketListener satisfies the PacketListener interface.
func NewNetPacketListener ¶
func NewNetPacketListener(listen ListenPacketFunc) *NetPacketListener
NewNetPacketListener constructs a new NetPacketListener.
func (*NetPacketListener) ListenPacket ¶
func (npl *NetPacketListener) ListenPacket(network, address string) (PacketConnection, error)
ListenPacket implements listening for packets.
type PacketConnection ¶
type PacketConnection interface { ReadFrom(p []byte) (n int, addr net.Addr, err error) Close() error }
PacketConnection is the interface that wraps the PacketConn methods.
type PacketListener ¶
type PacketListener interface {
ListenPacket(network, address string) (PacketConnection, error)
}
PacketListener is the interface that wraps the ListenPacket methods. net.PacketConn satisfies this interface.
type ProcessRegistry ¶
ProcessRegistry handles all the processes.
func NewProcessRegistry ¶
func NewProcessRegistry() *ProcessRegistry
NewProcessRegistry constructs a new ProcessRegistry.
func (*ProcessRegistry) Count ¶ added in v0.0.2
func (pr *ProcessRegistry) Count() int
Count returns the number of processes in the registry
func (*ProcessRegistry) HandleSignals ¶
func (pr *ProcessRegistry) HandleSignals(sigs <-chan os.Signal, sigterm chan<- struct{}, errors chan<- error)
HandleSignals handles the signals channel and forwards them to the registered processes. After a signal is handled it keeps running to handle any future ones.
func (*ProcessRegistry) KillAll ¶ added in v0.0.2
func (pr *ProcessRegistry) KillAll()
KillAll stops the timer and sends a kill signal to all registered processes.
func (*ProcessRegistry) Register ¶
func (pr *ProcessRegistry) Register(p Process) int
Register registers a process in the registry and returns how many processes are registered.
func (*ProcessRegistry) SignalAll ¶
func (pr *ProcessRegistry) SignalAll(sig os.Signal) []error
SignalAll sends a signal to all registered processes.
func (*ProcessRegistry) Unregister ¶ added in v0.0.2
func (pr *ProcessRegistry) Unregister(p Process) int
Unregister removes a process from the registry and returns how many processes are still registered.