Documentation ¶
Index ¶
- Constants
- Variables
- func GetProcessFactory(cmd *core.Command) process.ProcessFactory
- func RegisterCmd(cmd string, exe string, workdir string, cmdargs []string, ...)
- func UnregisterCmd(cmd string)
- type DelayHook
- type ExitHook
- type MatchHook
- type MessageHandler
- type MeterHandler
- type NOOPHook
- type PIDHook
- type PM
- func (pm *PM) AddMessageHandler(handler MessageHandler)
- func (pm *PM) AddResultHandler(handler ResultHandler)
- func (pm *PM) AddRouteResultHandler(route core.Route, handler ResultHandler)
- func (pm *PM) AddStatsHandler(handler StatsHandler)
- func (pm *PM) Aggregate(op, key string, value float64, tags string)
- func (pm *PM) Kill(cmdID string) error
- func (pm *PM) Killall()
- func (pm *PM) NewRunner(cmd *core.Command, factory process.ProcessFactory, hooks ...RunnerHook) (Runner, error)
- func (pm *PM) PushCmd(cmd *core.Command)
- func (pm *PM) PushCmdToQueue(cmd *core.Command)
- func (pm *PM) Register(g process.GetPID) error
- func (pm *PM) Run()
- func (pm *PM) RunCmd(cmd *core.Command, hooks ...RunnerHook) (Runner, error)
- func (pm *PM) RunSlice(slice settings.StartupSlice)
- func (pm *PM) Runners() map[string]Runner
- func (pm *PM) WaitPID(pid int) syscall.WaitStatus
- type ResultHandler
- type Runner
- type RunnerHook
- type StateMachine
- type StatsHandler
Constants ¶
const ( AggreagteAverage = "A" AggreagteDifference = "D" )
const (
StreamBufferSize = 1000
)
Variables ¶
var ( UnknownCommandErr = errors.New("unkonw command") DuplicateIDErr = errors.New("duplicate job id") )
var CmdMap = map[string]process.ProcessFactory{ process.CommandSystem: process.NewSystemProcess, }
Global command ProcessConstructor registery
Functions ¶
func GetProcessFactory ¶
func GetProcessFactory(cmd *core.Command) process.ProcessFactory
NewProcess creates a new process from a command
func RegisterCmd ¶
RegisterCmd registers a new command (extension) so it can be executed via commands
func UnregisterCmd ¶
func UnregisterCmd(cmd string)
UnregisterCmd removes an extension from the global registery
Types ¶
type DelayHook ¶
type MatchHook ¶
type MeterHandler ¶
MeterHandler represents a callback type
type PM ¶
type PM struct {
// contains filtered or unexported fields
}
PM is the main process manager.
func GetManager ¶
func GetManager() *PM
TODO: That's not clean, find another way to make this available for other code
func (*PM) AddMessageHandler ¶
func (pm *PM) AddMessageHandler(handler MessageHandler)
AddMessageHandler adds handlers for messages that are captured from sub processes. Logger can use this to process messages
func (*PM) AddResultHandler ¶
func (pm *PM) AddResultHandler(handler ResultHandler)
AddResultHandler adds a handler that receives job results.
func (*PM) AddRouteResultHandler ¶
func (pm *PM) AddRouteResultHandler(route core.Route, handler ResultHandler)
func (*PM) AddStatsHandler ¶ added in v0.11.0
func (pm *PM) AddStatsHandler(handler StatsHandler)
AddStatsFlushHandler adds handler to stats flush.
func (*PM) NewRunner ¶
func (pm *PM) NewRunner(cmd *core.Command, factory process.ProcessFactory, hooks ...RunnerHook) (Runner, error)
func (*PM) PushCmdToQueue ¶
RunCmdQueued Same as RunCmdAsync put will queue the command for later execution when there are no other commands runs on the same queue.
The queue name is retrieved from cmd.Args[queue]
func (*PM) RunSlice ¶
func (pm *PM) RunSlice(slice settings.StartupSlice)
RunSlice runs a slice of processes honoring dependencies. It won't just start in order, but will also make sure a service won't start until it's dependencies are running.
type ResultHandler ¶
ResultHandler represents a callback type
type Runner ¶
type Runner interface { Command() *core.Command Run() Terminate() Process() process.Process Wait() *core.JobResult StartTime() int64 }
func NewRunner ¶
func NewRunner(manager *PM, command *core.Command, factory process.ProcessFactory, hooks ...RunnerHook) Runner
NewRunner creates a new runner object that is bind to this PM instance.
:manager: Bind this runner to this PM instance :command: Command to run :factory: Process factory associated with command type. :hooksDelay: Fire the hooks after this delay in seconds if the process is still running. Basically it's a delay for if the
command didn't exit by then we assume it's running successfully values are: - 1 means hooks are only called when the command exits 0 means use default delay (default is 2 seconds) > 0 Use that delay
:hooks: Optionals hooks that are called if the process is considered RUNNING successfully.
The process is considered running, if it ran with no errors for 2 seconds, or exited before the 2 seconds passes with SUCCESS exit code.
type RunnerHook ¶
type StateMachine ¶
type StateMachine interface { Wait(key ...string) bool WaitAll() Release(ket string, state bool) error }
func NewStateMachine ¶
func NewStateMachine(keys ...string) StateMachine