/** * Defines the message shapes moved through Effect Cluster. * * Messages carry entity requests and control envelopes between callers, durable * storage, transports, and runner handlers. This module includes incoming and * outgoing variants for encoded stored requests, decoded local requests, * acknowledgements, and interrupts. It also provides helpers for local delivery * and for encoding or decoding request payloads with matching RPC schemas. * * @stability unstable * @since 4.0.0 */ import * as Context from "../Context.ts"; import * as Effect from "../Effect.ts"; import * as Option from "../Option.ts"; import * as Rpc from "../rpc/Rpc.ts"; import type * as RpcSerialization from "../rpc/RpcSerialization.ts"; import type * as Scope from "../Scope.ts"; import type { PersistenceError } from "./ClusterError.ts"; import { MalformedMessage } from "./ClusterError.ts"; import type { EntityAddress } from "./EntityAddress.ts"; import * as Envelope from "./Envelope.ts"; import type * as Reply from "./Reply.ts"; import type { Snowflake } from "./Snowflake.ts"; /** * Message read by a runner from storage or transport. * * **Details** * * An incoming message is either a persisted request with an encoded payload or an * incoming control envelope. * * @stability unstable * @category models * @since 4.0.0 */ export type Incoming = IncomingRequest | IncomingEnvelope; /** * Locally decoded incoming message for in-process delivery. * * **Details** * * It is either a request with a decoded payload or an incoming control envelope. * * @stability unstable * @category models * @since 4.0.0 */ export type IncomingLocal = IncomingRequestLocal | IncomingEnvelope; /** * Converts an outgoing message into a locally deliverable incoming message. * * **Details** * * Request messages keep their decoded payload and response callback, while * control envelopes are wrapped as incoming envelopes. * * @stability unstable * @category converting * @since 4.0.0 */ export declare const incomingLocalFromOutgoing: (self: Outgoing) => IncomingLocal; declare const IncomingRequest_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly & { readonly _tag: "IncomingRequest"; } & import("../Pipeable.ts").Pipeable; /** * Represents an incoming persisted request whose payload has not yet been decoded with the RPC * schema. * * **Details** * * It carries the last reply that was sent and a callback for persisting encoded * replies. * * @stability unstable * @category models * @since 4.0.0 */ export declare class IncomingRequest extends IncomingRequest_base<{ readonly envelope: Envelope.PartialRequest; readonly lastSentReply: Option.Option; readonly respond: (reply: Reply.ReplyWithContext) => Effect.Effect; /** * Codec that filled the payload and reply holes of this message. * * Messages read from `MessageStorage` use the JSON codec, while the runner * server sets it to the codec of its transport. */ readonly codecFor: RpcSerialization.CodecFor; /** * Scope that cancels interruptible, non-persisted requests when closed. * * @stability unstable * @since 4.0.0 */ readonly callerScope?: Scope.Scope | undefined; }> { } declare const IncomingRequestLocal_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly & { readonly _tag: "IncomingRequestLocal"; } & import("../Pipeable.ts").Pipeable; /** * Represents an incoming request for local delivery with a decoded payload. * * **Details** * * It includes dynamic annotations, the last sent reply, and a callback for * replying with decoded replies. * * @stability unstable * @category models * @since 4.0.0 */ export declare class IncomingRequestLocal extends IncomingRequestLocal_base<{ readonly envelope: Envelope.Request; readonly lastSentReply: Option.Option>; readonly respond: (reply: Reply.Reply) => Effect.Effect; readonly annotations: Context.Context; /** * Scope that cancels interruptible, non-persisted requests when closed. * * @stability unstable * @since 4.0.0 */ readonly callerScope?: Scope.Scope | undefined; }> { } declare const IncomingEnvelope_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly & { readonly _tag: "IncomingEnvelope"; } & import("../Pipeable.ts").Pipeable; /** * Represents an incoming control envelope carrying an `AckChunk` or `Interrupt`. * * @stability unstable * @category models * @since 4.0.0 */ export declare class IncomingEnvelope extends IncomingEnvelope_base<{ readonly _tag: "IncomingEnvelope"; readonly envelope: Envelope.AckChunk | Envelope.Interrupt; }> { } /** * Message produced for storage or transport. * * **Details** * * An outgoing message is either an entity request or a control envelope. * * @stability unstable * @category models * @since 4.0.0 */ export type Outgoing = OutgoingRequest | OutgoingEnvelope; declare const OutgoingRequest_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly & { readonly _tag: "OutgoingRequest"; } & import("../Pipeable.ts").Pipeable; /** * Represents an outgoing entity request with decoded payload and RPC metadata. * * **Details** * * It carries the service context used for serialization, the last received reply, * the reply callback, dynamic annotations, and an optional encoded request cache. * * @stability unstable * @category models * @since 4.0.0 */ export declare class OutgoingRequest extends OutgoingRequest_base<{ readonly envelope: Envelope.Request; readonly context: Context.Context>; readonly lastReceivedReply: Option.Option>; readonly rpc: R; readonly respond: (reply: Reply.Reply) => Effect.Effect; readonly annotations: Context.Context; }> { /** * Cached encoded envelope payload and the codec that produced it. The cache * is reused only when the requested codec is the same function. * * @stability unstable * @since 4.0.0 */ encodedCache?: { readonly codecFor: RpcSerialization.CodecFor; readonly envelope: Envelope.PartialRequest; }; } declare const OutgoingEnvelope_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly & { readonly _tag: "OutgoingEnvelope"; } & import("../Pipeable.ts").Pipeable; /** * Represents an outgoing control envelope paired with RPC metadata. * * **When to use** * * Use to construct an interrupt envelope for an * in-flight request. * * @stability unstable * @category models * @since 4.0.0 */ export declare class OutgoingEnvelope extends OutgoingEnvelope_base<{ readonly envelope: Envelope.AckChunk | Envelope.Interrupt; readonly rpc: Rpc.AnyWithProps; }> { /** * Creates an outgoing interrupt envelope for the supplied request. * * @stability unstable * @since 4.0.0 */ static interrupt(options: { readonly address: EntityAddress; readonly id: Snowflake; readonly requestId: Snowflake; }): OutgoingEnvelope; } /** * Serializes an outgoing message into a partial envelope. * * **Details** * * Control envelopes pass through unchanged. Requests are encoded with their RPC * payload schema, reusing the cached encoded request when available. * * @stability unstable * @category serialization * @since 4.0.0 */ export declare const serialize: (message: Outgoing, codecFor: RpcSerialization.CodecFor) => Effect.Effect; /** * Serializes an outgoing message into its JSON envelope representation. * * **Details** * * Schema encoding failures are converted to `MalformedMessage`. * * @stability unstable * @category serialization * @since 4.0.0 */ export declare const serializeEnvelope: (message: Outgoing) => Effect.Effect; /** * Encodes the payload of an `OutgoingRequest` with the request's RPC payload * schema and service context. * * **Details** * * The result is a `PartialRequest` suitable for storage or transport. * * @stability unstable * @category serialization * @since 4.0.0 */ export declare const serializeRequest: (self: OutgoingRequest, codecFor: RpcSerialization.CodecFor) => Effect.Effect; /** * Decodes a partial envelope back into a locally deliverable incoming message. * * **Details** * * Control envelopes pass through directly. Request envelopes require the original * `OutgoingRequest` so the payload can be decoded with the correct RPC schema and * context. * * @stability unstable * @category serialization * @since 4.0.0 */ export declare const deserializeLocal: (self: Outgoing, encoded: Envelope.Partial, codecFor: RpcSerialization.CodecFor) => Effect.Effect, MalformedMessage>; export {}; //# sourceMappingURL=Message.d.ts.map