Skip to content

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

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>) => boolean

Source

Since v0.2.0

Compare encoded append intent byte for byte, preserving payload order.

Signature

declare const samePayloads: (left: ReadonlyArray<Uint8Array>, right: ReadonlyArray<Uint8Array>) => boolean

Source

Since v0.2.0

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"]

Source

Since v0.2.0

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 CommitUncertain

Source

Since v0.2.0

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>
}>
>
}>

Source

Since v0.2.0

Signature

export interface AppendInput extends Schema.Schema.Type<typeof AppendInput> {}

Source

Since v0.2.0

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">>
}>

Source

Since v0.2.0

Signature

export interface AppendOptions extends Schema.Schema.Type<typeof AppendOptions> {}

Source

Since v0.2.0

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
}>

Source

Since v0.2.0

Signature

export interface EntriesOptions extends Schema.Schema.Type<typeof EntriesOptions> {}

Source

Since v0.2.0

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
}>

Source

Since v0.2.0

Signature

export interface ReadOptions extends Schema.Schema.Type<typeof ReadOptions> {}

Source

Since v0.2.0

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>

Source

Since v0.2.0

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
}>
>
}>

Source

Since v0.2.0

Signature

export interface AppendReceipt extends Schema.Schema.Type<typeof AppendReceipt> {}

Source

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
}>
>
}>

Source

Since v0.2.0

Signature

export interface Batch extends Schema.Schema.Type<typeof Batch> {}

Source

Since v0.2.0

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>
}>

Source

Since v0.2.0

Signature

export interface Content extends Schema.Schema.Type<typeof Content> {}

Source

Since v0.2.0

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
}>

Source

Since v0.2.0

Signature

export interface Cursor extends Schema.Schema.Type<typeof Cursor> {}

Source

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
}>

Source

Since v0.2.0

Signature

export interface Entry extends Schema.Schema.Type<typeof Entry> {}

Source

Since v0.2.0

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">

Source

Since v0.2.0

Signature

type IdempotencyKey = typeof IdempotencyKey.Type

Source

Since v0.2.0

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 Store

Source

Since v0.2.0

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 Transaction

Source

Since v0.2.0