GitHub

event_log_server_encrypted

API reference for event_log_server_encrypted.

An event log server that stores encrypted batches it cannot read (Effect's eventlog/EventLogServerEncrypted).

Batches are kept per identity and store; a batch whose entries are all stored is skipped, and its entries are acknowledged at the sequences they were first stored at. The server also serves EventLogCompactionRpcs: with a storage that provides compaction it says so in Hello and applies the compaction policy (threshold, lag, no-op backoff, commit checks); otherwise those RPCs fail NotFound.

Values

AttributeTypeDescription
layer_rpc_handlersLayer[HandlersFor[EventLogRemoteRpcs] | HandlersFor[EventLogCompactionRpcs] | EventLogAuthentication, Never, Storage]

The RPC handlers of an encrypted server over its Storage: EventLogRemoteRpcs and EventLogCompactionRpcs.

layerLayer[Never, Never, ServerProtocol | Storage]

An encrypted server over the ServerProtocol, serving EventLogRemoteRpcs and EventLogCompactionRpcs.

make_storage_memoryEffect[StorageService, Never, Scope]

Storage kept in memory with the default compaction tuning; its pubsubs and sweep stop when the scope closes.

layer_storage_memoryLayer[Storage]

Storage kept in memory, with the default compaction tuning.

Types

TypeDefinitionDescription
CompactionBeginResulttype CompactionBeginResult = BeginStarted | BeginBusy

The result of opening a compaction stage.

RollbackRefusaltype RollbackRefusal = Literal['NotActive', 'NoPrevious', 'PruneStarted']

Classes

Functions

layer_storage_memory_with

layer_storage_memory_with(compaction=None) -> Layer[Storage]

Storage kept in memory, with compaction tuning. Dies on invalid options (see make_compaction_config).

ParameterTypeDescription
compactionCompactionOptions | None = None

Returns Layer[Storage]

def layer_storage_memory_with(compaction: CompactionOptions | None = None) -> Layer[Storage]:
    """``Storage`` kept in memory, with ``compaction`` tuning. Dies on
    invalid options (see ``make_compaction_config``)."""
    return layer_effect(Storage, make_storage_memory_with(compaction))

make_storage_memory_with

make_storage_memory_with(compaction=None) -> Effect[StorageService, Never, Scope]

Storage kept in memory, with compaction tuning; its pubsubs and sweep stop when the scope closes. Dies on invalid compaction options (see make_compaction_config).

ParameterTypeDescription
compactionCompactionOptions | None = None

Returns Effect[StorageService, Never, Scope]

def make_storage_memory_with(
    compaction: CompactionOptions | None = None,
) -> Effect[StorageService, Never, Scope]:
    """Storage kept in memory, with ``compaction`` tuning; its pubsubs and
    sweep stop when the scope closes. Dies on invalid compaction options
    (see ``make_compaction_config``)."""

    def build():
        config = yield from make_compaction_config(compaction)
        pubsubs = yield from RcMap.make(_open_pubsub, idle_time_to_live="60 seconds")
        storage = _MemoryStorage(pubsubs, config)
        yield from storage.memory_compaction.run_sweeps.fork_scoped()
        return storage

    return gen(build)

make_compaction_config

make_compaction_config(options=None) -> Effect[CompactionConfig]

options resolved against their defaults. Dies with an IllegalArgumentError unless grace is longer than both lag and stage_ttl, stage_ttl and sweep_interval are positive, and threshold_floor is a non-negative integer.

ParameterTypeDescription
optionsCompactionOptions | None = None

Returns Effect[CompactionConfig]

def make_compaction_config(options: CompactionOptions | None = None) -> Effect[CompactionConfig]:
    """``options`` resolved against their defaults. Dies with an
    ``IllegalArgumentError`` unless ``grace`` is longer than both ``lag``
    and ``stage_ttl``, ``stage_ttl`` and ``sweep_interval`` are positive, and
    ``threshold_floor`` is a non-negative integer."""
    given = options or {}

    def make() -> Effect[CompactionConfig]:
        config = CompactionConfig(
            grace=from_input_unsafe(given.get("grace", "30 days")),
            lag=from_input_unsafe(given.get("lag", "24 hours")),
            stage_ttl=from_input_unsafe(given.get("stage_ttl", "10 minutes")),
            threshold_floor=given.get("threshold_floor", 1000),
            sweep_interval=from_input_unsafe(given.get("sweep_interval", "1 hour")),
        )
        if not (config.grace > config.lag and config.grace > config.stage_ttl):
            return die(
                IllegalArgumentError("Compaction grace must be longer than lag and stageTtl")
            )
        if not config.stage_ttl.is_positive():
            return die(IllegalArgumentError("Compaction stageTtl must be positive"))
        if not config.sweep_interval.is_positive():
            return die(IllegalArgumentError("Compaction sweepInterval must be positive"))
        # Untyped callers can pass any value.
        floor = cast("object", config.threshold_floor)
        if not (
            isinstance(floor, int)
            and not isinstance(floor, bool)
            and 0 <= floor <= _MAX_SAFE_INTEGER
        ):
            return die(
                IllegalArgumentError("Compaction thresholdFloor must be a non-negative integer")
            )
        return succeed(config)

    return suspend(make)