Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Scheduler)
func WithBackoff ¶
WithBackoff overrides the retry backoff strategy and maximum delay between execution attempts
func WithMaxFailedAttempts ¶
WithMaxFailedAttempts overrides the number of failed execution attempts before a task is marked as failed
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is the entry point into the guaranteed task execution system. Tasks are durably enqueued within the caller's DB transaction and executed at least once via the app's TaskExecutor, either through the best-effort fast path or the background worker.
func NewScheduler ¶
func NewScheduler(log *zap.Logger, data ocp_data.Provider, executor integration.TaskExecutor, opts ...Option) *Scheduler
func (*Scheduler) Enqueue ¶
Enqueue durably persists tasks for guaranteed execution. When called within a DB transaction passed along ctx (eg. the one committing an intent), the tasks are persisted atomically with that transaction.
func (*Scheduler) ExecuteAndAdvance ¶
ExecuteAndAdvance executes a single pending task and advances its state based on the outcome. On success the task is confirmed. On failure the task is scheduled for a retry with backoff, or marked as failed once the maximum attempt count is reached.
Both the fast path and the background worker funnel through this method, so the two cannot disagree on semantics. Concurrent executions of the same task are resolved by the optimistic concurrency check when the task record is updated.
func (*Scheduler) TryExecuteNow ¶
TryExecuteNow makes a best-effort immediate execution attempt for the provided tasks. Failures are left for the background worker to retry.
This must only be called after the tasks have been committed to the DB.