Documentation ¶
Overview ¶
Package status provides methods for reporting application status.
Index ¶
- func Block(ctx context.Context)
- func Do(ctx context.Context, name string, block func(context.Context))
- func Event(ctx context.Context, scope EventScope, name string, args ...interface{})
- func Finish(ctx context.Context)
- func MemorySnapshot() runtime.MemStats
- func PutTask(ctx context.Context, t *Task) context.Context
- func SnapshotMemory(ctx context.Context)
- func Start(ctx context.Context, name string, args ...interface{}) context.Context
- func StartBackground(ctx context.Context, name string, args ...interface{}) context.Context
- func Unblock(ctx context.Context)
- func UpdateProgress(ctx context.Context, n, outof uint64)
- type EventScope
- type Listener
- type Replay
- type Task
- func (t *Task) Background() bool
- func (t *Task) Completion() int
- func (t *Task) ID() uint64
- func (t *Task) Name() string
- func (t *Task) ParentID() uint64
- func (t *Task) String() string
- func (t *Task) SubTasks() []*Task
- func (t *Task) TimeSinceStart() time.Duration
- func (t *Task) Traverse(cb func(*Task))
- type Unregister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Event ¶
func Event(ctx context.Context, scope EventScope, name string, args ...interface{})
Event causes an event to be recorded. If EventScope == Task then the the currently executing task will get the scope
func MemorySnapshot ¶
MemorySnapshot returns the memory statistics sampled from the last call to SnapshotMemory().
func SnapshotMemory ¶
SnapshotMemory takes a snapshot of the current process's memory.
func Start ¶
Start returns a new context for a long running task. End() must be called with the returned context once the task has been finished.
func StartBackground ¶
StartBackground returns a new context for a long running background task. End() must be called with the returned context once the task has been finished.
func UpdateProgress ¶
UpdateProgress updates the progress of the task started with Start(). n is the number of units of completion, which ranges from [0, outof).
Types ¶
type EventScope ¶
type EventScope int
EventScope defines the scope for a particular event
const ( // TaskScope is an event that applies to the current task TaskScope EventScope = iota // ProcessScope is an event that only applies to this process ProcessScope // GlobalScope is an event that applies globally GlobalScope )
func (EventScope) String ¶
func (s EventScope) String() string
type Listener ¶
type Listener interface { OnTaskStart(context.Context, *Task) OnTaskProgress(context.Context, *Task) OnTaskFinish(context.Context, *Task) OnEvent(context.Context, *Task, string, EventScope) OnMemorySnapshot(context.Context, runtime.MemStats) OnTaskBlock(context.Context, *Task) OnTaskUnblock(context.Context, *Task) OnReplayStatusUpdate(context.Context, *Replay, uint64, uint32, uint32) }
Listener is the interface implemented by types that want to listen to application status messages.
type Replay ¶
Replay contains status information about a replay.
func ReplayQueued ¶
ReplayQueued notifies listeners that a new replay has been queued.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task represents a long running job which should be reported as part of the application's status.
func (*Task) Background ¶
func (*Task) Completion ¶
Completion returns the task's completion as a percentage.
func (*Task) TimeSinceStart ¶
TimeSinceStart returns the time the task was started.
type Unregister ¶
type Unregister func()
Unregister is the function returned by RegisterListener and is used to unregister the listenenr.
func RegisterListener ¶
func RegisterListener(l Listener) Unregister
RegisterListener registers l for status updates
func RegisterLogger ¶
func RegisterLogger(progressUpdateFreq time.Duration) Unregister
RegisterLogger registers a status listener that logs the updates to the logger bound to the context. Task completion updates will only be logged at the given frequency.
func RegisterTracer ¶
func RegisterTracer(w io.Writer) Unregister
RegisterTracer registers a status listener that writes all status updates in the Chrome Trace Event Format to the writer w. See https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU for documentation on the trace event format.