task

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("task not found")
	ErrExists       = errors.New("task already exists")
	ErrStaleVersion = errors.New("task version is stale")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	Id uint64

	TaskId string

	// Type and Data are opaque to the base system. The implementing app owns
	// the namespace and serialization.
	Type uint32
	Data []byte

	// ReferenceId is an optional correlation ID (eg. an intent ID) used purely
	// for observability. The base system never reads it.
	ReferenceId *string

	State State

	FailedAttempts uint32
	NextAttemptAt  time.Time

	Version uint64

	CreatedAt time.Time
}

func (*Record) Clone

func (r *Record) Clone() Record

func (*Record) CopyTo

func (r *Record) CopyTo(dst *Record)

func (*Record) Validate

func (r *Record) Validate() error

type State

type State uint8
const (
	StateUnknown State = iota
	StatePending
	StateConfirmed
	StateFailed
)

func (State) String

func (s State) String() string

type Store

type Store interface {
	// PutAll creates all tasks in a single operation. This method supports
	// being executed within an existing DB transaction passed along ctx.
	PutAll(ctx context.Context, records ...*Record) error

	// Update updates an existing task with an optimistic concurrency check
	// on the version. Only mutable fields (state, failed attempts, next
	// attempt timestamp) are updated.
	Update(ctx context.Context, record *Record) error

	// GetByTaskId gets a task by its task ID
	GetByTaskId(ctx context.Context, taskId string) (*Record, error)

	// GetAllReadyByState gets all tasks in the provided state whose next
	// attempt timestamp is at or before asOf
	GetAllReadyByState(ctx context.Context, state State, asOf time.Time, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)

	// CountByState returns the count of tasks in the requested state
	CountByState(ctx context.Context, state State) (uint64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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