GitHub

StorageService

API reference for StorageService.

Where an unencrypted server keeps entries.

Attributes

AttributeTypeDescription
first_sequenceint | None = None
get_idEffect[RemoteId]

The storage's remote id, which the server sends clients in its hello. Never fails.

Functions

get_or_create_session_auth_binding

get_or_create_session_auth_binding(public_key, signing_public_key) -> Effect[bytes]

The signing key bound to public_key, binding the given one on first use. The server passes only verified keys, and rejects one that differs from the returned binding. Never fails.

ParameterTypeDescription
public_keystr
signing_public_keybytes

Returns Effect[bytes]

@abstractmethod
def get_or_create_session_auth_binding(
    self, public_key: str, signing_public_key: bytes, /
) -> Effect[bytes]:
    """The signing key bound to ``public_key``, binding the given one
    on first use. The server passes only verified keys, and rejects one
    that differs from the returned binding. Never fails."""

entries_after

entries_after(store_id, oldest, batch=None) -> Effect[list[RemoteEntry]]

Stored entries at or after oldest: with a batch, only those it repeats or shares an event and primary key with.

ParameterTypeDescription
store_idStoreId
oldestEntry
batchSequence[Entry] | None = None

Returns Effect[list[RemoteEntry]]

@abstractmethod
def entries_after(
    self, store_id: StoreId, oldest: Entry, batch: Sequence[Entry] | None = None, /
) -> Effect[list[RemoteEntry]]:
    """Stored entries at or after ``oldest``: with a ``batch``, only
    those it repeats or shares an event and primary key with."""

write

write(store_id, entries) -> Effect[list[RemoteEntry]]

Appends entries to store_id, each at the next sequence, publishes them to its changes, and gives them with their sequences. Never fails; an entry already stored is a defect.

ParameterTypeDescription
store_idStoreId
entriesSequence[Entry]

Returns Effect[list[RemoteEntry]]

@abstractmethod
def write(self, store_id: StoreId, entries: Sequence[Entry], /) -> Effect[list[RemoteEntry]]:
    """Appends ``entries`` to ``store_id``, each at the next sequence,
    publishes them to its ``changes``, and gives them with their
    sequences. Never fails; an entry already stored is a defect."""

changes

changes(store_id, start_sequence, compactors) -> Stream[RemoteEntry]

The entries of store_id from start_sequence on, the backlog compacted by compactors, then each new one as it is written. Never fails.

ParameterTypeDescription
store_idStoreId
start_sequenceint
compactorsMapping[str, RegisteredCompactor]

Returns Stream[RemoteEntry]

@abstractmethod
def changes(
    self,
    store_id: StoreId,
    start_sequence: int,
    compactors: Mapping[str, RegisteredCompactor],
    /,
) -> Stream[RemoteEntry]:
    """The entries of ``store_id`` from ``start_sequence`` on, the
    backlog compacted by ``compactors``, then each new one as it is
    written. Never fails."""

latest_sequence

latest_sequence(store_id) -> Effect[int | None]

The sequence of the last stored entry, None when there is none.

ParameterTypeDescription
store_idStoreId

Returns Effect[int | None]

@abstractmethod
def latest_sequence(self, store_id: StoreId, /) -> Effect[int | None]:
    """The sequence of the last stored entry, ``None`` when there is none."""

with_transaction

with_transaction[A, E, R](effect) -> Effect[A, E, R]

Run effect in the storage's transaction, so its writes commit together and publish in commit order.

ParameterTypeDescription
effectEffect[A, E, R]

Returns Effect[A, E, R]

def with_transaction[A, E, R](self, effect: Effect[A, E, R], /) -> Effect[A, E, R]:
    """Run ``effect`` in the storage's transaction, so its writes commit
    together and publish in commit order."""
    require_effect(effect, "effect")
    return self._with_transaction(effect)