completer

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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) Retry

func (bc *BatchCompleter) Retry(taskID int64, blockedTill time.Time, message string) error

Retry schedules a task for retry.

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

type RetryRequest struct {
	BlockedTill time.Time
	Message     string
}

RetryRequest represents a pending retry operation.

type SnoozeRequest

type SnoozeRequest struct {
	BlockedTill time.Time
}

SnoozeRequest represents a pending snooze operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL