Documentation
¶
Index ¶
- Variables
- func ActionName(name string) string
- func CheckCronSpec(spec string) error
- func CheckShScript(script string, section string) error
- func CheckSignal(name string) error
- func Cli(opts appkit.Options, argsin []string) ([]string, error)
- func CreateActions(file *ini.File, bus *EventBus) error
- func ErrAnnotate(err error, a ...interface{}) error
- func EscapeName(name string) string
- func GenerateTemplates(opts appkit.Options) error
- func Main(opts appkit.Options) error
- func PrintGoroutines()
- func Templates() map[string]string
- func UnescapeName(name string) string
- func ValidateConfig(filename string) (*ini.File, error)
- type BaseAction
- type BusLink
- type CronAction
- type Deps
- type EventBus
- type FileAction
- type InitAction
- type Message
- type PrefixedWriter
- type RestartAction
- type ShAction
- type SignalAction
- type Terminal
- type TerminalOutput
- type VerboseWriter
- type WaitAction
Constants ¶
This section is empty.
Variables ¶
var ( MsgInit = "init" // Start everything MsgTerm = "terminate" // Stop all processing MsgRest = "restart" // Restart MsgTrig = "trigger" // Make action happen MsgWait = "wait" // Reset status to wait ToAll = "*" ErrMainRestarted = fmt.Errorf("main restarted") )
Common messages
Functions ¶
func ActionName ¶
func CheckCronSpec ¶ added in v0.9.1
func CheckShScript ¶ added in v0.9.3
func CheckSignal ¶ added in v0.9.2
func ErrAnnotate ¶ added in v0.10.0
func EscapeName ¶ added in v0.12.2
func GenerateTemplates ¶
func PrintGoroutines ¶ added in v0.9.3
func PrintGoroutines()
func UnescapeName ¶ added in v0.12.2
Types ¶
type BaseAction ¶
type BaseAction struct {
Visible bool
// contains filtered or unexported fields
}
func (*BaseAction) Identify ¶
func (a *BaseAction) Identify(name string, eb *EventBus)
func (*BaseAction) Send ¶
func (a *BaseAction) Send(to, message string)
func (*BaseAction) Terminal ¶
func (a *BaseAction) Terminal() Terminal
type BusLink ¶
type BusLink interface {
// Receiving messages
Receive(from, message string)
// Sending messages
Send(to, message string)
// Registering the EventBus to the BusLink
Identify(name string, bus *EventBus)
// Start the BusLink specific goroutine
Run()
}
BusLink is the interface for sending messages to the bus
type CronAction ¶ added in v0.9.1
type CronAction struct {
Triggered []string
BaseAction
// contains filtered or unexported fields
}
func NewCronAction ¶ added in v0.9.1
func NewCronAction(spec string) (*CronAction, error)
func (*CronAction) Receive ¶ added in v0.9.1
func (a *CronAction) Receive(_, message string)
func (*CronAction) Run ¶ added in v0.9.1
func (a *CronAction) Run()
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus conveys messages to Listeners
func NewEventBus ¶
func NewEventBus() *EventBus
func (*EventBus) LinkStopped ¶ added in v0.9.1
func (eb *EventBus) LinkStopped()
Action notifies that it has stopped. This is for waiting for all actions when terminating.
type FileAction ¶
type FileAction struct {
Patterns []string
Hysteresis time.Duration
Changed []string
BaseAction
// contains filtered or unexported fields
}
func NewFileAction ¶
func NewFileAction(patterns ...string) (*FileAction, error)
func (*FileAction) Receive ¶
func (a *FileAction) Receive(_, message string)
func (*FileAction) Run ¶ added in v0.9.1
func (a *FileAction) Run()
type InitAction ¶
type InitAction struct {
BaseAction
// contains filtered or unexported fields
}
func NewInitAction ¶
func NewInitAction(triggerName string) *InitAction
func (*InitAction) Receive ¶
func (a *InitAction) Receive(_, message string)
func (*InitAction) Run ¶ added in v0.9.1
func (a *InitAction) Run()
type PrefixedWriter ¶
type PrefixedWriter struct {
Prefix []byte // Prefix to add to each line
Eol []byte // Suffix to add each line
Out io.Writer // Write everything to this writer.
TimeStamp bool // Add timestamps to output
// contains filtered or unexported fields
}
PrefixedWriter is an io.Writer that prefixes and suffixes all lines given to it.
func NewPrefixedWriter ¶
func NewPrefixedWriter(prefix string, out io.Writer) *PrefixedWriter
NewPrefixedWriter create a PrefixedWriter with given prefix and write everything to out.
func (*PrefixedWriter) Write ¶
func (p *PrefixedWriter) Write(buf []byte) (n int, err error)
Write writes given buf with a prefix to the Out writer. Only write lines ending with a newline. If the input data doesn't contain a newline, the data is written to an internal buffer which is flushed the next time data with newline is given.
type RestartAction ¶ added in v0.9.3
type RestartAction struct {
BaseAction
// contains filtered or unexported fields
}
func NewRestartAction ¶ added in v0.9.3
func NewRestartAction(conffile string) *RestartAction
func (*RestartAction) Receive ¶ added in v0.9.3
func (a *RestartAction) Receive(_, message string)
func (*RestartAction) Run ¶ added in v0.9.3
func (a *RestartAction) Run()
type ShAction ¶ added in v0.9.3
type ShAction struct {
Cooldown time.Duration
Timeout time.Duration
Daemon bool
OnChange bool
Succeeded []string
Failed []string
BaseAction
// contains filtered or unexported fields
}
func NewShAction ¶ added in v0.9.3
func (*ShAction) RunCommand ¶ added in v0.9.3
type SignalAction ¶
type SignalAction struct {
Triggered []string
// If this signal should terminate the program
Terminator bool
BaseAction
// contains filtered or unexported fields
}
func NewSignalAction ¶
func NewSignalAction(signame string) (*SignalAction, error)
func (*SignalAction) Receive ¶
func (a *SignalAction) Receive(_, message string)
func (*SignalAction) Run ¶ added in v0.9.1
func (a *SignalAction) Run()
type Terminal ¶
type Terminal interface {
Stderr() io.Writer
Stdout() io.Writer
Verbose() io.Writer
SetStatus(status string, info string)
}
Terminal is the interface for outputting data to a terminal
func GetTerminal ¶
func RegisterTerminal ¶
RegisterTerminal registers an interface to outputting
type TerminalOutput ¶
type TerminalOutput struct {
Width int
Verbose bool
TitleStatus string
ProgTitle string
// contains filtered or unexported fields
}
func NewTerminalOutput ¶
func NewTerminalOutput(opts appkit.Options) *TerminalOutput
func (*TerminalOutput) Ready ¶ added in v0.13.0
func (a *TerminalOutput) Ready() bool
func (*TerminalOutput) Register ¶ added in v0.13.0
func (a *TerminalOutput) Register(t *terminal)
Register a new Terminal to the TerminalOutput
func (*TerminalOutput) Stop ¶
func (a *TerminalOutput) Stop()
Stop TerminalOutput. This cannot be stopped with the MsgTerm message as some other actions can print while they are terminating.
type VerboseWriter ¶
VerboseWriter writes to Out only if Verbose is set.
type WaitAction ¶ added in v0.14.0
type WaitAction struct {
Waiting map[string]bool
Triggered []string
BaseAction
}
func NewWaitAction ¶ added in v0.14.0
func NewWaitAction(waiting []string) (*WaitAction, error)
func (*WaitAction) Receive ¶ added in v0.14.0
func (a *WaitAction) Receive(from, message string)
func (*WaitAction) Run ¶ added in v0.14.0
func (a *WaitAction) Run()