import * as Context from "../Context.ts"; import type { Input } from "../Duration.ts"; import * as Effect from "../Effect.ts"; import * as Layer from "../Layer.ts"; import type * as Rpc from "../rpc/Rpc.ts"; import * as RpcClient from "../rpc/RpcClient.ts"; import * as Schedule from "../Schedule.ts"; import * as Scope from "../Scope.ts"; import * as Stream from "../Stream.ts"; import type { MailboxFull, PersistenceError } from "./ClusterError.ts"; import { AlreadyProcessingMessage, EntityNotAssignedToRunner } from "./ClusterError.ts"; import { CurrentAddress, type CurrentRunnerAddress, type Entity, type HandlersFrom } from "./Entity.ts"; import type { EntityId } from "./EntityId.ts"; import * as Message from "./Message.ts"; import * as MessageStorage from "./MessageStorage.ts"; import * as RunnerHealth from "./RunnerHealth.ts"; import { Runners } from "./Runners.ts"; import { RunnerStorage } from "./RunnerStorage.ts"; import type { ShardId } from "./ShardId.ts"; import { ShardingConfig } from "./ShardingConfig.ts"; import { type ShardingRegistrationEvent } from "./ShardingRegistrationEvent.ts"; import * as Snowflake from "./Snowflake.ts"; declare const Sharding_base: Context.ServiceClass; /** * Returns the `ShardId` of the shard to which the entity at the specified * `address` is assigned. */ readonly getShardId: (entityId: EntityId, group: string) => ShardId; /** * Returns `true` if the specified `shardId` is assigned to this runner. */ readonly hasShardId: (shardId: ShardId) => boolean; /** * Generate a Snowflake ID that is unique to this runner. */ readonly getSnowflake: Effect.Effect; /** * Returns `true` if sharding is shutting down, `false` otherwise. */ readonly isShutdown: Effect.Effect; /** * Constructs a `RpcClient` which can be used to send messages to the * specified `Entity`. */ readonly makeClient: (entity: Entity) => Effect.Effect<(entityId: string) => RpcClient.RpcClient.From>; /** * Registers a new entity with the runner. */ readonly registerEntity: , RX>(entity: Entity, handlers: Effect.Effect, options?: { readonly maxIdleTime?: Input | undefined; readonly concurrency?: number | "unbounded" | undefined; readonly mailboxCapacity?: number | "unbounded" | undefined; readonly mailboxMetrics?: boolean | undefined; readonly disableFatalDefects?: boolean | undefined; readonly defectRetryPolicy?: Schedule.Schedule | undefined; readonly spanAttributes?: Record | undefined; }) => Effect.Effect | Rpc.Middleware | Exclude>; /** * Registers a new singleton with the runner. */ readonly registerSingleton: (name: string, run: Effect.Effect, options?: { readonly shardGroup?: string | undefined; }) => Effect.Effect; /** * Sends a message to the specified entity. */ readonly send: (message: Message.Incoming) => Effect.Effect; /** * Sends an outgoing message */ readonly sendOutgoing: (message: Message.Outgoing, discard: boolean) => Effect.Effect; /** * Notify sharding that a message has been persisted to storage. */ readonly notify: (message: Message.Incoming, options?: { readonly waitUntilRead?: boolean | undefined; }) => Effect.Effect; /** * Reset the state of a message. When options.expectedReplyId is provided, * reset only if it is still the latest reply. Otherwise reset unconditionally. */ readonly reset: (requestId: Snowflake.Snowflake, options?: { readonly expectedReplyId?: Snowflake.Snowflake | undefined; }) => Effect.Effect; /** * Trigger a storage read, which will read all unprocessed messages. */ readonly pollStorage: Effect.Effect; /** * Retrieves the active entity count for the current runner. */ readonly activeEntityCount: Effect.Effect; }>; /** * Service that registers entities and singletons, routes messages to owned * shards, generates runner-local snowflake ids, and polls * storage for persisted work. * * **When to use** * * Use to access or provide cluster routing, shard ownership, entity * registration, singleton registration, and persisted-work polling. * * @stability unstable * @category services * @since 4.0.0 */ export declare class Sharding extends Sharding_base { } /** * Layer that constructs the `Sharding` service from sharding configuration, * runner communication, message storage, runner storage, runner health, the * snowflake generator, and the entity reaper. * * **When to use** * * Use when you need to assemble a cluster sharding runtime from explicit * sharding configuration, runner communication, message storage, runner * storage, and runner health layers. * * **Details** * * The layer provides the `Sharding` service and installs its own snowflake * generator and entity reaper. Callers still provide `ShardingConfig`, * `Runners`, `MessageStorage`, `RunnerStorage`, and `RunnerHealth`. * * **Gotchas** * * Persisted messages require a non-no-op `MessageStorage`; if this layer is * provided with `MessageStorage.layerNoop`, persisted sends defect. * * @see {@link Sharding} for the service provided by this layer * * @stability unstable * @category layers * @since 4.0.0 */ export declare const layer: Layer.Layer; export {}; //# sourceMappingURL=Sharding.d.ts.map