reaper

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package reaper periodically scans tracked operation collections for records that have been stuck in a non-terminal state (pending / running / sent / rebooting / in_progress) for longer than a configurable timeout, marks them failed, and emits a synthetic realtime event so subscribers (agents, frontends) are informed.

This directly addresses the problem that PocketBase's realtime layer is fire-and-forget: even when the original "start" event was delivered, the agent may have died mid-execution and no completion event will ever arrive. Without the reaper, the record sits in "pending" forever and the UI shows a perpetual spinner.

Configuration (environment):

STUCK_OP_TIMEOUT_SECONDS       How long a record can remain in a
                                non-terminal state before being
                                reaped. Default: 3600 (1h).
STUCK_OP_SCAN_INTERVAL_SECONDS How often the reaper scans.
                                Default: 300 (5 min).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(app core.App)

Register starts the reaper goroutine as part of app startup. The goroutine stops when the process exits; PocketBase does not expose a lifecycle hook for graceful shutdown of background tasks.

func Run

func Run(app core.App, cfg Config)

Run performs a single reap pass. Exported so tests and manual triggers (e.g. an admin endpoint) can invoke it deterministically. It never returns an error — individual failures are logged and do not interrupt the pass.

Types

type Config

type Config struct {
	Timeout      time.Duration
	ScanInterval time.Duration
}

Config controls the reaper's behavior. Zero values fall back to environment variables, and then to the documented defaults.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config populated from the environment or from the built-in defaults.

Jump to

Keyboard shortcuts

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