PhoenixMicro.Config (PhoenixMicro v1.0.0)

Copy Markdown View Source

Centralised configuration loader and validator for phoenix_micro.

Configuration lives in config/*.exs:

config :phoenix_micro,
  transport: :rabbitmq,
  transports: [
    rabbitmq: [url: "amqp://localhost"],
    kafka: [brokers: [{"localhost", 9092}], group_id: "my_app"],
    nats: [host: "localhost", port: 4222],
    memory: []
  ],
  default_timeout: 5_000,
  default_retry: [max_attempts: 3, base_delay: 500],
  serializer: PhoenixMicro.Serializer.JSON,
  telemetry_enabled: true

Runtime config via {:system, "ENV_VAR"} tuples is also supported.

Summary

Functions

Returns the active (default) transport module atom.

Returns the fully-validated application configuration. Raises NimbleOptions.ValidationError on bad config.

Returns a single top-level config key with an optional default.

Returns the retry options, merging consumer-level overrides with defaults.

Returns the config for a specific transport.

Maps a transport atom name to its implementation module.

Functions

active_transport()

@spec active_transport() :: atom()

Returns the active (default) transport module atom.

get()

@spec get() :: keyword() | map()

Returns the fully-validated application configuration. Raises NimbleOptions.ValidationError on bad config.

get(key, default \\ nil)

@spec get(atom(), term()) :: term()

Returns a single top-level config key with an optional default.

retry_opts(overrides \\ [])

@spec retry_opts(keyword()) :: keyword()

Returns the retry options, merging consumer-level overrides with defaults.

transport_config(transport_name)

@spec transport_config(atom()) :: keyword() | map()

Returns the config for a specific transport.

transport_module(mod)

@spec transport_module(atom()) :: module()

Maps a transport atom name to its implementation module.