Skip to content

Cluster.Docker reference

Source: packages/effect-cluster/src/Docker/Database.ts

The database an Effect Cluster coordinates through, on a Docker swarm, as an Cluster.Database Layer: Postgres as a one-replica swarm service with its data on a named volume, on an overlay network the pool’s runners join. The Docker engine must be in swarm mode (docker swarm init).

One Postgres on one disk is meant for development and tests.

export const Database = ClusterDocker.Database("Cluster");

Source: packages/effect-cluster/src/Docker/SwarmPool.ts

Run a pool of Effect Cluster runners on a Docker swarm: a swarm service whose tasks host every Cluster.Entity given this pool, on the database’s overlay network. Runners find each other through the database and talk on the network; the gateway is served on the same network. Requires an Cluster.Database on a Docker network — ClusterDocker.Database.

Every entity given the same pool shares it: declare the pool once and provide them to each class.

export const Database = ClusterDocker.Database("Cluster");
export const Default = ClusterDocker.SwarmPool("Default", { replicas: 2 }).pipe(
Layer.provide(Database),
);