IF Commons GitHub

logical/layers/ports

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-anyfs-middleware FR-001

What the layers are given instead of reaching for it: the clock and the sleep, the tracer and the sink of the audit. Each is a value a caller passes, so that every layer is a function of its arguments and a test holds time in its hand.

import type { Clock } from "./ports.ts";
const clock: Clock = { now: () => 0, sleep: async () => {} };

Source: commons/anyfs/src/logical/layers/ports.ts

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

Clocktype
type Clock = { now(): number; sleep(ms: number): Promise<void> };

Time: the instant in milliseconds since the epoch, and a wait.

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

Spantype
type Span = { end(attributes: Readonly<Record<string, string | number>>): void };

A span that has begun: it ends with the attributes of what happened.

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

Tracertype
type Tracer = { start(name: string, attributes: Readonly<Record<string, string | number>>): Span };

Where spans begin.

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

AuditRecordtype
type AuditRecord = {
  readonly at: string;
  readonly store: string;
  readonly op: OpName;
  readonly path?: string;
  readonly outcome: "ok" | "missing" | "conflict" | "refused" | "unavailable" | "tampered";
  readonly size?: number;
};

What the audit says of one operation. It holds no bytes and no text of a file.

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

AuditSinktypeno test imports it
type AuditSink = (record: AuditRecord) => Promise<void>;

Where the audit records go: it may throw, and the operation says so.

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