0

I have defined a InfluxConnection module

defmodule MyModule.InfluxConnection do
  use Instream.Connection, otp_app: :my_app

  def safe_query(query, opts \\ [log: false]) ...
  def safe_write(data, opts \\ [log: false]) ...
end

and the config is

config :my_app, MyModule.InfluxConnection,
  auth: ....
  database: System.get_env("INFLUXDB_DB") || "price_service",
  host: System.get_env("INFLUX_HOSTNAME") || "localhost",
  pool: [max_overflow: 10, size: 50],
  port: 8086,
  scheme: "http",
  writer: Instream.Writer.Line

after running the following two function in dev environment i am getting two different result

iex(7)> Application.get_env(:my_app, MyModule.InfluxConnection)
[
  auth: [method: :basic, username: "local_user", password: ""],
  database: "price_service",
  host: "influxdb",
  pool: [max_overflow: 10, size: 50],
  port: 8086,
  scheme: "http",
  writer: Instream.Writer.Line
]
iex(8)> Instream.Connection.Config.runtime(:my_app, MyModule.InfluxConnection, nil)
[
  host: "localhost",
  loggers: [{Instream.Log.DefaultLogger, :log, []}],
  port: 8086,
  scheme: "http",
  writer: Instream.Writer.Line
]

but the result of these two function should be same, I think somehow my Instream.Connection is not picking the defined config in dev.exs

help me out, please i am stuck here. what could be possible error, i am running influxdb in docker.

  • Are you using other environment-specific configs? Like `config/prod.exs`? Remember that `config.exs` is evaluated at compile-time (not runtime). I would try moving all of your config to the `config/runtime.exs` and see if anything changes. – Everett Aug 26 '22 at 15:46
  • yes i am using three `config/dev.exs, prod.exs, test.exs` k – Aadarsh Bishen Aug 26 '22 at 16:37
  • which config file `config.exs is evaluated at compile-time (not runtime).` is it my project config file or Instream config file – Aadarsh Bishen Aug 26 '22 at 17:10
  • `config.exs` and the env-specific files it includes (`dev.exs`, `prod.exs`, and `test.exs`) are evaluated at compile-time. `config/runtime.exs` is evaluated at runtime. Try moving all config to the `runtime.exs` and see if anything changes. – Everett Aug 26 '22 at 23:49

0 Answers0