Skip to content
// EFFECT DAYS 2026

EventLogRemote unstable

Connects a local event log to a remote replica.

EventLogRemote writes local entries to another journal, receives remote change streams from a sequence number, and can wait until the current event-log identity has completed remote authentication. The encrypted constructor is the default for browser, edge, or service replicas crossing an untrusted network. The unencrypted constructor is intended for trusted transports or tests.

12 exports Since v4.0.0 Source

Constructors

Since v4.0.0

Creates an EventLogRemote that encrypts outgoing entries and decrypts incoming changes with EventLogEncryption.

See

Signature

declare const makeEncrypted: Effect.Effect<EventLogRemote["Service"], EventLogRemoteError, Scope.Scope | EventLogRemoteClient | EventLogEncryption | Registry>
Since v4.0.0

Creates an EventLogRemote that encrypts outgoing entries and decrypts incoming changes with EventLogEncryption.

Details

The remote has a compaction member when the server advertises compaction and the RPC client includes EventLogCompactionRpcs, unless built with compaction: false. Without it the client never calls the compaction RPCs.

Signature

declare const makeEncryptedWith: (...args: [options: {
readonly compaction?: boolean;
}]) => Effect<{
readonly changes: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly knownEntries?: (ids: readonly Array<EntryId>) => Effect<readonly Array<Entry | undefined>, EventJournalError>;
readonly startSequence: number;
readonly storeId: StoreId;
}) => Effect<Dequeue<RemoteEntry, EventLogRemoteError>, never, Scope>;
readonly compaction?: EventLogRemoteCompaction;
readonly firstSequence?: number;
readonly id: RemoteId;
readonly whenAuthenticated: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, EventLogRemoteError | E, Identity | R>;
readonly write: (options: {
readonly entries: readonly Array<Entry>;
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly storeId: StoreId;
}) => Effect<void | readonly Array<{
readonly entryId: Uint8Array<ArrayBuffer> & Brand<"effect/eventlog/EventJournal/EntryId">;
readonly sequence: number;
}>, EventLogRemoteError>;
}, EventLogRemoteError, Scope | Registry | EventLogEncryption | EventLogRemoteClient>
Since v4.0.0

Creates an EventLogRemote that sends and receives plaintext entry payloads.

Signature

declare const makeUnencrypted: Effect.Effect<EventLogRemote["Service"], EventLogRemoteError, Scope.Scope | EventLogRemoteClient | Registry>

makeWith

unstable
Since v4.0.0

Creates an EventLogRemote from custom write encoding and change decoding functions.

Details

The remote performs the hello/authentication handshake, retries after forbidden responses by re-authenticating, chunks large writes, and registers itself with the Registry for the current scope.

Signature

declare function makeWith(options: {
readonly decodeChanges: (identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
}, storeId: StoreId, data: Uint8Array<ArrayBuffer>, knownEntries?: (ids: readonly Array<EntryId>) => Effect<readonly Array<Entry | undefined>, EventJournalError>) => Effect<readonly Array<RemoteEntry>, SchemaError | EventJournalError>;
readonly encodeWrite: (options: {
readonly entries: readonly Array<Entry>;
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly storeId: StoreId;
}) => Effect<Uint8Array<ArrayBuffer>, SchemaError>;
}): Effect<{
readonly changes: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly knownEntries?: (ids: readonly Array<EntryId>) => Effect<readonly Array<Entry | undefined>, EventJournalError>;
readonly startSequence: number;
readonly storeId: StoreId;
}) => Effect<Dequeue<RemoteEntry, EventLogRemoteError>, never, Scope>;
readonly compaction?: EventLogRemoteCompaction;
readonly firstSequence?: number;
readonly id: RemoteId;
readonly whenAuthenticated: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, EventLogRemoteError | E, Identity | R>;
readonly write: (options: {
readonly entries: readonly Array<Entry>;
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly storeId: StoreId;
}) => Effect<void | readonly Array<{
readonly entryId: Uint8Array<ArrayBuffer> & Brand<"effect/eventlog/EventJournal/EntryId">;
readonly sequence: number;
}>, EventLogRemoteError>;
}, EventLogRemoteError, Scope | Registry | EventLogRemoteClient>

Errors

Since v4.0.0

Error raised by EventLogRemote operations, recording the failed method and underlying cause.

Signature

declare class EventLogRemoteError extends YieldableError<this> & {
readonly _tag: "EventLogRemoteError";
} & Readonly<{
readonly cause: unknown;
readonly method: string;
}> {
constructor(args: {
readonly cause: unknown;
readonly method: string;
});
static is(u: unknown): u is EventLogRemoteError;
}

Layers

Since v4.0.0

Provides an encrypted EventLogRemote using the remote RPC client and the default Web Crypto encryption layer.

See

Signature

declare const layerEncrypted: Layer.Layer<EventLogRemote, EventLogRemoteError, RpcClient.Protocol | Registry>
Since v4.0.0

Provides an encrypted EventLogRemote using the remote RPC client and the default Web Crypto encryption layer.

Details

compaction: false leaves the remote without its compaction member, so this client never calls the compaction RPCs.

Signature

declare function layerEncryptedWith(options: {
readonly compaction?: boolean;
}): Layer<EventLogRemote, EventLogRemoteError, Protocol | Registry>
Since v4.0.0

Provides an unencrypted EventLogRemote using the remote RPC client.

Signature

declare const layerUnencrypted: Layer.Layer<EventLogRemote, EventLogRemoteError, RpcClient.Protocol | Registry>

Models

CompactionStage

interface unstable
Since v4.0.0

A stage opened by EventLogRemoteCompaction.begin, with the identity and store it belongs to.

Signature

interface CompactionStage {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly stageId: string;
readonly storeId: StoreId;
}

EventLogRemoteCompaction

interface unstable
Since v4.0.0

Client side of encrypted remote compaction.

Details

A run opens a stage with begin, reads its input headers with input, fetches the batches it needs with fetch, uploads the kept entries with upload and calls commit. abort releases a stage that won't be committed.

Signature

interface EventLogRemoteCompaction {
readonly abort: (stage: CompactionStage) => Effect<void>;
readonly begin: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly storeId: StoreId;
}) => Effect<{
readonly _tag: "Started";
readonly stageId: string;
} | {
readonly _tag: "Busy";
} | {
readonly _tag: "NotWanted";
}, EventLogRemoteError>;
readonly commit: (stage: CompactionStage, result: {
readonly _tag: "Snapshot";
readonly segmentCount: number;
} | {
readonly _tag: "NoOp";
}) => Effect<"Committed" | "Superseded", EventLogRemoteError>;
readonly fetch: (stage: CompactionStage, sequences: readonly Array<number>) => Stream<RemoteEntry, EventLogRemoteError>;
readonly input: (stage: CompactionStage) => Stream<{
readonly entryIds: readonly [Uint8Array<ArrayBuffer> & Brand<"effect/eventlog/EventJournal/EntryId">, Uint8Array<ArrayBuffer> & Brand<"effect/eventlog/EventJournal/EntryId">];
readonly sequence: number;
}, EventLogRemoteError>;
readonly status: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly storeId: StoreId;
}) => Effect<CompactionStatus, EventLogRemoteError>;
readonly upload: (stage: CompactionStage, entries: readonly Array<Entry>) => Effect<{
readonly segmentCount: number;
}, EventLogRemoteError>;
}

Services

Since v4.0.0

Service that represents a remote event-log replica.

When to use

Use to access or provide a remote event-log replica that can write local entries and stream remote changes.

Details

It can write local entries to the remote, stream remote changes from a sequence number, and run effects only after the supplied identity has authenticated.

Built-in remotes acknowledge writes instead of echoing them through changes. Custom remotes may return void from write to confirm uploads through changes instead.

Signature

declare class EventLogRemote extends Shape<"effect/eventlog/EventLogRemote", {
readonly changes: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly knownEntries?: (ids: readonly Array<EntryId>) => Effect<readonly Array<Entry | undefined>, EventJournalError>;
readonly startSequence: number;
readonly storeId: StoreId;
}) => Effect<Dequeue<RemoteEntry, EventLogRemoteError>, never, Scope>;
readonly compaction?: EventLogRemoteCompaction;
readonly firstSequence?: number;
readonly id: RemoteId;
readonly whenAuthenticated: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, EventLogRemoteError | E, Identity | R>;
readonly write: (options: {
readonly entries: readonly Array<Entry>;
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly storeId: StoreId;
}) => Effect<void | readonly Array<{
readonly entryId: Uint8Array<ArrayBuffer> & Brand<"effect/eventlog/EventJournal/EntryId">;
readonly sequence: number;
}>, EventLogRemoteError>;
}, this> {
constructor(_: never);
}
Since v4.0.0

Service that provides a typed RPC client for the EventLogRemoteRpcs protocol.

When to use

Use to provide the RPC client used by remote event-log replicas to authenticate, write entries, and subscribe to changes.

Details

The EventLogCompactionRpcs methods are optional. The encrypted remote offers compaction only when the client has them. layer builds the client from both groups.

Signature

declare class EventLogRemoteClient extends Shape<"effect/eventlog/EventLogRemote/EventLogRemoteClient", {
"EventLog.Authenticate": <AsQueue extends boolean = false, Discard = false>(input: {
readonly algorithm: "Ed25519";
readonly publicKey: string;
readonly signature: Uint8Array<ArrayBuffer>;
readonly signingPublicKey: Uint8Array<ArrayBuffer>;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : void, RpcClientError | Discard extends true ? never : EventLogProtocolError, never>;
"EventLog.Changes": <AsQueue extends boolean = false, Discard = false>(input: {
readonly publicKey: string;
readonly startSequence: number;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly asQueue?: AsQueue;
readonly context?: Context<never>;
readonly headers?: Input;
readonly streamBufferSize?: number;
}) => AsQueue extends true ? Effect<Dequeue<SingleMessage | ChunkedMessage, Done<void> | RpcClientError | EventLogProtocolError>, never, Scope> : Stream<SingleMessage | ChunkedMessage, RpcClientError | EventLogProtocolError, never>;
"EventLog.Hello": <AsQueue extends boolean = false, Discard = false>(input: void, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : HelloResponse, RpcClientError | Discard extends true ? never : never, never>;
"EventLog.WriteChunked": <AsQueue extends boolean = false, Discard = false>(input: {
readonly _tag?: "Chunked";
readonly data: Uint8Array<ArrayBuffer>;
readonly id: number;
readonly part: readonly [number, number];
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : readonly Array<{
readonly entryId: Uint8Array<...> & Brand<...>;
readonly sequence: number;
}>, RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
"EventLog.WriteSingle": <AsQueue extends boolean = false, Discard = false>(input: {
readonly data: Uint8Array<ArrayBuffer>;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : readonly Array<{
readonly entryId: Uint8Array<...> & Brand<...>;
readonly sequence: number;
}>, RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
} & Partial<{
"EventLog.CompactionAbort": <AsQueue extends boolean = false, Discard = false>(input: {
readonly publicKey: string;
readonly stageId: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : void, RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
"EventLog.CompactionBegin": <AsQueue extends boolean = false, Discard = false>(input: {
readonly publicKey: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : {
readonly _tag: "Started";
readonly stageId: string;
} | {
readonly _tag: "Busy";
} | {
readonly _tag: "NotWanted";
}, RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
"EventLog.CompactionCommit": <AsQueue extends boolean = false, Discard = false>(input: {
readonly publicKey: string;
readonly result: {
readonly _tag?: "Snapshot";
readonly segmentCount: number;
} | {
readonly _tag?: "NoOp";
};
readonly stageId: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : "Committed" | "Superseded", RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
"EventLog.CompactionFetch": <AsQueue extends boolean = false, Discard = false>(input: {
readonly batches: readonly Array<number>;
readonly publicKey: string;
readonly stageId: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly asQueue?: AsQueue;
readonly context?: Context<never>;
readonly headers?: Input;
readonly streamBufferSize?: number;
}) => AsQueue extends true ? Effect<Dequeue<SingleMessage | ChunkedMessage, Done<...> | RpcClientError | EventLogProtocolError>, never, Scope> : Stream<SingleMessage | ChunkedMessage, RpcClientError | EventLogProtocolError, never>;
"EventLog.CompactionInput": <AsQueue extends boolean = false, Discard = false>(input: {
readonly publicKey: string;
readonly stageId: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly asQueue?: AsQueue;
readonly context?: Context<never>;
readonly headers?: Input;
readonly streamBufferSize?: number;
}) => AsQueue extends true ? Effect<Dequeue<SingleMessage | ChunkedMessage, Done<...> | RpcClientError | EventLogProtocolError>, never, Scope> : Stream<SingleMessage | ChunkedMessage, RpcClientError | EventLogProtocolError, never>;
"EventLog.CompactionPart": <AsQueue extends boolean = false, Discard = false>(input: {
readonly chunk: ChunkedMessage;
readonly publicKey: string;
readonly stageId: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : void, RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
"EventLog.CompactionStatus": <AsQueue extends boolean = false, Discard = false>(input: {
readonly publicKey: string;
readonly storeId: string & Brand<"effect/eventlog/EventLog/StoreId">;
}, options?: {
readonly context?: Context<never>;
readonly discard?: Discard;
readonly headers?: Input;
}) => Effect<Discard extends true ? void : CompactionStatus, RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError, never>;
}>, this> {
constructor(_: never);
static readonly layer: Layer<EventLogRemoteClient, never, Protocol>;
}