GitHub

event_log_message

API reference for event_log_message.

The RPCs between an event log and its remote server (Effect's eventlog/EventLogMessage).

A client says Hello (the server's remote id and a one-time challenge), Authenticate\s an identity by signing the challenge, then writes entries (WriteSingle, or WriteChunked parts of at most 512,000 bytes) and streams Changes. Writes and changes carry their entries as SchemaBinary bytes: encrypted batches, or plain entries for an unencrypted server.

Re-exports

Values

AttributeTypeDescription
CHUNK_SIZELiteral[512000] = 512000
WRITE_ENTRIES_CODECBytesCodec[WriteEntries]
WRITE_ENTRIES_UNENCRYPTED_CODECBytesCodec[WriteEntriesUnencrypted]
CHANGES_ENCRYPTED_CODECBytesCodec[tuple[EncryptedRemoteBatch, ...]]
CHANGES_UNENCRYPTED_CODECBytesCodec[tuple[RemoteEntry, ...]]
HelloRpcRpc[None, HelloResponse, Never, Never, Never, Literal['EventLog.Hello']]
AuthenticateRpcRpc[Authenticate, None, EventLogProtocolError, Never, Never, Literal['EventLog.Authenticate']]
WriteChunkedRpcRpc[ChunkedMessage, tuple[WriteAck, ...], EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.WriteChunked']]
WriteSingleRpcRpc[WriteSinglePayload, tuple[WriteAck, ...], EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.WriteSingle']]
ChangesRpcStreamRpc[ChangesPayload, SingleMessage | ChunkedMessage, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.Changes']]
LatestSequenceRpcRpc[LatestSequencePayload, int | None, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.LatestSequence']]

The highest sequence the server has stored for an identity's store, or None (a pyfect addition: what EventLog.synced waits for).

CompactionBeginResultSchemaUnionSchema[CompactionStarted | CompactionBusy | CompactionNotWanted, Mapping[str, object], Never, Never]
CompactionResultSchemaUnionSchema[CompactionSnapshot | CompactionNoOp, Mapping[str, object], Never, Never]
COMPACTION_INPUT_HEADERS_CODECBytesCodec[tuple[CompactionInputHeader, ...]]

A CompactionInput frame (Effect's CompactionInputRpc.HeadersFromSchemaBinary).

COMPACTION_SEGMENT_CODECBytesCodec[tuple[EncryptedBatch, ...]]

A CompactionPart segment (Effect's CompactionPartRpc.SegmentFromSchemaBinary).

CompactionStatusRpcRpc[CompactionScopePayload, CompactionStatus, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionStatus']]

Reports a store's compaction state.

CompactionBeginRpcRpc[CompactionScopePayload, CompactionStarted | CompactionBusy | CompactionNotWanted, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionBegin']]

Opens a compaction stage.

CompactionInputRpcStreamRpc[CompactionStagePayload, SingleMessage | ChunkedMessage, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionInput']]

Streams a stage's input batch headers in input order: the pinned snapshot, then the originals up to the stage's through, framed as in ChangesRpc. Fails NotFound once the stage or its pin is gone.

CompactionFetchRpcStreamRpc[CompactionFetchPayload, SingleMessage | ChunkedMessage, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionFetch']]

Streams the encrypted input batches at the given input sequences, framed and encoded as in ChangesRpc. Fails NotFound once the stage or its pin is gone.

CompactionPartRpcRpc[CompactionPartPayload, None, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionPart']]

Uploads one piece of a snapshot segment (an encoded non-empty array of encrypted batches, indexed by chunk.id). A re-uploaded segment is acknowledged without storing it again; one that fails validation aborts the stage with InvalidRequest.

CompactionAbortRpcRpc[CompactionStagePayload, None, EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionAbort']]

Releases an open stage. A late abort is a no-op.

CompactionCommitRpcRpc[CompactionCommitPayload, Literal['Committed', 'Superseded'], EventLogProtocolError, EventLogAuthentication, EventLogAuthentication, Literal['EventLog.CompactionCommit']]

Commits a stage: Superseded when its pinned generation is no longer active; InvalidRequest (aborting the stage) when the segments are incomplete or the kept ids are not a non-empty, repeat-free subsequence of the pinned input; NotFound when the stage expired, was aborted or committed, or is unknown, so a retried commit fails too.

Types

TypeDefinitionDescription
ProtocolErrorCodetype ProtocolErrorCode = Literal['Unauthorized', 'Forbidden', 'NotFound', 'InvalidRequest', 'InternalServerError']
JoinStatetype JoinState = dict[int, _Parts]
CompactionBeginResulttype CompactionBeginResult = CompactionStarted | CompactionBusy | CompactionNotWanted
CompactionResulttype CompactionResult = CompactionSnapshot | CompactionNoOp

Classes

Functions

encode_changes_encrypted

encode_changes_encrypted(batches) -> Effect[bytes, S.SchemaError]

A Changes frame of encrypted batches (Effect's ChangesRpc.encodeEncrypted).

ParameterTypeDescription
batchesSequence[EncryptedRemoteBatch]

Returns Effect[bytes, S.SchemaError]

def encode_changes_encrypted(
    batches: Sequence[EncryptedRemoteBatch],
) -> Effect[bytes, S.SchemaError]:
    """A ``Changes`` frame of encrypted batches (Effect's
    ``ChangesRpc.encodeEncrypted``)."""
    return S.encode_effect(CHANGES_ENCRYPTED_CODEC)(tuple(batches))

decode_changes_encrypted

decode_changes_encrypted(data, **options) -> Effect[tuple[EncryptedRemoteBatch, ...], S.SchemaError]
ParameterTypeDescription
databytes
optionsUnpack[S.ParseOptions] = {}

Returns Effect[tuple[EncryptedRemoteBatch, ...], S.SchemaError]

def decode_changes_encrypted(
    data: bytes, **options: Unpack[S.ParseOptions]
) -> Effect[tuple[EncryptedRemoteBatch, ...], S.SchemaError]:
    return S.decode_effect(CHANGES_ENCRYPTED_CODEC, **options)(data)

encode_changes_unencrypted

encode_changes_unencrypted(entries) -> Effect[bytes, S.SchemaError]

A Changes frame of plain entries (Effect's ChangesRpc.encodeUnencrypted).

ParameterTypeDescription
entriesSequence[RemoteEntry]

Returns Effect[bytes, S.SchemaError]

def encode_changes_unencrypted(entries: Sequence[RemoteEntry]) -> Effect[bytes, S.SchemaError]:
    """A ``Changes`` frame of plain entries (Effect's
    ``ChangesRpc.encodeUnencrypted``)."""
    return S.encode_effect(CHANGES_UNENCRYPTED_CODEC)(tuple(entries))

decode_changes_unencrypted

decode_changes_unencrypted(data, **options) -> Effect[tuple[RemoteEntry, ...], S.SchemaError]
ParameterTypeDescription
databytes
optionsUnpack[S.ParseOptions] = {}

Returns Effect[tuple[RemoteEntry, ...], S.SchemaError]

def decode_changes_unencrypted(
    data: bytes, **options: Unpack[S.ParseOptions]
) -> Effect[tuple[RemoteEntry, ...], S.SchemaError]:
    return S.decode_effect(CHANGES_UNENCRYPTED_CODEC, **options)(data)

encode_compaction_input_headers

encode_compaction_input_headers(headers) -> Effect[bytes, S.SchemaError]
ParameterTypeDescription
headersSequence[CompactionInputHeader]

Returns Effect[bytes, S.SchemaError]

def encode_compaction_input_headers(
    headers: Sequence[CompactionInputHeader],
) -> Effect[bytes, S.SchemaError]:
    return S.encode_effect(COMPACTION_INPUT_HEADERS_CODEC)(tuple(headers))

decode_compaction_input_headers

decode_compaction_input_headers(data, **options) -> Effect[tuple[CompactionInputHeader, ...], S.SchemaError]
ParameterTypeDescription
databytes
optionsUnpack[S.ParseOptions] = {}

Returns Effect[tuple[CompactionInputHeader, ...], S.SchemaError]

def decode_compaction_input_headers(
    data: bytes, **options: Unpack[S.ParseOptions]
) -> Effect[tuple[CompactionInputHeader, ...], S.SchemaError]:
    return S.decode_effect(COMPACTION_INPUT_HEADERS_CODEC, **options)(data)

encode_compaction_segment

encode_compaction_segment(batches) -> Effect[bytes, S.SchemaError]
ParameterTypeDescription
batchesSequence[EncryptedBatch]

Returns Effect[bytes, S.SchemaError]

def encode_compaction_segment(batches: Sequence[EncryptedBatch]) -> Effect[bytes, S.SchemaError]:
    return S.encode_effect(COMPACTION_SEGMENT_CODEC)(tuple(batches))

decode_compaction_segment

decode_compaction_segment(data, **options) -> Effect[tuple[EncryptedBatch, ...], S.SchemaError]
ParameterTypeDescription
databytes
optionsUnpack[S.ParseOptions] = {}

Returns Effect[tuple[EncryptedBatch, ...], S.SchemaError]

def decode_compaction_segment(
    data: bytes, **options: Unpack[S.ParseOptions]
) -> Effect[tuple[EncryptedBatch, ...], S.SchemaError]:
    return S.decode_effect(COMPACTION_SEGMENT_CODEC, **options)(data)