reportqueue

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvelopeVersion = 2
	KindReport      = "report"
)

Variables

View Source
var ErrLocked = errors.New("queue is locked")

Functions

func NewEnvelopeID

func NewEnvelopeID(now time.Time) string

func Permanent

func Permanent(err error) error

func RegistryObservation

func RegistryObservation(report Report) registry.Observation

func RegistryReport

func RegistryReport(report Report) registry.Observation

func RootForStore

func RootForStore(storePath string) string

Types

type DrainOptions

type DrainOptions struct {
	MaxItems     int
	LeaseTimeout time.Duration
	Now          func() time.Time
	Processor    Processor
}

type DrainResult

type DrainResult struct {
	Processed int  `json:"processed"`
	Succeeded int  `json:"succeeded"`
	Retried   int  `json:"retried"`
	Dead      int  `json:"dead"`
	Recovered int  `json:"recovered"`
	Locked    bool `json:"locked"`
}

type EnqueueOptions

type EnqueueOptions struct {
	Now func() time.Time
}

type EnqueueResult

type EnqueueResult struct {
	ID   string `json:"id"`
	Path string `json:"path"`
}

type Envelope

type Envelope struct {
	Version             int                  `json:"version"`
	ID                  string               `json:"id"`
	CreatedAt           time.Time            `json:"created_at"`
	StorePath           string               `json:"store_path"`
	Kind                string               `json:"kind"`
	Report              Report               `json:"report"`
	RawPayloadSet       bool                 `json:"raw_payload_set,omitempty"`
	NoTmux              bool                 `json:"no_tmux,omitempty"`
	Runtime             RuntimeContext       `json:"runtime"`
	Attempt             int                  `json:"attempt,omitempty"`
	NextAttemptAt       time.Time            `json:"next_attempt_at,omitzero"`
	ProcessingStartedAt time.Time            `json:"processing_started_at,omitzero"`
	WorkerPID           int                  `json:"worker_pid,omitempty"`
	LastError           string               `json:"last_error,omitempty"`
	CachedTmux          registry.TmuxContext `json:"cached_tmux,omitzero"`
}

type PermanentError

type PermanentError struct {
	Err error
}

func (PermanentError) Error

func (e PermanentError) Error() string

func (PermanentError) Unwrap

func (e PermanentError) Unwrap() error

type Processor

type Processor func(context.Context, Envelope) error

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func New

func New(storePath string) Queue

func (Queue) Drain

func (q Queue) Drain(ctx context.Context, options DrainOptions) (DrainResult, error)

func (Queue) Enqueue

func (q Queue) Enqueue(ctx context.Context, envelope Envelope, options EnqueueOptions) (EnqueueResult, error)

func (Queue) LookupTmuxContext

func (q Queue) LookupTmuxContext(reference registry.TmuxContext, now time.Time, ttl time.Duration) (registry.TmuxContext, bool)

func (Queue) Root

func (q Queue) Root() string

func (Queue) Status

func (q Queue) Status(ctx context.Context) (StatusResult, error)

func (Queue) StoreTmuxContext

func (q Queue) StoreTmuxContext(ctx context.Context, tmux registry.TmuxContext, now time.Time) error

type Report

type Report = registry.Observation

Report is the v2 observation payload carried by a queue envelope.

It aliases the registry contract so queue serialization cannot drift from registry observation semantics.

func ReportFromRegistry

func ReportFromRegistry(observation registry.Observation) Report

type RuntimeContext

type RuntimeContext struct {
	CWD        string            `json:"cwd,omitempty"`
	ParentArgs []string          `json:"parent_args,omitempty"`
	Env        map[string]string `json:"env,omitempty"`
}

type StatusResult

type StatusResult struct {
	Root               string    `json:"root"`
	Pending            int       `json:"pending"`
	Ready              int       `json:"ready"`
	Deferred           int       `json:"deferred"`
	Processing         int       `json:"processing"`
	StaleLeases        int       `json:"stale_leases"`
	Retries            int       `json:"retries"`
	NextRetryAt        time.Time `json:"next_retry_at,omitzero"`
	Dead               int       `json:"dead"`
	Invalid            int       `json:"invalid"`
	OldestPendingAt    time.Time `json:"oldest_pending_at,omitzero"`
	OldestProcessingAt time.Time `json:"oldest_processing_at,omitzero"`
	OldestBacklogAt    time.Time `json:"oldest_backlog_at,omitzero"`
	OldestDeadAt       time.Time `json:"oldest_dead_at,omitzero"`
}

Jump to

Keyboard shortcuts

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