Pular para o conteúdo
Português (BR)

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, ConfigSeedProvider, ConfigSeedProviderOptions } from 'actor-ts';
const configSeedProviderOptions = ConfigSeedProviderOptions.create()
.withSeeds(['10.0.0.5:2552', '10.0.0.6:2552', '10.0.0.7:2552'])
.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.

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', '10.0.0.6: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,10.0.0.6:2552'

Pick whichever fits your deployment pattern. Env vars are typical for containerized deployments where the list comes from a config map / orchestrator.

Three good fits:

  1. Docker Compose — known service names + ports; actor-ts-1:2552,actor-ts-2:2552,actor-ts-3:2552 in env.
  2. VMs with fixed IPs — three production VMs, each with a stable address.
  3. Tests — known peer addresses inline in test setup.