Surgex.RepoHelpers (Surgex v5.0.0) View Source

Tools for dynamic setup of Ecto repo opts.

NOTE: Deprecated in favor of Elixir 1.9 runtime configuration.

Link to this section Summary

Functions

Sets application_name to the value of APP_NAME env var.

Sets repo options from env vars starting with specified prefix.

Sets repo database pool size from specified env var.

Sets repo database pool size from specified env var only if Phoenix server is configured to run.

Sets repo database ssl enable from specified env var.

Sets repo database URL from specified env var.

Link to this section Functions

Link to this function

set_application_name(opts)

View Source

Sets application_name to the value of APP_NAME env var.

Link to this function

set_opts(opts, env_prefix \\ :database)

View Source

Sets repo options from env vars starting with specified prefix.

Examples

iex> System.put_env("DATABASE_URL", "postgres://localhost")
iex> System.put_env("DATABASE_SERVER_POOL_SIZE", "30")
iex> System.put_env("DATABASE_SSL", "true")
iex> Application.put_env(:phoenix, :serve_endpoints, true)
iex>
iex> final_opts = Surgex.RepoHelpers.set_opts([])
iex>
iex> Keyword.get(final_opts, :url)
"postgres://localhost"
iex> Keyword.get(final_opts, :pool_size)
30
iex> Keyword.get(final_opts, :ssl)
true
Link to this function

set_pool_size(opts, env)

View Source

Sets repo database pool size from specified env var.

Link to this function

set_server_pool_size(opts, env)

View Source

Sets repo database pool size from specified env var only if Phoenix server is configured to run.

Sets repo database ssl enable from specified env var.

Sets repo database URL from specified env var.