Alternera.PluginHosts.Starter (alternera_plugin_hosts v0.9.0)

Copy Markdown View Source

Starts one kind's configured hosts (PluginHosts.configured/1), each once its tenant slug names a tenant (Plugin.Host.tenant_id_for_slug/1): the pool (PluginHosts.pool_child/3) runs under the kind's DynamicSupervisor of pools (pools/1) and carries the tenant's id.

Each lookup runs in a process of its own, monitored, so a slow database holds up neither this process nor the other entries. An entry whose slug is not looked up is asked again after 1 second, the wait doubling to at most 30. A plugin package starts before the proxy's database, so at boot the answer is usually :not_started, logged at debug: no error. No such tenant is logged as a warning and a disabled tenant at info, each once until the answer changes, and asked again on the same schedule, so a tenant created, given the slug or enabled later brings its host up. Any other failure (the read failed, the lookup crashed) is logged as a warning on every attempt.

The slug is looked up once: a host keeps the tenant it started with until it restarts. Should this process crash, it starts again and looks up every entry; a pool that is already running stays as it is.

Summary

Functions

Returns a specification to start this module under a supervisor.

The DynamicSupervisor kind's pools run under.

The child spec of kind's DynamicSupervisor of pools.

kind's configured hosts whose tenant is not looked up yet, each as {tenant slug, name}.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

pools(kind)

@spec pools(module()) :: atom()

The DynamicSupervisor kind's pools run under.

pools_child_spec(kind)

The child spec of kind's DynamicSupervisor of pools.

start_link(kind)

waiting(kind)

@spec waiting(module()) :: [{String.t(), String.t()}]

kind's configured hosts whose tenant is not looked up yet, each as {tenant slug, name}.