ExDataSketch.Integration (ExDataSketch v0.9.0)

Copy Markdown View Source

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: false

Setting 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

IntegrationDependencyAlways available?
GenStageOTP (always)Yes
Broadway:broadwayNo
Flow:flowNo
CubDB:cubdbNo
Ecto:ecto_sqlNo
MnesiaOTP (always)Yes
ETSOTP (always)Yes
DETSOTP (always)Yes
OpenTelemetry:opentelemetry_apiNo

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

broadway_available?()

@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

cubdb_available?()

@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

ecto_available?()

@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

flow_available?()

@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

opentelemetry_available?()

@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

require_broadway!()

@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.

require_cubdb!()

@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.

require_ecto!()

@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.

require_flow!()

@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.

require_opentelemetry!()

@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.