GitHub

EventLogRemoteService

API reference for EventLogRemoteService.

A remote an event log syncs with (Effect's EventLogRemote): write sends it entries, changes streams the entries stored there.

Attributes

AttributeTypeDescription
idRemoteId = id

The remote's id.

first_sequenceint | None = first_sequence

The lowest sequence the remote assigns (None: 0).

compactionEventLogRemoteCompaction | None = compaction

Encrypted remote compaction: present when the remote advertises HelloResponse.compaction and the RPC client includes EventLogCompactionRpcs.

latest_sequenceLatestSequence | None

latest_sequence(identity=, store_id=): the highest sequence the remote has stored for the store (None when it has none), failing with an EventLogRemoteError when the remote cannot be asked. None for a remote that cannot tell, which EventLogService.synced then does not wait for (a pyfect addition).

Functions

__init__

__init__(id, changes, write, first_sequence=None, when_authenticated=_authenticated, latest_sequence=None, compaction=None) -> None
ParameterTypeDescription
idRemoteId
changesChanges
writeWriteFn
first_sequenceint | None = None
when_authenticatedWhenAuthenticated = _authenticated
latest_sequenceLatestSequence | None = None
compactionEventLogRemoteCompaction | None = None
def __init__(  # noqa: PLR0917
    self,
    id: RemoteId,
    changes: Changes,
    write: WriteFn,
    first_sequence: int | None = None,
    when_authenticated: WhenAuthenticated = _authenticated,
    latest_sequence: LatestSequence | None = None,
    compaction: EventLogRemoteCompaction | None = None,
) -> None:
    self.id = id
    self._changes = changes
    self._write = write
    self.first_sequence = first_sequence
    self._when_authenticated = when_authenticated
    self._latest_sequence = latest_sequence
    self.compaction = compaction

changes

changes(*, identity, store_id, start_sequence, known_entries=None) -> Effect[Dequeue[RemoteEntry, EventLogRemoteError], Never, Scope]

A queue of the entries of store_id stored on the remote for identity, from start_sequence on and then as they arrive, until the Scope closes. known_entries looks up entries stored locally, so the remote can reuse them instead of decoding the matching changes. Making it never fails; the queue fails with an EventLogRemoteError when the subscription does.

ParameterTypeDescription
identityIdentityService
store_idStoreId
start_sequenceint
known_entriesEntriesById | None = None

Returns Effect[Dequeue[RemoteEntry, EventLogRemoteError], Never, Scope]

def changes(
    self,
    *,
    identity: IdentityService,
    store_id: StoreId,
    start_sequence: int,
    known_entries: EntriesById | None = None,
) -> Effect[Dequeue[RemoteEntry, EventLogRemoteError], Never, Scope]:
    """A queue of the entries of ``store_id`` stored on the remote for
    ``identity``, from ``start_sequence`` on and then as they arrive,
    until the ``Scope`` closes. ``known_entries`` looks up entries
    stored locally, so the remote can reuse them instead of decoding
    the matching changes. Making it never fails; the queue fails with
    an ``EventLogRemoteError`` when the subscription does."""
    return self._changes(
        identity=identity,
        store_id=store_id,
        start_sequence=start_sequence,
        known_entries=known_entries,
    )

write

write(*, identity, store_id, entries) -> Effect[Sequence[WriteAck] | None, EventLogRemoteError]

Sends entries of store_id for identity, giving the remote's acks (None from a remote that sends none). Fails with an EventLogRemoteError when the remote cannot be written.

ParameterTypeDescription
identityIdentityService
store_idStoreId
entriesSequence[Entry]

Returns Effect[Sequence[WriteAck] | None, EventLogRemoteError]

def write(
    self, *, identity: IdentityService, store_id: StoreId, entries: Sequence[Entry]
) -> Effect[Sequence[WriteAck] | None, EventLogRemoteError]:
    """Sends ``entries`` of ``store_id`` for ``identity``, giving the
    remote's acks (``None`` from a remote that sends none). Fails with
    an ``EventLogRemoteError`` when the remote cannot be written."""
    return self._write(identity=identity, store_id=store_id, entries=entries)

when_authenticated

when_authenticated[A, E, R](effect) -> Effect[A, E | EventLogRemoteError, R | Identity]

Runs effect once the Identity in the context is authenticated with the remote; fails with an EventLogRemoteError when authenticating does, or as effect does.

ParameterTypeDescription
effectEffect[A, E, R]

Returns Effect[A, E | EventLogRemoteError, R | Identity]

def when_authenticated[A, E, R](
    self, effect: Effect[A, E, R], /
) -> Effect[A, E | EventLogRemoteError, R | Identity]:
    """Runs ``effect`` once the ``Identity`` in the context is
    authenticated with the remote; fails with an
    ``EventLogRemoteError`` when authenticating does, or as ``effect``
    does."""
    require_effect(effect, "effect")
    return self._when_authenticated(effect)