Dowser.Client.Config (Dowser.Client v0.1.1)

View Source

Bundles everything needed to reach one search backend: its :endpoint, :auth, and the HTTP/JSON/codec adapters and options to use.

Build one inline with new/1, or configure named ones at compile time:

config :dowser_client,
  configs: [
    default: [endpoint: "http://localhost:9200", auth: {:basic, "user", "changeme"}],
    logs: [endpoint: "https://logs.internal:9200"]
  ]

resolve/1 — used by Dowser.Client.request/4 on opts[:config] — turns any of the following into a %Config{}:

  • nil — resolves the :default entry from config :dowser_client, configs: [...]. There is no built-in fallback; a :default entry must be configured, or every call site must pass :config explicitly.
  • an atom — looks up that name in the same configs list/map.
  • a map or keyword list — builds an ad-hoc config inline via new/1.
  • a %Config{} — returned as-is.

:http_adapter, :json_adapter and :codec_adapter default to nil on the struct itself; when unset, Dowser.Client.Request resolves them at request time from config :dowser_client, :http_adapter | :json_adapter | :codec_adapter, falling back to the built-in Httpc/Native/ Dowser.Client.Codec.Default — so they can be changed at runtime (e.g. in config/runtime.exs), not just at compile time.

Summary

Functions

fetch_configuration(name)

new(opts)

resolve(config)