Config seed provider
Este conteúdo não está disponível em sua língua ainda.
ConfigSeedProvider returns a static list of seed addresses
— from a constructor argument or environment variables. No
discovery logic; what you configure is what you get.
import { Cluster, ClusterOptions } from 'actor-ts/cluster';import { ConfigSeedProvider, ConfigSeedProviderOptions } from 'actor-ts/discovery';
const configSeedProviderOptions = ConfigSeedProviderOptions.create() .withSeeds(['10.0.0.5:2552']) // the designated first node, on every node .withSystemName('my-app');const provider = new ConfigSeedProvider( configSeedProviderOptions,);
const seeds = await provider.lookup();const clusterOptions = ClusterOptions.create() .withHost(host) .withPort(port) .withSeeds(seeds);await Cluster.join(system, clusterOptions);The simplest provider for the simplest case.
One list, every node
Section titled “One list, every node”Give every node the same list, naming the designated first node by the
address it advertises. On that node the list resolves to itself, which the
join drops — Cluster.bootstrap filters the resolved addresses and
Cluster.join filters its seeds — so it is left with nobody to dial and forms
the cluster; every other node dials it. One list, correct everywhere.
A list naming every node is the shape that does not work: after
self-exclusion nobody is left with an empty list, nobody may form the
cluster, and every node waits in joining for a promotion that never comes —
see
the symmetric seed list does not cold-start.
Only the bootstrap’s stable observation, an election among the listed nodes,
breaks that tie. The same holds for the list under
actor-ts.discovery.config.seeds, which is this provider in config form.
Configuration
Section titled “Configuration”type ConfigSeedProviderOptionsType = { seeds: string[]; // "system@host:port" or "host:port" systemName: string; // default system name for seeds omitting it};Two ways to specify:
// Explicit:const configSeedProviderOptions = ConfigSeedProviderOptions.create() .withSeeds(['10.0.0.5:2552']) .withSystemName('my-app');new ConfigSeedProvider( configSeedProviderOptions,);
// From env (CSV):seedsFromEnv('ACTOR_TS_SEEDS', 'my-app');// where ACTOR_TS_SEEDS='10.0.0.5:2552' — more entries only with stable observationPick whichever fits your deployment pattern. Env vars are typical for containerized deployments where the list comes from a config map / orchestrator.
When to use it
Section titled “When to use it”Three good fits:
- Docker Compose — known service names + ports;
actor-ts-1:2552in every service’s environment, the designated first node. - VMs with fixed IPs — three production VMs, each with a stable address.
- Tests — known peer addresses inline in test setup.
When NOT
Section titled “When NOT”Where to next
Section titled “Where to next”- Discovery overview — the bigger picture.
- DNS seed provider — for DNS-based discovery.
- Kubernetes API seed provider — for K8s deployments.
- Aggregate seed provider — combine multiple providers.
- Joining and seeds — how seeds are consumed by the cluster bootstrap.
