quasar_postgres/retention

Periodic, bounded PostgreSQL cleanup for terminal Quasar jobs.

Types

pub opaque type Config
pub type Event {
  BatchCompleted(
    status: String,
    requested: Int,
    deleted: Int,
    duration_ms: Int,
  )
  BatchFailed(status: String, reason: pog.QueryError)
  CycleCompleted(deleted: Int)
}

Constructors

  • BatchCompleted(
      status: String,
      requested: Int,
      deleted: Int,
      duration_ms: Int,
    )
  • BatchFailed(status: String, reason: pog.QueryError)
  • CycleCompleted(deleted: Int)
pub opaque type Runtime
pub type StartError {
  InvalidConfig
  ActorStart(actor.StartError)
}

Constructors

Values

pub fn new(
  connection: pog.Connection,
  policy: retention.Policy,
) -> Config

Builds a conservative cleanup configuration.

Defaults: 1,000 rows per batch, 100 ms between batches, and one cycle per minute. Disabled policy states are never touched.

pub fn start(config: Config) -> Result(Runtime, StartError)

Starts a linked retention worker. Stop it before closing the Pog pool.

pub fn stop(runtime: Runtime) -> Nil
pub fn with_batch_size(config: Config, rows rows: Int) -> Config
pub fn with_interval(
  config: Config,
  milliseconds milliseconds: Int,
) -> Config
pub fn with_pause(
  config: Config,
  milliseconds milliseconds: Int,
) -> Config
pub fn with_reporter(
  config: Config,
  report: fn(Event) -> Nil,
) -> Config
Search Document