mix ash_clickhouse.helpers (AshClickhouse v0.5.2)

Copy Markdown View Source

Shared helpers for the ash_clickhouse mix tasks.

Both mix ash_clickhouse.setup and mix ash_clickhouse.migrate need to enumerate the app's compiled modules to find AshClickhouse repos and resources. Centralising this keeps the two tasks consistent and avoids duplicated discovery logic.

Summary

Functions

Returns the configured Mix.Project.config()[:app] name, or nil if none.

Returns every module compiled into the app that declares __ash_clickhouse_repo__/0 (i.e. AshClickhouse repos).

Returns every module compiled into the app that declares __ash_clickhouse__/1 (i.e. AshClickhouse resources).

Starts the ClickHouse connection for each repo.

Functions

app_name()

@spec app_name() :: atom() | nil

Returns the configured Mix.Project.config()[:app] name, or nil if none.

find_repos()

@spec find_repos() :: [module()]

Returns every module compiled into the app that declares __ash_clickhouse_repo__/0 (i.e. AshClickhouse repos).

find_resources()

@spec find_resources() :: [module()]

Returns every module compiled into the app that declares __ash_clickhouse__/1 (i.e. AshClickhouse resources).

start_clients(repos, overrides \\ [])

@spec start_clients(
  [module()],
  keyword()
) :: :ok

Starts the ClickHouse connection for each repo.

Mix tasks (mix ash_clickhouse.setup, mix ash_clickhouse.migrate) run queries through the repos, so the client must be registered even when the application itself is not started.