periodic-poller

command
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Command periodic-poller shows durable timers (Sleep) and ContinueAsNew for a workflow that repeats work on an interval without its history growing.

DATABASE_URL=postgres://localhost:5432/river_dev?sslmode=disable \
    go run ./examples/periodic-poller

Each iteration the "poll" workflow does one unit of work, Sleeps for an interval (a durable timer that survives restarts — no goroutine is held), then ContinueAsNew's: it ends the current run and starts a fresh generation with EMPTY history, so replay cost stays flat no matter how long the loop runs.

For the demo the poller stops itself after a few ticks (returning a result). A real, endless poller would simply always ContinueAsNew and be stopped with riverworkflow.Cancel.

Note: Sleep resolution is coarse — a timer fires on River's job-scheduler tick (a few seconds), not to the millisecond — so the ticks below are a few seconds apart even though the interval is 1s. That granularity is negligible for the minutes/hours intervals real pollers use.

Jump to

Keyboard shortcuts

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