Skip to content

EntityAddress.ts

The EntityAddress module defines the value used to locate an entity within a cluster. An address combines the entity type, entity id, and shard id so messages, persisted envelopes, workflow executions, and entity managers can agree on the same routing target.

Since v4.0.0



Constructs an EntityAddress from a shard ID, entity type, and entity ID.

When to use

Use to create the routing target for a known entity type and entity id after resolving that id to the ShardId assigned by the entity’s shard group.

Details

The returned EntityAddress stores the supplied shardId, entityType, and entityId. Equality and hashing include all three fields.

Gotchas

make does not choose the shard for an entity. Use the same shard group logic as the entity definition; a different shardId makes a different address even when the entity type and entity id match.

See

  • EntityAddress for the equality, hashing, and string formatting behavior of constructed addresses
  • ShardId for the shard identifier included in the address

Signature

declare const make: (options: {
readonly shardId: ShardId
readonly entityType: EntityType
readonly entityId: EntityId
}) => EntityAddress

Source

Since v4.0.0

Represents the unique address of an entity within the cluster.

Signature

declare class EntityAddress

Source

Since v4.0.0

Formats the entity type, entity id, and shard id as a readable address.

Signature

declare const toString: () => string

Source

Since v4.0.0

Compares entity addresses by entity type, entity id, and shard id.

Signature

declare const [Equal.symbol]: (that: EntityAddress) => boolean

Source

Since v4.0.0

Computes a structural hash from the entity type, entity id, and shard id.

Signature

declare const [Hash.symbol]: () => number

Source

Since v4.0.0

Marks this value as a cluster entity address for runtime guards.

Signature

readonly [TypeId]: "~effect/cluster/EntityAddress"

Source

Since v4.0.0