SnapshotStore <T>
Index
Constructors
Methods
Constructors
constructor
Parameters
historyMillis: number = 30_000
Returns SnapshotStore<T>
Methods
getAll
Direct access to the underlying array (for backward-compat getters).
Returns T[]
getSample
Return all snapshots, or only those within the given time window.
Parameters
optionalsampleDurationMillis: number
Returns T[]
push
Add a snapshot and prune entries older than the history window.
Parameters
snapshot: T
now: Date = snapshot.createdAt
Returns void
staticfromEvent
Create a
LoadSignalthat snapshots in response to anEventManagerevent.The
handlerreceives the event payload and the store. It should callstore.push()to record a snapshot.Parameters
options: { event: EventTypeName; events: EventManager; handler: (store, payload) => void; name: string; overloadedRatio: number; snapshotHistoryMillis?: number }
event: EventTypeName
events: EventManager
handler: (store, payload) => void
name: string
overloadedRatio: number
optionalsnapshotHistoryMillis: number
Returns Omit<LoadSignal, getSample> & { handle: (payload) => void; store: SnapshotStore<T>; getSample: any }
staticfromInterval
Create a
LoadSignalthat snapshots on abetterSetIntervaltick.The
handlerreceives the store (to read previous snapshots) and the interval callback (which it must call when done). It should callstore.push()to record a snapshot.Parameters
options: { handler: (store, intervalCallback) => void; intervalMillis: number; name: string; overloadedRatio: number; snapshotHistoryMillis?: number }
handler: (store, intervalCallback) => void
intervalMillis: number
name: string
overloadedRatio: number
optionalsnapshotHistoryMillis: number
Returns Omit<LoadSignal, getSample> & { handle: (cb) => void; store: SnapshotStore<T>; getSample: any }
A time-pruning, time-windowed store for
LoadSnapshotvalues. Signals compose with this instead of inheriting from a base class.