# `Lightning.Adaptors.Supervisor`
[🔗](https://github.com/OpenFn/lightning/blob/main/lib/lightning/adaptors/supervisor.ex#L1)

Supervises one instance of the adaptors subsystem: the cache, task
supervisor, invalidator, node monitor, channel broadcaster and the
`HighlanderPG`-wrapped scheduler.

Every child, cache, topic and lock name derives from the `:name` opt,
so several instances can run in one BEAM. Production starts one under
`name: Lightning.Adaptors`. The scheduler is a cluster singleton
registered under `global_scheduler_name/1`.

# `cache_name`

```elixir
@spec cache_name(atom()) :: atom()
```

Cachex table name for the supervisor named `name`.

# `channel_broadcaster_name`

```elixir
@spec channel_broadcaster_name(atom()) :: atom()
```

`ChannelBroadcaster` GenServer name for the supervisor named `name`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `client_topic`

```elixir
@spec client_topic(atom()) :: String.t()
```

PubSub topic carrying debounced `adaptors_updated` events for the
supervisor named `name`; see `Lightning.Adaptors.subscribe_to_updates/1`.

# `ensure_started`

```elixir
@spec ensure_started(keyword()) :: {:ok, pid()} | {:error, term()}
```

Starts an instance, or returns the running one. For entry points that
may run either against a cold BEAM or inside the booted application.

# `forget`

```elixir
@spec forget(atom()) :: boolean()
```

Erases the instance's `:persistent_term` entry. Not called
automatically, since `:persistent_term.erase/1` triggers a global GC.

# `global_scheduler_name`

```elixir
@spec global_scheduler_name(atom()) :: {:global, atom()}
```

`:global` Scheduler name for the supervisor named `name`; pass it to
`GenServer.call/3` directly.

# `highlander_name`

```elixir
@spec highlander_name(atom()) :: atom()
```

`HighlanderPG` supervisor name for the supervisor named `name`.

# `invalidator_name`

```elixir
@spec invalidator_name(atom()) :: atom()
```

`Invalidator` GenServer name for the supervisor named `name`.

# `lock_key`

```elixir
@spec lock_key(atom()) :: non_neg_integer()
```

Postgres advisory-lock key for the supervisor named `name`.

# `node_monitor_name`

```elixir
@spec node_monitor_name(atom()) :: atom()
```

`NodeMonitor` GenServer name for the supervisor named `name`.

# `scheduler_name`

```elixir
@spec scheduler_name(atom()) :: atom()
```

Atom form of the Scheduler name for the supervisor named `name`. The
process itself registers under `global_scheduler_name/1`.

# `source`

```elixir
@spec source(atom()) :: :npm | :local
```

Returns the source (`:npm | :local`) of the supervisor named `name`.

# `source_topic`

```elixir
@spec source_topic(atom()) :: String.t()
```

PubSub topic carrying `{:changed, name, source}` events for the
supervisor named `name`.

# `start_link`

```elixir
@spec start_link(keyword()) :: Supervisor.on_start()
```

Starts a supervisor instance.

Options:

  * `:name` - every child name derives from it, defaulting to
    `Lightning.Adaptors.Config.default_instance/0`
  * `:strategy` - `Lightning.Adaptors.Strategy` implementation,
    defaulting to `Lightning.Adaptors.Config.strategy/0`
  * `:lock_key` - `HighlanderPG` advisory-lock key, defaulting to
    `lock_key(name)`
  * `:refresh_interval` - scheduler tick interval in milliseconds,
    defaulting to `Lightning.Adaptors.Config.refresh_interval/0`
  * `:warn_when_empty` - whether the scheduler warns when it boots on an
    empty catalogue that no timer will fill, defaulting to
    `Lightning.Adaptors.Config.warn_when_empty?/0`
  * `:checked_at` - forwarded to the scheduler; see
    `Lightning.Adaptors.Scheduler.start_link/1`

# `strategy`

```elixir
@spec strategy(atom()) :: module()
```

Returns the strategy of the supervisor named `name`. Raises if no
supervisor has started under that name.

# `tasks_name`

```elixir
@spec tasks_name(atom()) :: atom()
```

`Task.Supervisor` name for the supervisor named `name`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
