ObjectStackObjectStack

Cluster

Cluster protocol schemas

Cluster Protocol

Defines the runtime semantics required for ObjectStack to behave correctly

when more than one Node.js process is involved. The protocol layer codifies

intent (scope, delivery, leadership); concrete implementations

(memory, redis, postgres, nats) live in @objectstack/service-cluster.

The full design rationale is in

content/docs/concepts/cluster-semantics.mdx. Read it before changing

any of the enums here — every value has a precise contract that other

subsystems depend on.

Source: packages/spec/src/kernel/cluster.zod.ts

TypeScript Usage

import { ClusterCapabilityConfig, ClusterDriver, ClusterTenantIsolation, EventClusterOptions, EventDeliverySemantics, EventScope, MetadataChangeOperation, ServiceClusterAnnotations, ServiceClusterScope, ServiceLeaderStrategy } from '@objectstack/spec/kernel';
import type { ClusterCapabilityConfig, ClusterDriver, ClusterTenantIsolation, EventClusterOptions, EventDeliverySemantics, EventScope, MetadataChangeOperation, ServiceClusterAnnotations, ServiceClusterScope, ServiceLeaderStrategy } from '@objectstack/spec/kernel';

// Validate data
const result = ClusterCapabilityConfig.parse(data);

ClusterCapabilityConfig

Cluster capability configuration for the stack.

Properties

PropertyTypeRequiredDescription
driverEnum<'memory' | 'redis' | 'postgres' | 'nats' | 'custom'>Cluster transport driver. Defaults to in-memory single-process.
urlstringoptionalDriver-specific connection URL.
useExistingPoolbooleanReuse the main DB pool for the postgres driver.
nodeIdstringoptionalStable node identifier. Auto-generated when absent.
heartbeatMsintegerLeader-election heartbeat interval in milliseconds.
lockTtlMsintegerLeader-election lock TTL in milliseconds (≥ 3× heartbeatMs).
tenantIsolationEnum<'channel-prefix' | 'none'>Channel/key namespacing strategy for multi-tenant deployments.
driverOptionsRecord<string, any>optionalDriver-specific opaque options.

ClusterDriver

Cluster transport driver.

Allowed Values

  • memory
  • redis
  • postgres
  • nats
  • custom

ClusterTenantIsolation

How tenant traffic is separated on shared transports.

Allowed Values

  • channel-prefix
  • none

EventClusterOptions

Per-emit cluster routing & ordering options.

Properties

PropertyTypeRequiredDescription
scopeEnum<'local' | 'cluster' | 'tenant'>Delivery scope. Default local for backward compatibility.
deliverySemanticsEnum<'best-effort' | 'at-least-once' | 'exactly-once'>optionalDelivery guarantee. Default depends on scope.
partitionKeystringoptionalStable key that guarantees emit-order delivery for same-key events.

EventDeliverySemantics

Delivery guarantee offered by the transport.

Allowed Values

  • best-effort
  • at-least-once
  • exactly-once

EventScope

Where the event must be delivered: local process, whole cluster, or tenant-scoped.

Allowed Values

  • local
  • cluster
  • tenant

MetadataChangeOperation

Persistence operation that triggered the change.

Allowed Values

  • create
  • update
  • delete
  • publish

ServiceClusterAnnotations

Service-registration annotations governing cluster behaviour.

Properties

PropertyTypeRequiredDescription
clusterScopeEnum<'node' | 'cluster'>Per-node vs cluster-singleton presence.
leaderStrategyEnum<'leader-elected' | 'partitioned' | 'idempotent-broadcast'>optionalHow the cluster-singleton invariant is maintained.
clusterIdstringoptionalLogical cluster identity used for leader election (defaults to service name).

ServiceClusterScope

Whether this service runs on every node or as a cluster singleton.

Allowed Values

  • node
  • cluster

ServiceLeaderStrategy

How the cluster-singleton invariant is enforced at runtime.

Allowed Values

  • leader-elected
  • partitioned
  • idempotent-broadcast

On this page