Store
The storage contract for logs, which every storage adapter implements for one space of logs.
Store appends to and reads the space’s logs, opens native transactions, and waits for appends;
Transaction is the handle a native transaction provides, through which a commit’s log appends,
and whatever else the host enlists, join one commit. The coordinator in Transaction.Transaction
runs commits over this contract, and Log reads and writes through it; make checks every input
before an adapter’s driver sees it.
Since v0.2.0
Comparisons
Section titled “Comparisons”sameContents
Section titled “sameContents”Retries compare the complete content: payloads byte for byte, and names and subjects by value. Storage adapters check a keyed retry against its original append with it.
Signature
declare const sameContents: (left: ReadonlyArray<Content>, right: ReadonlyArray<Content>) => booleanSince v0.2.0
samePayloads
Section titled “samePayloads”Compare encoded append intent byte for byte, preserving payload order.
Signature
declare const samePayloads: (left: ReadonlyArray<Uint8Array>, right: ReadonlyArray<Uint8Array>) => booleanSince v0.2.0
Constructors
Section titled “Constructors”The store over a driver: each input is checked against its schema before the driver sees it. A transaction’s appends are checked the same way, through the handle the program is given.
Signature
declare const make: (driver: Store["Service"]) => Store["Service"]Since v0.2.0
Errors
Section titled “Errors”CommitUncertain (class)
Section titled “CommitUncertain (class)”Storage could not confirm whether a commit took effect. commitId names it for reconciliation;
retrying the same keyed intent reuses a first attempt that committed.
Signature
declare class CommitUncertainSince v0.2.0
Options
Section titled “Options”AppendInput
Section titled “AppendInput”One append as storage receives it: the log, the entries’ contents in order, and the append’s options. A keyed append holds at least one entry.
Signature
declare const AppendInput: Schema.Struct<{ readonly expectedAfter: Schema.optionalKey<Schema.Option<Schema.brand<Schema.Natural, "LogPosition">>> readonly idempotencyKey: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "LogIdempotencyKey">> readonly logId: Schema.brand<Schema.NonEmptyString, "LogId"> readonly entries: Schema.$Array< Schema.Struct<{ readonly payload: Schema.Uint8Array readonly name: Schema.optionalKey<Schema.NonEmptyString> readonly subject: Schema.optionalKey<Schema.NonEmptyString> }> >}>Since v0.2.0
AppendInput (interface)
Section titled “AppendInput (interface)”Signature
export interface AppendInput extends Schema.Schema.Type<typeof AppendInput> {}Since v0.2.0
AppendOptions
Section titled “AppendOptions”How an append is conditioned: on the log’s current position, and on whether a key already names it.
Signature
declare const AppendOptions: Schema.Struct<{ readonly expectedAfter: Schema.optionalKey<Schema.Option<Schema.brand<Schema.Natural, "LogPosition">>> readonly idempotencyKey: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "LogIdempotencyKey">>}>Since v0.2.0
AppendOptions (interface)
Section titled “AppendOptions (interface)”Signature
export interface AppendOptions extends Schema.Schema.Type<typeof AppendOptions> {}Since v0.2.0
EntriesOptions
Section titled “EntriesOptions”A page of entries: those with a name, a subject, or both, after the exclusive after cursor and
at most limit. Entry pagination is independent of the complete-batch replay cursor.
Signature
declare const EntriesOptions: Schema.Struct<{ readonly name: Schema.optionalKey<Schema.NonEmptyString> readonly subject: Schema.optionalKey<Schema.NonEmptyString> readonly after: Schema.optionalKey< Schema.Struct<{ readonly position: Schema.brand<Schema.Natural, "LogPosition">; readonly index: Schema.Natural }> > readonly limit: Schema.Int}>Since v0.2.0
EntriesOptions (interface)
Section titled “EntriesOptions (interface)”Signature
export interface EntriesOptions extends Schema.Schema.Type<typeof EntriesOptions> {}Since v0.2.0
ReadOptions
Section titled “ReadOptions”A page of complete batches: those after the exclusive after position, or from the log’s
beginning, and at most limit.
Signature
declare const ReadOptions: Schema.Struct<{ readonly after: Schema.optionalKey<Schema.brand<Schema.Natural, "LogPosition">> readonly limit: Schema.Int}>Since v0.2.0
ReadOptions (interface)
Section titled “ReadOptions (interface)”Signature
export interface ReadOptions extends Schema.Schema.Type<typeof ReadOptions> {}Since v0.2.0
Running
Section titled “Running”runAfterCommit
Section titled “runAfterCommit”Run what a committed transaction’s afterCommit collected, in order, logging each failure
rather than passing it on: the commit already happened. For storage adapters.
Signature
declare const runAfterCommit: (effects: ReadonlyArray<Effect.Effect<void>>) => Effect.Effect<void, never, never>Since v0.2.0
Schemas
Section titled “Schemas”AppendReceipt
Section titled “AppendReceipt”A durable key binds the exact slice written by one append, not its entire commit: storage keeps the key with its commit, the first index and count of its slice, and the entries, which a retry returns.
Signature
declare const AppendReceipt: Schema.Struct<{ readonly logId: Schema.brand<Schema.NonEmptyString, "LogId"> readonly key: Schema.brand<Schema.NonEmptyString, "LogIdempotencyKey"> readonly commitId: Schema.brand<Schema.NonEmptyString, "LogCommitId"> readonly firstIndex: Schema.Natural readonly entryCount: Schema.Int readonly entries: Schema.NonEmptyArray< Schema.Struct<{ readonly payload: Schema.Uint8Array readonly name: Schema.optionalKey<Schema.NonEmptyString> readonly subject: Schema.optionalKey<Schema.NonEmptyString> readonly id: Schema.brand<Schema.NonEmptyString, "LogEntryId"> readonly logId: Schema.brand<Schema.NonEmptyString, "LogId"> readonly position: Schema.brand<Schema.Natural, "LogPosition"> readonly commitId: Schema.brand<Schema.NonEmptyString, "LogCommitId"> readonly index: Schema.Natural readonly recordedAt: Schema.DateTimeUtcFromString }> >}>Since v0.2.0
AppendReceipt (interface)
Section titled “AppendReceipt (interface)”Signature
export interface AppendReceipt extends Schema.Schema.Type<typeof AppendReceipt> {}Since v0.2.0
All entries written to one log by one commit.
Signature
declare const Batch: Schema.Struct<{ readonly logId: Schema.brand<Schema.NonEmptyString, "LogId"> readonly position: Schema.brand<Schema.Natural, "LogPosition"> readonly commit: Schema.Struct<{ readonly id: Schema.brand<Schema.NonEmptyString, "LogCommitId"> readonly entryCount: Schema.Natural readonly recordedAt: Schema.DateTimeUtcFromString }> readonly entries: Schema.NonEmptyArray< Schema.Struct<{ readonly payload: Schema.Uint8Array readonly name: Schema.optionalKey<Schema.NonEmptyString> readonly subject: Schema.optionalKey<Schema.NonEmptyString> readonly id: Schema.brand<Schema.NonEmptyString, "LogEntryId"> readonly logId: Schema.brand<Schema.NonEmptyString, "LogId"> readonly position: Schema.brand<Schema.Natural, "LogPosition"> readonly commitId: Schema.brand<Schema.NonEmptyString, "LogCommitId"> readonly index: Schema.Natural readonly recordedAt: Schema.DateTimeUtcFromString }> >}>Since v0.2.0
Batch (interface)
Section titled “Batch (interface)”Signature
export interface Batch extends Schema.Schema.Type<typeof Batch> {}Since v0.2.0
Content
Section titled “Content”What an entry stores: its payload, and the name and subject a log may give it, which storage
indexes so that readEntries can select entries by either.
Signature
declare const Content: Schema.Struct<{ readonly payload: Schema.Uint8Array readonly name: Schema.optionalKey<Schema.NonEmptyString> readonly subject: Schema.optionalKey<Schema.NonEmptyString>}>Since v0.2.0
Content (interface)
Section titled “Content (interface)”Signature
export interface Content extends Schema.Schema.Type<typeof Content> {}Since v0.2.0
Cursor
Section titled “Cursor”An entry’s place in its log: its batch’s position and its index in that batch. Entry reads page by it, exclusively, so a page can end inside a commit.
Signature
declare const Cursor: Schema.Struct<{ readonly position: Schema.brand<Schema.Natural, "LogPosition"> readonly index: Schema.Natural}>Since v0.2.0
Cursor (interface)
Section titled “Cursor (interface)”Signature
export interface Cursor extends Schema.Schema.Type<typeof Cursor> {}Since v0.2.0
Complete persisted entry, with queryable metadata beside the payload: its content, where it is, and which commit recorded it.
Signature
declare const Entry: Schema.Struct<{ readonly payload: Schema.Uint8Array readonly name: Schema.optionalKey<Schema.NonEmptyString> readonly subject: Schema.optionalKey<Schema.NonEmptyString> readonly id: Schema.brand<Schema.NonEmptyString, "LogEntryId"> readonly logId: Schema.brand<Schema.NonEmptyString, "LogId"> readonly position: Schema.brand<Schema.Natural, "LogPosition"> readonly commitId: Schema.brand<Schema.NonEmptyString, "LogCommitId"> readonly index: Schema.Natural readonly recordedAt: Schema.DateTimeUtcFromString}>Since v0.2.0
Entry (interface)
Section titled “Entry (interface)”Signature
export interface Entry extends Schema.Schema.Type<typeof Entry> {}Since v0.2.0
IdempotencyKey
Section titled “IdempotencyKey”Names one append within a log, so that a retry under the same key returns the original entries instead of appending again. Its encoding is a persistence contract.
Signature
declare const IdempotencyKey: Schema.brand<Schema.NonEmptyString, "LogIdempotencyKey">Since v0.2.0
IdempotencyKey (type alias)
Section titled “IdempotencyKey (type alias)”Signature
type IdempotencyKey = typeof IdempotencyKey.TypeSince v0.2.0
Services
Section titled “Services”Store (class)
Section titled “Store (class)”What a storage adapter implements for one space of logs. make builds the store over a driver
of the same shape. It checks every input against its schema before the driver sees it, so a
driver keeps only what storage keeps.
Signature
declare class StoreSince v0.2.0
Transaction (class)
Section titled “Transaction (class)”Host-owned write handle shared by all logs and whatever else the host enlists: the handle of one
native transaction, which Store.transaction provides to its program. Every log append requires
it and enlists in its commit, and a host’s own stores may require it too, so that their writes
commit with the entries.
Signature
declare class TransactionSince v0.2.0