Giter Club home page Giter Club logo

Comments (8)

Strech avatar Strech commented on August 23, 2024 1

Yes, configuration will be scoped to the client, like this get_env(:the_app, __MODULE__, :registry_url) and __MODULE__ will be resolved per-client.

I will open PR and mention you there 👍🏼

from avrora.

juanperi avatar juanperi commented on August 23, 2024

btw, I saw other issues dealing with compile time configuration and fixes. But I haven't seen anything related to fully runtime (startup) configuration

from avrora.

Strech avatar Strech commented on August 23, 2024

Hey @juanperi seems like there are some demand on runtime 😆

Since we have new configuration option otp_app: :name I think we can extend its usage and take most of the settings if they set from the OTP app and if not – fallback to default value.

Then the chain would be

  1. If otp_app is set and schemas_path is set – apply Application.app_dir
  2. If otp_app is set and schemas_path is not – take Application.get_env(<otp_app>, __MODULE__, :schemas_path)
  3. If otp_app is not set and schemas_path is set – take schemas_path
  4. If otp_app is not set and schemas_path is not set – take default value

And the same-ish logic for rest options, WDYT?

from avrora.

juanperi avatar juanperi commented on August 23, 2024

that would still allow for 1 client for otp app, right?
What if instead we allow options to be passed when the start_link is called on the CustomAvroClient?

      children = [
        {TheApp.AvroClient, [schemas_path: xxxx, registry_url: yyyyy]}
      ]

      {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)

That way, the initialization of the process will be able to pass the config, and make it fully independent of any compile time dependency, and allow you to have as many configurations as you need.

The usecase i have, is that I build a single docker image for QA and Prod. I need to point the client to point to QA when started in QA mode, and in production mode to a different schema.

The otp app might work in this case, but isn't it more straightforward and flexible to just pass the parameters when starting the supervision tree? The developer is in charge of where that config is coming from.

from avrora.

Strech avatar Strech commented on August 23, 2024

Yeah, initially the supervision tree args were complicated due to the Private client, but I guess I can take a look again into it. So will try that way

from avrora.

juanperi avatar juanperi commented on August 23, 2024

can you expand a bit in the complication?

from avrora.

Strech avatar Strech commented on August 23, 2024

Also with Application.get_env I've suggested you still have control over environment, since you will be able to do it this way

# config/test.exs
config :the_app, TheApp.AvroClient, 
  registry_url: "http://xxx.xx"
defmodule TheApp.AvroClient do
  use Avrora.Client,
    otp_app: :the_app
end

because the resolution will happen in runtime, you can have different config per environment. I think it should work for you.

P.S Complications there because Avrora is not running Avrora.Config as a process to hold the config from supervision setup

from avrora.

juanperi avatar juanperi commented on August 23, 2024

you are totally correct. that would work if you automatically scope the config to the current client as in your last example, we could have multiple clients, with different configurations.
That would be good enough for having custom configurations per client

from avrora.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.