Documentation
¶
Index ¶
- type Cooldown
- type DBReporter
- type LoggingReporter
- type Reporter
- type Tracker
- func (t *Tracker) Child(operation task.Operation) *Tracker
- func (t *Tracker) Complete(ctx context.Context)
- func (t *Tracker) Fail(ctx context.Context, errMsg string)
- func (t *Tracker) Notify(ctx context.Context)
- func (t *Tracker) SetCurrent(ctx context.Context, current int, message string)
- func (t *Tracker) SetTotal(ctx context.Context, total int)
- func (t *Tracker) Skip(ctx context.Context, reason string)
- func (t *Tracker) Status() task.Status
- func (t *Tracker) Subscribe(reporter Reporter)
- func (t *Tracker) WithLabel(key, value string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cooldown ¶
type Cooldown struct {
// contains filtered or unexported fields
}
Cooldown wraps a Reporter and limits how frequently updates are delivered for each status ID. Terminal states (completed, failed, skipped) are always delivered immediately. Non-terminal updates are delivered at most once per the configured interval; the latest pending status is flushed when the interval elapses or when a terminal state arrives.
func NewCooldown ¶
NewCooldown creates a Cooldown wrapping the given reporter with the specified minimum interval between deliveries per status ID.
type DBReporter ¶
type DBReporter struct {
// contains filtered or unexported fields
}
DBReporter implements Reporter by persisting status changes to the database.
func NewDBReporter ¶
func NewDBReporter(repo task.StatusStore, logger zerolog.Logger) *DBReporter
NewDBReporter creates a new DBReporter.
type LoggingReporter ¶
type LoggingReporter struct {
// contains filtered or unexported fields
}
LoggingReporter implements Reporter by logging status changes.
func NewLoggingReporter ¶
func NewLoggingReporter(logger zerolog.Logger) *LoggingReporter
NewLoggingReporter creates a new LoggingReporter.
type Reporter ¶
type Reporter interface {
// OnChange is called when a task status changes.
OnChange(ctx context.Context, status task.Status) error
}
Reporter defines the interface for progress reporting modules. Implementations receive notifications when task status changes.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker provides progress tracking with automatic notification to subscribers. It wraps Status and propagates state changes to registered reporters.
func NewTracker ¶
NewTracker creates a new progress tracker wrapping the given Status.
func TrackerForOperation ¶
func TrackerForOperation( operation task.Operation, logger zerolog.Logger, trackableType task.TrackableType, trackableID int64, ) *Tracker
TrackerForOperation creates a new Tracker for the given operation.
func (*Tracker) Child ¶
Child creates a child tracker for a sub-operation. The child inherits the parent's subscribers, trackable info, and labels.
func (*Tracker) Notify ¶
Notify explicitly notifies all subscribers of the current status. Use this after initial setup to announce the tracker's existence.
func (*Tracker) SetCurrent ¶
SetCurrent updates the current progress count and optionally a message.