Documentation ¶
Index ¶
- type Action
- type BaseAction
- func (b *BaseAction) After(after time.Duration) *BaseAction
- func (b *BaseAction) At(at time.Time) *BaseAction
- func (b *BaseAction) End()
- func (b *BaseAction) Every(every time.Duration) *BaseAction
- func (b *BaseAction) For(length time.Duration) *BaseAction
- func (b *BaseAction) OnSignal(signals ...os.Signal) *BaseAction
- func (b *BaseAction) Start() error
- func (b *BaseAction) ToFile(f string) *BaseAction
- func (b *BaseAction) ToWriter(w io.Writer) *BaseAction
- func (b *BaseAction) Until(until time.Time) *BaseAction
- type Swat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { // Start should verify conditions, returning an error if // necessary, then start listening asynchronously. Start() error // End should signal the action to stop, and block until it does. End() }
An "action" is the basic unit of Swat. It is started and should listen for events, until End is called.
type BaseAction ¶
type BaseAction struct {
// contains filtered or unexported fields
}
The base action is used to generate all the actions in Swat.
func DumpBlocking ¶
func DumpBlocking() *BaseAction
Returns an action that dumps stack traces that led to blocking on synchronization primitives.
func DumpGoroutine ¶
func DumpGoroutine() *BaseAction
Returns an action that dumps all running goroutines, like you'd get from a panic.
func DumpHeap ¶
func DumpHeap() *BaseAction
Returns an action that dumps a sample of all head allocations.
func DumpPProfLookup ¶
func DumpPProfLookup(name string, debug int) *BaseAction
Returns an action that dumps a pprof lookup, with the given name and debug constant.
func DumpThreadCreate ¶
func DumpThreadCreate() *BaseAction
Returns an action that dumps stack traces that led to the creation of new OS threads.
func NewAction ¶
func NewAction(fn func(io.Writer) error) *BaseAction
Creates and returns a new generic action. Currently there are two ways of triggering actions: by using a Scheduler and/or Signaller.
The Scheduler is activated by calling After, Every, At, For, or Until, and is used for running tasks after durations or on intervals.
The Signaller is activated by calling OnSignal, and will trigger an action to be run when a process gets a POSIX signal.
The output of the action can be sent to a writer. You can specify a writer using ToWriter, and there's a shortcut for specifying a file output using ToFile.
func (*BaseAction) After ¶
func (b *BaseAction) After(after time.Duration) *BaseAction
`After` starts something after a given duration. Cannot be used with `At`. Omitting `After` and `At` cause the scheduler to start the task immediately
func (*BaseAction) At ¶
func (b *BaseAction) At(at time.Time) *BaseAction
`At` starts something at a given time. Cannot be used with `After`. Omitting `After` and `At` cause the scheduler to start the task immediately.
func (*BaseAction) Every ¶
func (b *BaseAction) Every(every time.Duration) *BaseAction
Specifies the time between runs, after the start time (specified by `After` or `At`) has passed. Omitting `Every` causes the action to be run just once.
func (*BaseAction) For ¶
func (b *BaseAction) For(length time.Duration) *BaseAction
`For` specifies how long `Every` runs. annot be used with `Until`. Omitting both `For` and `Every` cause the event to run for an infinite time.
func (*BaseAction) OnSignal ¶
func (b *BaseAction) OnSignal(signals ...os.Signal) *BaseAction
Used to run an action when an OS signal is received.
func (*BaseAction) ToFile ¶
func (b *BaseAction) ToFile(f string) *BaseAction
Writes the output of the action to the writer.
func (*BaseAction) ToWriter ¶
func (b *BaseAction) ToWriter(w io.Writer) *BaseAction
Writes the output of the action to the writer.
func (*BaseAction) Until ¶
func (b *BaseAction) Until(until time.Time) *BaseAction
`Unil` specifies a time at which `Every` stops. Cannot be used with `For`. Omitting both `For` and `Every` cause the event to run for an infinite time.