How to setup configuration values for simple_one_to_one processes

For a stand-alone GenServer (or process) we may easily read values set in config.exs, for example:

use Mix.Config

    config :gateway,
         debug: 1,
  media_folder: "C:/Elixir/gateway/media/",
   delay_media: 50,
    delay_text: 50,
        mobile: "2348012345678" 

and use them as (global) module arguments:

defmodule TL.Utils do

## Variables
  @mobile Application.get_env(:gateway, :mobile)
  @profile_pics Path.join([Application.get_env(:gateway, :media_folder), "profile-pics"])
  @media_folder Path.join([Application.get_env(:gateway, :media_folder), Application.get_env(:gateway, :mobile)])
  @delay_media Application.get_env(:gateway, :delay_media)
  @delay_text Application.get_env(:gateway, :delay_text)
  @debug Application.get_env(:gateway, :debug)

## Variable Accessors
  def mobile, do: @mobile
  def media_folder, do: @media_folder <> "/"
  def profile_pics, do: @profile_pics <> "/"
  def delay_media, do: @delay_media
  def delay_text, do: @delay_text
  def debug, do: @debug

end

How may we set (global) module-level configuration on start-up of each simple_one_for_one instance?

1 Like