Documentation
¶
Overview ¶
A "Task", as used in this package, is simply a function that takes in input, returns data (or an error), and runs a maximum of one time per execution context / input value pairing, even if invoked repeatedly during the lifetime of the execution context.
Tasks are automatically protected from circular deps by Go's compile-time "initialization cycle" errors (assuming they are defined as package-level variables).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
func NewCtx ¶
NewCtx creates a new task execution context with no TTL. The context will cache task results indefinitely until the Ctx is discarded.
func NewCtxWithTTL ¶
NewCtxWithTTL creates a new task execution context with a TTL for cached results. When ttl > 0, cached results expire after the specified duration and will be re-executed on subsequent access. Expired entries are lazily removed from memory during cache access, at most once per TTL period.
func (*Ctx) NativeContext ¶
func (*Ctx) RunParallel ¶
type Task ¶
type Task[I comparable, O any] struct { // contains filtered or unexported fields }
type TaskResult ¶
func (*TaskResult) OK ¶
func (r *TaskResult) OK() bool