AtpClient.Config (AtpClient v0.1.6)

Copy Markdown View Source

Resolves configuration for each backend by merging (in increasing precedence):

  1. Library defaults declared in mix.exs under the :env key.
  2. Application configuration under the :atp_client OTP app.
  3. Per-call options passed as a Keyword.t().

Example

In config/config.exs:

config :atp_client, :starexec,
  base_url: "https://starexec.example.org/starexec",
  username: System.get_env("STAREXEC_USER"),
  password: System.get_env("STAREXEC_PASS")

config :atp_client, :isabelle,
  host: "isabelle.example.org",
  port: 9999,
  password: System.get_env("ISABELLE_PASSWORD"),
  local_dir: "/shared/problems",
  isabelle_dir: "/shared/problems",
  session: "HOL"

Any setting may be overridden per call. For instance,

AtpClient.Isabelle.query(theory, session: "Main")

forces the Main session for that single query regardless of what is set in config.exs.

Summary

Functions

Returns the value of key from the resolved settings for backend, falling back to the given default if unset or set to nil.

Returns the value of key from the resolved settings for backend, raising a descriptive ArgumentError if unset or nil.

Returns the fully resolved settings for the given backend as a keyword list.

Types

backend()

@type backend() :: :sotptp | :starexec | :isabelle

Functions

fetch(backend, key, default, opts \\ [])

@spec fetch(backend(), atom(), any(), keyword()) :: any()

Returns the value of key from the resolved settings for backend, falling back to the given default if unset or set to nil.

fetch!(backend, key, opts \\ [])

@spec fetch!(backend(), atom(), keyword()) :: any()

Returns the value of key from the resolved settings for backend, raising a descriptive ArgumentError if unset or nil.

Use this for settings that have no sensible default (for example :base_url, :password, :local_dir).

get(backend, opts \\ [])

@spec get(
  backend(),
  keyword()
) :: keyword()

Returns the fully resolved settings for the given backend as a keyword list.