import * as Rpc from "@effect/rpc/Rpc"; import * as RpcClient from "@effect/rpc/RpcClient"; import * as RpcGroup from "@effect/rpc/RpcGroup"; import type { Brand } from "effect/Brand"; import type * as Cause from "effect/Cause"; import * as Context from "effect/Context"; import * as Data from "effect/Data"; import type { DurationInput } from "effect/Duration"; import * as Effect from "effect/Effect"; import * as Equal from "effect/Equal"; import * as Exit from "effect/Exit"; import * as Layer from "effect/Layer"; import * as Mailbox from "effect/Mailbox"; import * as Option from "effect/Option"; import type * as Schedule from "effect/Schedule"; import { Scope } from "effect/Scope"; import type * as Stream from "effect/Stream"; import type { AlreadyProcessingMessage, MailboxFull, PersistenceError } from "./ClusterError.js"; import { EntityAddress } from "./EntityAddress.js"; import type { EntityId } from "./EntityId.js"; import * as Envelope from "./Envelope.js"; import type * as Reply from "./Reply.js"; import { RunnerAddress } from "./RunnerAddress.js"; import * as ShardId from "./ShardId.js"; import type { Sharding } from "./Sharding.js"; import { ShardingConfig } from "./ShardingConfig.js"; /** * @since 1.0.0 * @category type ids */ export declare const TypeId: unique symbol; /** * @since 1.0.0 * @category type ids */ export type TypeId = typeof TypeId; /** * @since 1.0.0 * @category models */ export interface Entity extends Equal.Equal { readonly [TypeId]: TypeId; /** * The name of the entity type. */ readonly type: Type & Brand<"EntityType">; /** * A RpcGroup definition for messages which represents the messaging protocol * that the entity is capable of processing. */ readonly protocol: RpcGroup.RpcGroup; /** * Get the shard group for the given EntityId. */ getShardGroup(entityId: EntityId): string; /** * Get the ShardId for the given EntityId. */ getShardId(entityId: EntityId): Effect.Effect; /** * Annotate the entity with a value. */ annotate(tag: Context.Tag, value: S): Entity; /** * Annotate the Rpc's above this point with a value. */ annotateRpcs(tag: Context.Tag, value: S): Entity; /** * Annotate the entity with a context object. */ annotateContext(context: Context.Context): Entity; /** * Annotate the Rpc's above this point with a context object. */ annotateRpcsContext(context: Context.Context): Entity; /** * Create a client for this entity. */ readonly client: Effect.Effect<(entityId: string) => RpcClient.RpcClient.From, never, Sharding>; /** * Create a Layer from an Entity. * * It will register the entity with the Sharding service. */ toLayer, RX = never>(build: Handlers | Effect.Effect, options?: { readonly maxIdleTime?: DurationInput | undefined; readonly concurrency?: number | "unbounded" | undefined; readonly mailboxCapacity?: number | "unbounded" | undefined; readonly disableFatalDefects?: boolean | undefined; readonly defectRetryPolicy?: Schedule.Schedule | undefined; readonly spanAttributes?: Record | undefined; }): Layer.Layer | RpcGroup.HandlersContext | Rpc.Context | Rpc.Middleware | Sharding>; of>(handlers: Handlers): Handlers; /** * Create a Layer from an Entity. * * It will register the entity with the Sharding service. */ toLayerMailbox(build: ((mailbox: Mailbox.ReadonlyMailbox>, replier: Replier) => Effect.Effect) | Effect.Effect<(mailbox: Mailbox.ReadonlyMailbox>, replier: Replier) => Effect.Effect, never, RX>, options?: { readonly maxIdleTime?: DurationInput | undefined; readonly mailboxCapacity?: number | "unbounded" | undefined; readonly disableFatalDefects?: boolean | undefined; readonly defectRetryPolicy?: Schedule.Schedule | undefined; readonly spanAttributes?: Record | undefined; }): Layer.Layer | R | Rpc.Context | Rpc.Middleware | Sharding>; } /** * @since 1.0.0 * @category models */ export type Any = Entity; /** * @since 1.0.0 * @category models */ export type HandlersFrom = { readonly [Current in Rpc as Current["_tag"]]: (envelope: Request) => Rpc.ResultFrom | Rpc.Wrapper>; }; /** * @since 1.0.0 * @category refinements */ export declare const isEntity: (u: unknown) => u is Any; /** * Creates a new `Entity` of the specified `type` which will accept messages * that adhere to the provided `RpcGroup`. * * @since 1.0.0 * @category constructors */ export declare const fromRpcGroup: ( /** * The entity type name. */ type: Type, /** * The schema definition for messages that the entity is capable of * processing. */ protocol: RpcGroup.RpcGroup) => Entity; /** * Creates a new `Entity` of the specified `type` which will accept messages * that adhere to the provided schemas. * * @since 1.0.0 * @category constructors */ export declare const make: >( /** * The entity type name. */ type: Type, /** * The schema definition for messages that the entity is capable of * processing. */ protocol: Rpcs) => Entity; declare const CurrentAddress_base: Context.TagClass; /** * A Context.Tag to access the current entity address. * * @since 1.0.0 * @category context */ export declare class CurrentAddress extends CurrentAddress_base { } declare const CurrentRunnerAddress_base: Context.TagClass; /** * A Context.Tag to access the current Runner address. * * @since 1.0.0 * @category context */ export declare class CurrentRunnerAddress extends CurrentRunnerAddress_base { } /** * @since 1.0.0 * @category Replier */ export interface Replier { readonly succeed: (request: Envelope.Request, value: Replier.Success) => Effect.Effect; readonly fail: (request: Envelope.Request, error: Rpc.Error) => Effect.Effect; readonly failCause: (request: Envelope.Request, cause: Cause.Cause>) => Effect.Effect; readonly complete: (request: Envelope.Request, exit: Exit.Exit, Rpc.Error>) => Effect.Effect; } /** * @since 1.0.0 * @category Replier */ export declare namespace Replier { /** * @since 1.0.0 * @category Replier */ type Success = Rpc.Success extends Stream.Stream ? Stream.Stream<_A, _E | Rpc.Error, _R> | Mailbox.ReadonlyMailbox<_A, _E | Rpc.Error> : Rpc.Success; } /** * @since 1.0.0 * @category Request */ export declare class Request extends Data.Class & { readonly lastSentChunk: Option.Option>; }> { /** * @since 1.0.0 */ get lastSentChunkValue(): Option.Option>; /** * @since 1.0.0 */ get nextSequence(): number; } /** * @since 1.0.0 * @category Testing */ export declare const makeTestClient: (entity: Entity, layer: Layer.Layer) => Effect.Effect<(entityId: string) => Effect.Effect>, LE, Scope | ShardingConfig | Exclude | Rpc.MiddlewareClient>; /** * @since 1.0.0 * @category Keep alive */ export declare const keepAlive: (enabled: boolean) => Effect.Effect; /** * @since 1.0.0 * @category Keep alive */ export declare const KeepAliveRpc: Rpc.Rpc<"Cluster/Entity/keepAlive", typeof import("effect/Schema").Void, typeof import("effect/Schema").Void, typeof import("effect/Schema").Never, never>; declare const KeepAliveLatch_base: Context.TagClass; /** * @since 1.0.0 * @category Keep alive */ export declare class KeepAliveLatch extends KeepAliveLatch_base { } export {}; //# sourceMappingURL=Entity.d.ts.map