Documentation ¶
Index ¶
Constants ¶
const (
DefaultLoggingThrottle = 200 * time.Millisecond
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListTask ¶
type ListTask struct {
// contains filtered or unexported fields
}
ListTask is a Task implementation that logs all updates in a list where each entry is line-delimited.
For example:
entry #1 entry #2 msg: ..., done
func NewListTask ¶
NewListTask instantiates a new *ListTask instance with the given message.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs a series of tasks to an io.Writer, processing each task in order until completion .
func NewLogger ¶
NewLogger retuns a new *Logger instance that logs to "sink" and uses the current terminal width as the width of the line.
func (*Logger) Close ¶
func (l *Logger) Close()
Close closes the queue and does not allow new Tasks to be `enqueue()`'d. It waits until the currently running Task has completed.
func (*Logger) Percentage ¶
func (l *Logger) Percentage(msg string, total uint64) *PercentageTask
Percentage creates and enqueues a new *PercentageTask.
func (*Logger) Waiter ¶
func (l *Logger) Waiter(msg string) *WaitingTask
Waitier creates and enqueues a new *WaitingTask.
type PercentageTask ¶
type PercentageTask struct {
// contains filtered or unexported fields
}
PercentageTask is a task that is performed against a known number of elements.
func NewPercentageTask ¶
func NewPercentageTask(msg string, total uint64) *PercentageTask
func (*PercentageTask) Count ¶
func (c *PercentageTask) Count(n uint64) (new uint64)
Count indicates that work has been completed against "n" number of elements, marking the task as complete if the total "n" given to all invocations of this method is equal to total.
Count returns the new total number of (atomically managed) elements that have been completed.
func (*PercentageTask) Entry ¶
func (t *PercentageTask) Entry(update string)
Entry logs a line-delimited task entry.
func (*PercentageTask) Throttled ¶
func (c *PercentageTask) Throttled() bool
Throttled implements Task.Throttled and returns true, indicating that this task is throttled.
func (*PercentageTask) Updates ¶
func (c *PercentageTask) Updates() <-chan *Update
Updates implements Task.Updates and returns a channel which is written to when the state of this task changes, and closed when the task is completed. has been completed.
type Task ¶
type Task interface { // Updates returns a channel which is written to with the current state // of the Task when an update is present. It is closed when the task is // complete. Updates() <-chan *Update // Throttled returns whether or not updates from this task should be // limited when being printed to a sink via *log.Logger. // // It is expected to return the same value for a given Task instance. Throttled() bool }
Task is an interface which encapsulates an activity which can be logged.
type Update ¶
type Update struct { // S is the message sent in this update. S string // At is the time that this update was sent. At time.Time // Force determines if this update should not be throttled. Force bool }
Update is a single message sent (S) from a Task at a given time (At).
type WaitingTask ¶
type WaitingTask struct {
// contains filtered or unexported fields
}
WaitingTask represents a task for which the total number of items to do work is on is unknown.
func NewWaitingTask ¶
func NewWaitingTask(msg string) *WaitingTask
NewWaitingTask returns a new *WaitingTask.
func (*WaitingTask) Complete ¶
func (w *WaitingTask) Complete()
Complete marks the task as completed.
func (*WaitingTask) Throttled ¶
func (w *WaitingTask) Throttled() bool
Throttled implements Task.Throttled and returns true, indicating that this task is Throttled.
func (*WaitingTask) Updates ¶
func (w *WaitingTask) Updates() <-chan *Update
Done implements Task.Done and returns a channel which is closed when Complete() is called.