Runtime dependency detection for optional integrations.
This module provides a unified interface for checking whether optional dependencies (Broadway, Flow, CubDB, Ecto) are available at runtime. It is used internally by integration modules to provide clear error messages when a dependency is missing.
Configuration
Optional dependencies can be explicitly disabled via application config:
config :ex_data_sketch, :integrations,
broadway: falseSetting an integration to true does not override compile-time
availability. If the dependency is not loaded, true has no effect.
Setting to false always disables the integration regardless of
whether the dependency is loaded.
When not explicitly configured, availability defaults to whether the
dependency is loaded at compile time. This means adding a dependency
to mix.exs after compilation requires a full recompile
(mix deps.compile) for the availability check to return true.
Supported Integrations
| Integration | Dependency | Always available? |
|---|---|---|
| GenStage | OTP (always) | Yes |
| Broadway | :broadway | No |
| Flow | :flow | No |
| CubDB | :cubdb | No |
| Ecto | :ecto_sql | No |
| Mnesia | OTP (always) | Yes |
| ETS | OTP (always) | Yes |
| DETS | OTP (always) | Yes |
| OpenTelemetry | :opentelemetry_api | No |
Summary
Functions
Returns whether the Broadway library is available.
Returns whether the CubDB library is available.
Returns whether the Ecto library is available.
Returns whether the Flow library is available.
Returns whether the OpenTelemetry API library is available.
Raises an error if Broadway is not available.
Raises an error if CubDB is not available.
Raises an error if Ecto is not available.
Raises an error if Flow is not available.
Raises an error if OpenTelemetry is not available.
Functions
@spec broadway_available?() :: boolean()
Returns whether the Broadway library is available.
Checks compile-time availability and runtime configuration. Setting
broadway: true in config does not override compile-time unavailability.
Examples
iex> is_boolean(ExDataSketch.Integration.broadway_available?())
true
@spec cubdb_available?() :: boolean()
Returns whether the CubDB library is available.
Checks compile-time availability and runtime configuration. Setting
cubdb: [enabled: true] in config does not override compile-time
unavailability.
Examples
iex> is_boolean(ExDataSketch.Integration.cubdb_available?())
true
@spec ecto_available?() :: boolean()
Returns whether the Ecto library is available.
Checks compile-time availability and runtime configuration. Setting
ecto: [enabled: true] in config does not override compile-time
unavailability.
Examples
iex> is_boolean(ExDataSketch.Integration.ecto_available?())
true
@spec flow_available?() :: boolean()
Returns whether the Flow library is available.
Checks compile-time availability and runtime configuration. Setting
flow: true in config does not override compile-time unavailability.
Examples
iex> is_boolean(ExDataSketch.Integration.flow_available?())
true
@spec opentelemetry_available?() :: boolean()
Returns whether the OpenTelemetry API library is available.
Checks compile-time availability and runtime configuration.
Examples
iex> is_boolean(ExDataSketch.Integration.opentelemetry_available?())
true
@spec require_broadway!() :: :ok
Raises an error if Broadway is not available.
Provides a clear error message directing the user to add the dependency.
Examples
iex> ExDataSketch.Integration.require_broadway!()
:ok
# When Broadway is not available:
# ** (RuntimeError) Broadway integration requires the :broadway dependency.
# Add {:broadway, "~> 1.0"} to your mix.exs dependencies.
@spec require_cubdb!() :: :ok
Raises an error if CubDB is not available.
Provides a clear error message directing the user to add the dependency.
Examples
iex> ExDataSketch.Integration.require_cubdb!()
:ok
# When CubDB is not available:
# ** (RuntimeError) CubDB persistence requires the :cubdb dependency.
# Add {:cubdb, "~> 2.0"} to your mix.exs dependencies.
@spec require_ecto!() :: :ok
Raises an error if Ecto is not available.
Provides a clear error message directing the user to add the dependency.
Examples
iex> ExDataSketch.Integration.require_ecto!()
:ok
# When Ecto is not available:
# ** (RuntimeError) Ecto persistence requires the :ecto_sql dependency.
# Add {:ecto_sql, "~> 3.0"} to your mix.exs dependencies.
@spec require_flow!() :: :ok
Raises an error if Flow is not available.
Provides a clear error message directing the user to add the dependency.
Examples
iex> ExDataSketch.Integration.require_flow!()
:ok
# When Flow is not available:
# ** (RuntimeError) Flow integration requires the :flow dependency.
# Add {:flow, "~> 1.2"} to your mix.exs dependencies.
@spec require_opentelemetry!() :: :ok
Raises an error if OpenTelemetry is not available.
Provides a clear error message directing the user to add the dependency.
Examples
iex> ExDataSketch.Integration.require_opentelemetry!()
:ok
# When OpenTelemetry is not available:
# ** (RuntimeError) OpenTelemetry integration requires the :opentelemetry_api dependency.
# Add {:opentelemetry_api, "~> 1.0"} to your mix.exs dependencies.