View Source KafkaEx.Support.OptionalDeps (kafka_ex v1.0.0)

Startup-time validation for optional-dependency modules.

A handful of kafka_ex features (SASL mechanisms, compression algorithms) rely on libraries marked optional: true in mix.exs so apps that don't need them don't pay the install cost. The downside is that a misconfigured app compiles and boots, only to UndefinedFunctionError on first produce or first auth.

This module crosses that surface into startup: given the user's runtime configuration, ensure the backing modules are loadable and raise with a concrete mix.exs snippet otherwise.

Summary

Functions

Validates that all optional-dep modules the configuration implies are actually loaded. Raises ArgumentError with a mix.exs migration snippet on the first missing dep; otherwise returns :ok.

Functions

@spec validate!(KafkaEx.Auth.Config.t() | nil) :: :ok

Validates that all optional-dep modules the configuration implies are actually loaded. Raises ArgumentError with a mix.exs migration snippet on the first missing dep; otherwise returns :ok.

The auth argument should be the resolved %AuthConfig{} (or nil) that the Client will pass to NetworkClient. Compression checks are driven by the :required_compression application-env key — setting it is optional; it exists so apps that rely on compression can fail at boot instead of at first produce.

# mix.exs has :snappyer in deps
config :kafka_ex,
  required_compression: [:snappy]