Documentation
¶
Index ¶
- type BatchCompleter
- func (bc *BatchCompleter) Complete(taskID int64) error
- func (bc *BatchCompleter) Fail(taskID int64, message string) error
- func (bc *BatchCompleter) Retry(taskID int64, blockedTill time.Time, message string) error
- func (bc *BatchCompleter) Snooze(taskID int64, blockedTill time.Time) error
- func (bc *BatchCompleter) Start(ctx context.Context) error
- func (bc *BatchCompleter) Stop()
- type Completer
- type Config
- type FailRequest
- type RetryRequest
- type SnoozeRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchCompleter ¶
type BatchCompleter struct {
// contains filtered or unexported fields
}
BatchCompleter accumulates task completions and executes them in batches.
func NewBatchCompleter ¶
func NewBatchCompleter(repo completerRepo, cfg Config) *BatchCompleter
NewBatchCompleter creates a new BatchCompleter.
func (*BatchCompleter) Complete ¶
func (bc *BatchCompleter) Complete(taskID int64) error
Complete marks a task as completed.
func (*BatchCompleter) Fail ¶
func (bc *BatchCompleter) Fail(taskID int64, message string) error
Fail marks a task as failed with an error message.
func (*BatchCompleter) Snooze ¶
func (bc *BatchCompleter) Snooze(taskID int64, blockedTill time.Time) error
Snooze reschedules a task without counting it as an attempt.
func (*BatchCompleter) Start ¶
func (bc *BatchCompleter) Start(ctx context.Context) error
Start begins the batch processing loop.
func (*BatchCompleter) Stop ¶
func (bc *BatchCompleter) Stop()
Stop gracefully stops the BatchCompleter, flushing any pending operations.
type Completer ¶
type Completer interface {
Start(ctx context.Context) error
Stop()
Complete(taskID int64) error
Fail(taskID int64, message string) error
Retry(taskID int64, blockedTill time.Time, message string) error
Snooze(taskID int64, blockedTill time.Time) error
}
Completer defines the interface for task completion operations.
type Config ¶
type Config struct {
FlushInterval time.Duration
FlushThreshold int
MaxBatchSize int
MaxBacklog int
Logger *slog.Logger
}
Config configures the BatchCompleter.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default configuration for BatchCompleter.
type FailRequest ¶
type FailRequest struct {
Message string
}
FailRequest represents a pending fail operation.
type RetryRequest ¶
RetryRequest represents a pending retry operation.
type SnoozeRequest ¶
SnoozeRequest represents a pending snooze operation.