Documentation
¶
Overview ¶
Package taskruntime provides bounded, durable scheduling for typed background tasks.
Index ¶
- type Admitter
- type CancelFunc
- type EventSink
- type Handler
- type Manager
- func (manager *Manager) CancelTask(ctx context.Context, owner, taskID string) (*database.TaskEntity, bool, error)
- func (manager *Manager) GetTask(ctx context.Context, owner, taskID string) (*database.TaskEntity, bool, error)
- func (manager *Manager) ListTasks(ctx context.Context, owner string, states []database.TaskState, limit int) ([]database.TaskEntity, error)
- func (manager *Manager) RegisterCancel(kind string, cancel CancelFunc) error
- type Options
- type Outcome
- type Recoverer
- type Service
- type Settler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Admitter ¶
type Admitter interface {
TryAdmit(context.Context, *database.TaskEntity) (bool, error)
ReleaseAdmission(string)
}
Admitter reserves execution resources while a task is still queued.
type CancelFunc ¶
CancelFunc requests cancellation through a kind's specialized lifecycle service.
type Handler ¶
type Handler interface {
Kind() string
Run(context.Context, *database.TaskEntity, EventSink) (Outcome, error)
}
Handler reconstructs and executes one durable task kind.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides transport-neutral lifecycle inspection while preserving typed cancellation behavior.
func NewManager ¶
func NewManager(tasks *database.TaskRepository) *Manager
NewManager constructs generic lifecycle management over the authoritative tasks table.
func (*Manager) CancelTask ¶
func (manager *Manager) CancelTask( ctx context.Context, owner, taskID string, ) (*database.TaskEntity, bool, error)
CancelTask dispatches cancellation to the task kind's specialized service.
func (*Manager) GetTask ¶
func (manager *Manager) GetTask( ctx context.Context, owner, taskID string, ) (*database.TaskEntity, bool, error)
GetTask returns an owner-scoped generic lifecycle snapshot.
func (*Manager) ListTasks ¶
func (manager *Manager) ListTasks( ctx context.Context, owner string, states []database.TaskState, limit int, ) ([]database.TaskEntity, error)
ListTasks lists every supported durable task kind owned by a session.
func (*Manager) RegisterCancel ¶
func (manager *Manager) RegisterCancel(kind string, cancel CancelFunc) error
RegisterCancel installs the specialized cancellation path for a durable task kind.
type Options ¶
type Options struct {
Tasks *database.TaskRepository
Logger *slog.Logger
Workers int
PollInterval time.Duration
LeaseDuration time.Duration
HeartbeatInterval time.Duration
RecoveryInterval time.Duration
DefaultTimeout time.Duration
MaxPayloadBytes int
}
Options configures the generic task-table polling scheduler.
type Outcome ¶
type Outcome struct {
Value any `json:"value,omitempty"`
Summary string `json:"summary,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
Outcome is a handler's canonical structured result and searchable summary.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns all scheduler and execution goroutines.
func (*Service) CancelActive ¶
CancelActive interrupts a locally running task after durable cancellation is requested.
func (*Service) Notify ¶
func (service *Service) Notify()
Notify wakes the task-table poller after durable acceptance.