Documentation ¶
Overview ¶
Package taskbasket is a persistent task manager.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TB ¶
type TB struct {
// contains filtered or unexported fields
}
TB is a taskbasket, a collection of abstract tasks that are persisted to a database. When the TB is running (see TB.Run) it launches each task in a goroutine that retries until the task succeeds, at which point it is removed from the database.
func New ¶
New creates a new taskbasket. It launches goroutines for any tasks already existing in the db.
func NewTx ¶
NewTx creates a new taskbasket in the context of an existing bolt Update transaction. It launches goroutines for any tasks already exiting in the db.
func (*TB) Add ¶
Add adds a task to the taskbasket. It is persisted to the database and then processed immediately. Note that if TB.Run has not been called, this function can block.
func (*TB) AddTx ¶
AddTx adds a task to the taskbasket in the context of an existing bolt Update transaction. It is persisted to the database and processed when the transaction commits. Note that if TB.Run has not been called, this function can block.
type Task ¶
type Task interface { // Run runs the task once. // It is called repeatedly by a running taskbasket, // with exponential backoff and jitter, // until it returns nil. Run(context.Context) error }
Task is an item in a TB. The TB runs the task via its Run method. If that returns an error, it is retried after an interval.