EventLogRemote
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.
Constructors
makeEncrypted
Signature
declare const makeEncrypted: Effect<{
readonly changes: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly startSequence: number;
readonly storeId: StoreId;
}) => Effect<Dequeue<RemoteEntry, EventLogRemoteError>, never, Scope>;
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, EventLogRemoteError>;
}, EventLogRemoteError, Scope | Registry | EventLogEncryption | EventLogRemoteClient>makeUnencrypted
Creates an EventLogRemote that sends and receives plaintext entry payloads.
Signature
declare const makeUnencrypted: Effect.Effect<
EventLogRemote["Service"],
EventLogRemoteError,
Scope.Scope | EventLogRemoteClient | Registry
>;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 const makeWith: (...args: [{
readonly decodeChanges: (identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
}, data: Uint8Array<ArrayBuffer>) => Effect<readonly Array<RemoteEntry>, SchemaError>;
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 startSequence: number;
readonly storeId: StoreId;
}) => Effect<Dequeue<RemoteEntry, EventLogRemoteError>, never, Scope>;
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, EventLogRemoteError>;
}, EventLogRemoteError, Scope | Registry | EventLogRemoteClient>Errors
EventLogRemoteError
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;
});
}Layers
layerEncrypted
Provides an encrypted EventLogRemote using the remote RPC client and the default Web Crypto encryption layer.
Signature
declare const layerEncrypted: Layer.Layer<
EventLogRemote,
EventLogRemoteError,
RpcClient.Protocol | Registry
>;layerUnencrypted
Provides an unencrypted EventLogRemote using the remote RPC client.
Signature
declare const layerUnencrypted: Layer.Layer<
EventLogRemote,
EventLogRemoteError,
RpcClient.Protocol | Registry
>;Services
EventLogRemote
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.
Signature
declare class EventLogRemote extends Shape<"effect/eventlog/EventLogRemote", {
readonly changes: (options: {
readonly identity: {
readonly privateKey: Redacted<Uint8Array<ArrayBuffer>>;
readonly publicKey: string;
};
readonly startSequence: number;
readonly storeId: StoreId;
}) => Effect<Dequeue<RemoteEntry, EventLogRemoteError>, never, Scope>;
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, EventLogRemoteError>;
}, this> {
constructor(_: never);
}EventLogRemoteClient
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.
Signature
declare class EventLogRemoteClient extends Shape<
"effect/unstable/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 : void,
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 : void,
RpcClientError | EventLogProtocolError | Discard extends true ? never : EventLogProtocolError,
never
>;
},
this
> {
constructor(_: never);
static readonly layer: Layer<EventLogRemoteClient, never, Protocol>;
}
Creates an
EventLogRemotethat encrypts outgoing entries and decrypts incoming changes withEventLogEncryption.