IF Commons GitHub

physical/timer

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-evidence-capture-views FR-006

The one timer that runs the collector (0005-evidence-capture-views FR-006): how often it fires follows from the shortest cadence of the capture policy, in whole steps of the clock, and it is installed and removed with the scheduler code of the commons (systemd, launchd or Task Scheduler). What the timer runs, and where, is the caller's: it gives the argument vector and the folder.

import { timerEvery } from "./timer.ts";
// timerEvery(policy) is { kind: "minutes", every: 15 } for a cadence of 15 minutes

Source: commons/evidence-capture/src/physical/timer.ts

2 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.timerEveryfunctionno test imports it
function timerEvery(policy: CapturePolicy): { readonly kind: "minutes"; readonly every: number; } | { readonly kind: "hourly"; }

How often the one timer fires: the largest step of the clock (1, 2, 3, 4, 5, 6, 10, 12, 15, 20 or 30 minutes) that is not longer than the shortest cadence of the policy, so that nothing due waits for the next firing; every hour where the shortest cadence is an hour or more. The collector decides, on each firing, which assets are due.

physical.Timertypeno test imports it
type Timer = { readonly job: JobSpec; readonly plan: JobPlan; readonly firesEvery: string; readonly windowMs: number };

What the timer is made from: the plan, the job and how often it fires, and the freshness window of the policy.

physical.TimerSpectypeno test imports it
type TimerSpec = { readonly name: string; readonly owner: { readonly domain: string; readonly folder: string }; readonly argv: readonly string[]; readonly workdir: string; readonly os: SchedulerOs; readonly home: string; readonly uid?: number };

What the timer runs and where: the name it is known by, the argument vector, the folder, the scheduler, the home folder and the user.

physical.timerForfunctionno test imports it
function timerFor(policy: CapturePolicy, s: TimerSpec): Result<Timer, string>

The timer of a collector for a capture policy and a scheduler.

physical.setTimerfunctionno test imports it
function setTimer(action: "install" | "remove", job: JobSpec, options: JobOptions): Promise<Result<JobReport, string>>

Installs or removes the timer through the commons' scheduler code; options say where (a test gives a folder and a runner of its own).

timerEveryfunction
function timerEvery(policy: CapturePolicy): { readonly kind: "minutes"; readonly every: number; } | { readonly kind: "hourly"; }

How often the one timer fires: the largest step of the clock (1, 2, 3, 4, 5, 6, 10, 12, 15, 20 or 30 minutes) that is not longer than the shortest cadence of the policy, so that nothing due waits for the next firing; every hour where the shortest cadence is an hour or more. The collector decides, on each firing, which assets are due.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Timertypeno test imports it
type Timer = { readonly job: JobSpec; readonly plan: JobPlan; readonly firesEvery: string; readonly windowMs: number };

What the timer is made from: the plan, the job and how often it fires, and the freshness window of the policy.

TimerSpectypeno test imports it
type TimerSpec = { readonly name: string; readonly owner: { readonly domain: string; readonly folder: string }; readonly argv: readonly string[]; readonly workdir: string; readonly os: SchedulerOs; readonly home: string; readonly uid?: number };

What the timer runs and where: the name it is known by, the argument vector, the folder, the scheduler, the home folder and the user.

timerForfunction
function timerFor(policy: CapturePolicy, s: TimerSpec): Result<Timer, string>

The timer of a collector for a capture policy and a scheduler.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

setTimerfunctionno test imports it
function setTimer(action: "install" | "remove", job: JobSpec, options: JobOptions): Promise<Result<JobReport, string>>

Installs or removes the timer through the commons' scheduler code; options say where (a test gives a folder and a runner of its own).

Titles, headings, exports, tables, columns and requirements. Esc closes.