EventLogServerUnencrypted.ts
EventLogServerUnencrypted.ts overview
Section titled “EventLogServerUnencrypted.ts overview”Plaintext server implementation for the event-log remote protocol.
This module accepts unencrypted event batches from remote clients, runs the
registered event handlers, stores journal entries, and streams backlog plus
live changes through the shared EventLogServer RPC protocol. It is intended
for trusted deployments, local development, and tests where event data does
not need a server-side encryption layer. The module also provides the
services and layers needed to authorize requests, map stores, persist entries,
and install the plaintext server.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”EventLogServerUnencrypted
Section titled “EventLogServerUnencrypted”makeWrite
Section titled “makeWrite”Creates a typed server-side write function for events in the supplied
EventLogSchema.
Signature
declare const makeWrite: <Groups extends EventGroup.Any>( schema: EventLog.EventLogSchema<Groups>) => Effect.Effect< < Tag extends EventGroup.Events<Groups>["tag"], Event extends Event.Any = Event.WithTag<EventGroup.Events<Groups>, Tag> >(options: { readonly storeId: StoreId readonly event: Tag readonly payload: Event.Payload<Event> }) => Effect.Effect<Event.Success<Event>, EventLogServerStoreError | Event.Error<Event>>, never, EventLogServerUnencrypted>Since v4.0.0
compaction
Section titled “compaction”compactBacklog
Section titled “compactBacklog”Runs the registered compactors over a backlog of remote entries.
When to use
Use to reduce stored remote entries before replaying them to an unencrypted event-log client.
Details
Contiguous entries handled by the same compactor may be replaced with compacted entries when the replacement count can be mapped back to increasing remote sequence numbers; otherwise the original entries are kept.
Signature
declare const compactBacklog: (options: { readonly remoteEntries: ReadonlyArray<RemoteEntry> readonly compactors: ReadonlyMap<string, RegisteredCompactor>}) => Effect.Effect<ReadonlyArray<EventJournal.RemoteEntry>, never, never>Since v4.0.0
constructors
Section titled “constructors”Creates the EventLogServerUnencrypted service from the configured storage and
registered event handlers.
When to use
Use when you need the unencrypted event-log server service from provided
Storage and an event-log Registry.
Details
The constructed service exposes makeWrite, which builds a typed server-side
write function from an EventLogSchema. Each write encodes the payload with
the event schema, runs the registered handler, and persists the generated
entry inside Storage.withTransaction.
Gotchas
The write function dies if the requested event tag is not present in the
schema passed to makeWrite; it does not report that case as a typed failure.
See
makeWritefor the accessor that retrieves the typed server-side write function from the service environmentlayerServerfor the layer form that provides this service together with an event-logRegistry
Signature
declare const make: Effect.Effect< { readonly makeWrite: <Groups extends EventGroup.Any>( schema: EventLog.EventLogSchema<Groups> ) => < Tag extends EventGroup.Events<Groups>["tag"], Event extends Event.Any = Event.WithTag<EventGroup.Events<Groups>, Tag> >(options: { readonly storeId: StoreId readonly event: Tag readonly payload: Event.Payload<Event> }) => Effect.Effect<Event.Success<Event>, EventLogServerStoreError | Event.Error<Event>> }, never, Storage | EventLog.Registry>Since v4.0.0
errors
Section titled “errors”EventLogServerAuthError (class)
Section titled “EventLogServerAuthError (class)”Error raised when unencrypted server authorization rejects an identity or store operation.
Signature
declare class EventLogServerAuthErrorSince v4.0.0
EventLogServerStoreError (class)
Section titled “EventLogServerStoreError (class)”Error raised by unencrypted server storage and store mapping operations.
Signature
declare class EventLogServerStoreErrorSince v4.0.0
layers
Section titled “layers”Builds a full unencrypted event-log RPC server for the supplied schema and event-group handler layer.
When to use
Use when you need the full unencrypted event-log RPC server layer with storage, authorization, RPC protocol, and event-group handler dependencies supplied externally.
Details
The layer installs EventLogRemoteRpcs, wires layerRpcHandlers, registers
the supplied event-group handler layer, and provides layerServer, leaving
only the required infrastructure services in the environment.
Gotchas
Entries are persisted and streamed in plaintext. Protect the backing
Storage with the surrounding infrastructure, and use durable storage that
preserves session authentication bindings when the server must survive
restarts.
See
layerNoRpcServerfor installing the same unencrypted handlers when anRpcServer.Protocolis provided elsewherelayerRpcHandlersfor wiring the unencrypted RPC handlers directlylayerServerfor constructing the server service and event-log registry without RPC handlers
Signature
declare const layer: <Groups extends EventGroup.Any, E, R>( _schema: EventLog.EventLogSchema<Groups>, layer: Layer.Layer<EventGroup.ToService<Groups>, E, R>) => Layer.Layer< never, E, | Exclude<R, EventLogServerUnencrypted | EventLog.Registry> | EventLogServerAuthorization | RpcServer.Protocol | Storage | StoreMapping>Since v4.0.0
layerNoRpcServer
Section titled “layerNoRpcServer”Builds the unencrypted event-log server handlers without installing an
RpcServer.Protocol implementation.
Signature
declare const layerNoRpcServer: <Groups extends EventGroup.Any, E, R>( _schema: EventLog.EventLogSchema<Groups>, layer: Layer.Layer<EventGroup.ToService<Groups>, E, R>) => Layer.Layer< Rpc.ToHandler<RpcGroup.Rpcs<typeof EventLogRemoteRpcs>> | EventLogAuthentication, E, Exclude<R, EventLogServerUnencrypted | EventLog.Registry> | EventLogServerAuthorization | Storage | StoreMapping>Since v4.0.0
layerRpcHandlers
Section titled “layerRpcHandlers”Provides RPC handlers for the unencrypted event-log server.
Details
Incoming plaintext entries are authorized, mapped to a server store, checked for conflicts, run through registered handlers, and persisted; change streams include compacted backlog entries when compactors are registered.
Signature
declare const layerRpcHandlers: Layer.Layer< | EventLogAuthentication | Rpc.Handler<"EventLog.Hello"> | Rpc.Handler<"EventLog.Authenticate"> | Rpc.Handler<"EventLog.WriteChunked"> | Rpc.Handler<"EventLog.WriteSingle"> | Rpc.Handler<"EventLog.Changes">, never, Storage | StoreMapping | EventLog.Registry | EventLogServerAuthorization>Since v4.0.0
layerServer
Section titled “layerServer”Provides EventLogServerUnencrypted and an event-log Registry using the
configured unencrypted server Storage.
When to use
Use to provide the unencrypted event-log server service together with the registry needed by event handlers.
Signature
declare const layerServer: Layer.Layer<EventLogServerUnencrypted | EventLog.Registry, never, Storage>Since v4.0.0
services
Section titled “services”EventLogServerAuthorization (class)
Section titled “EventLogServerAuthorization (class)”Service that validates unencrypted event-log server write access, read access, and identities.
When to use
Use to provide authorization checks for plaintext event-log writes, reads, and identity authentication.
Signature
declare class EventLogServerAuthorizationSince v4.0.0
EventLogServerUnencrypted (class)
Section titled “EventLogServerUnencrypted (class)”Service that writes plaintext event-log entries directly to unencrypted storage through registered event handlers.
When to use
Use to access or provide the server service that handles plaintext event-log writes.
Signature
declare class EventLogServerUnencryptedSince v4.0.0
StoreMapping (class)
Section titled “StoreMapping (class)”Service that resolves client-requested store ids to server store ids and checks whether a store exists.
When to use
Use to map client-visible store identifiers to server storage identifiers before authorizing or serving unencrypted event-log requests.
Signature
declare class StoreMappingSince v4.0.0
storage
Section titled “storage”Storage (class)
Section titled “Storage (class)”Defines the backing store service used by the unencrypted event-log server.
When to use
Use to provide durable event-log persistence for an unencrypted event-log server layer.
Details
It provides the server remote id, stores session authentication bindings, allocates remote sequence numbers, persists entries, streams changes, and exposes a transaction boundary.
Signature
declare class StorageSince v4.0.0
layerStorageMemory
Section titled “layerStorageMemory”Provides unencrypted server Storage using the in-memory implementation.
Signature
declare const layerStorageMemory: Layer.Layer<Storage, never, never>Since v4.0.0
makeStorageMemory
Section titled “makeStorageMemory”Creates an in-memory unencrypted server Storage.
Details
The implementation keeps per-store journals and session authentication bindings in memory, publishes live changes, and serializes transactions with a semaphore.
Signature
declare const makeStorageMemory: Effect.Effect< { readonly getId: Effect.Effect<RemoteId> readonly getOrCreateSessionAuthBinding: ( publicKey: string, signingPublicKey: Uint8Array<ArrayBuffer> ) => Effect.Effect<Uint8Array<ArrayBuffer>> readonly entriesAfter: (storeId: StoreId, entry: Entry) => Effect.Effect<Array<Entry>> readonly write: (storeId: StoreId, entries: ReadonlyArray<Entry>) => Effect.Effect<ReadonlyArray<RemoteEntry>> readonly changes: (options: { readonly storeId: StoreId readonly startSequence: number readonly compactors: ReadonlyMap<string, RegisteredCompactor> }) => Stream.Stream<RemoteEntry> readonly withTransaction: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> }, never, Scope.Scope>Since v4.0.0
layerStoreMappingStatic
Section titled “layerStoreMappingStatic”Provides a StoreMapping that accepts only one configured store id and fails
all other store ids as not found.
Signature
declare const layerStoreMappingStatic: (options: { readonly storeId: StoreId }) => Layer.Layer<StoreMapping>Since v4.0.0