Skip to main content
Version: Current

AutocloseArchiver

@rotorsoft/act-root


@rotorsoft/act-root / act/src / AutocloseArchiver

Type Alias: AutocloseArchiver<TEvents>

AutocloseArchiver<TEvents> = (stream, head, before?) => Promise<void>

Defined in: libs/act/src/types/action.ts:609

Side-effect callback the online close cycle runs before truncating a stream that the state's .autocloses(...) predicate accepted. Hosts use it to write the stream's events somewhere durable (S3, cold storage, an analytics warehouse) before the tombstone lands. The cycle threads this into CloseTarget.archive so the existing close-cycle's archive-while-guarded invariant carries over: the stream is locked against new writes while the archiver runs, and a thrown archiver leaves the stream guarded but un-truncated (no data loss, the cycle retries the candidate next tick).

State-level (one per state, last-write-wins). Hosts with per-stream archiving differences branch inside the function. Absent โ†’ truncate runs without an archive step (matches the explicit app.close({ stream }) default).

On a windowed close staged by a rolling-window policy (.autocloses({ keep })), the third argument carries the cutoff โ€” archive the events older than before; the prune deletes a subset of them (the prefix below the boundary snapshot). Absent on full closes.

Type Parametersโ€‹

TEventsโ€‹

TEvents extends Schemas

Event schemas declared by the owning state.

Parametersโ€‹

streamโ€‹

string

Committed<TEvents, keyof TEvents>

before?โ€‹

Date

Returnsโ€‹

Promise<void>