Per-instance interval gating in the polling loop #15

Open
opened 2026-04-26 01:25:39 +02:00 by myrmidex · 0 comments
Owner

Context

v0.1 polls every enabled instance every minute regardless of instances.interval_seconds. The column exists and is validated (fedi-discover:validate rejects < 1) but is currently ignored at poll time.

PollFediverseAction::execute() runs unconditionally; PollInstancesCommand::handle() calls it for every Instance::enabled() row each minute.

Goal

Respect interval_seconds per instance. If now() - last_polled_at < interval_seconds, skip this tick.

Acceptance criteria

  • PollInstancesCommand (or the action) skips an instance when last_polled_at + interval_seconds > now().
  • A skipped instance does NOT count as a failure (exit code stays 0).
  • Logging at debug level (or quiet) when an instance is skipped — not at warn level; routine.
  • Test: instance with interval_seconds=600 and last_polled_at=now() is NOT polled this minute.
  • Test: same instance with last_polled_at=now()-700s IS polled.
  • Test: last_polled_at=null (never polled) is always polled.

Where the gate lives — design call

Two options:

  • A. Inside PollFediverseAction::execute() — early return if not due. Action is the gatekeeper.
  • B. Inside PollInstancesCommand::handle() — filter the Instance::enabled() collection before iterating.

B is cleaner: action stays single-purpose ("poll this instance, no questions"), command owns the scheduling concern. Pick B unless there's a reason to invert.

Out of scope

Per-instance backoff on errors (separate concern — file separately if needed).

## Context `v0.1` polls every enabled instance every minute regardless of `instances.interval_seconds`. The column exists and is validated (`fedi-discover:validate` rejects `< 1`) but is currently ignored at poll time. `PollFediverseAction::execute()` runs unconditionally; `PollInstancesCommand::handle()` calls it for every `Instance::enabled()` row each minute. ## Goal Respect `interval_seconds` per instance. If `now() - last_polled_at < interval_seconds`, skip this tick. ## Acceptance criteria - `PollInstancesCommand` (or the action) skips an instance when `last_polled_at + interval_seconds > now()`. - A skipped instance does NOT count as a failure (exit code stays 0). - Logging at debug level (or quiet) when an instance is skipped — not at warn level; routine. - Test: instance with `interval_seconds=600` and `last_polled_at=now()` is NOT polled this minute. - Test: same instance with `last_polled_at=now()-700s` IS polled. - Test: `last_polled_at=null` (never polled) is always polled. ## Where the gate lives — design call Two options: - **A.** Inside `PollFediverseAction::execute()` — early return if not due. Action is the gatekeeper. - **B.** Inside `PollInstancesCommand::handle()` — filter the `Instance::enabled()` collection before iterating. B is cleaner: action stays single-purpose ("poll this instance, no questions"), command owns the scheduling concern. Pick B unless there's a reason to invert. ## Out of scope Per-instance backoff on errors (separate concern — file separately if needed).
myrmidex added this to the v0.2 milestone 2026-04-26 01:25:39 +02:00
myrmidex self-assigned this 2026-04-26 01:25:39 +02:00
myrmidex added the
enhancement
label 2026-04-26 01:28:09 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lvl0/trove#15
No description provided.