completer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 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 state transitions and flushes them to PostgreSQL in batches. The same task claim submitted multiple times across different operations collapses to the last write.

func NewBatchCompleter

func NewBatchCompleter(repo completerRepo, cfg Config) *BatchCompleter

NewBatchCompleter creates a new BatchCompleter.

func (*BatchCompleter) Complete

func (bc *BatchCompleter) Complete(taskID, generation int64) error

Complete marks a task as completed.

func (*BatchCompleter) Fail

func (bc *BatchCompleter) Fail(taskID, generation int64, message string) error

Fail marks a task as failed with an error message.

func (*BatchCompleter) Retry

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

Retry schedules a task for retry.

func (*BatchCompleter) Snooze

func (bc *BatchCompleter) Snooze(taskID, generation 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. Calling Start twice returns an error.

func (*BatchCompleter) Stop

func (bc *BatchCompleter) Stop()

Stop signals the run loop to exit, waits for the final flush, and returns. Safe to call multiple times and safe to call without Start.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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