Giter Site home page Giter Site logo

Comments (6)

weavejester avatar weavejester commented on May 21, 2024 1

So, if I'll replace :data/store with :sql/store all refs to :data/store will be properly resolved?

Yes, that's right. A reference like #ig/ref :data/store will look for a key that derives from :data/store.

It's common practice to have both test and production services derive from the same base key, so that you can transparently swap in fake services for testing without altering any other part of the configuration.

I think you want to use the same configuration map in tests as in prod.

Whether you change the keys in the configuration, or change the hierarchy, the resulting system map is the same, and different to production.

My preference is to change the configuration directly, as not only is that simpler (as we don't have to worry about local hierarchies), but it also allows test services to be configured separately to production services.

For example, you might have a fake emailer service that writes to a file, and the filename could be part of the config:

{:fake/emailer {:filename "emails.log"}}

And in production:

{:real/emailer {:smtp "example.com"}}

from integrant.

weavejester avatar weavejester commented on May 21, 2024

It's an interesting idea, but why not just change the configuration to use the test key? The effect will be the same without the need to mess around with the hierarchy.

from integrant.

kirillsalykin avatar kirillsalykin commented on May 21, 2024

It should be changed more than in one place, right?
Also as I mentioned - i dont want the system-map to be changed.

from integrant.

weavejester avatar weavejester commented on May 21, 2024

It should be changed more than in one place, right?

What do you mean? You only need to change the keys you want to replace. Everything else, including references, can remain the same.

Also as I mentioned - i dont want the system-map to be changed.

Do you mean the configuration map? The system map is the return value of ig/init.

Also why don't you want it to be changed?

from integrant.

kirillsalykin avatar kirillsalykin commented on May 21, 2024

What do you mean? You only need to change the keys you want to replace. Everything else, including references, can remain the same.

So, if I'll replace :data/store with :sql/store all refs to :data/store will be properly resolved?

(def system-map
 {:adapter/jetty {:port 8080, :handler (ig/ref :handler/greet)}
   :sql/store {:jdbc-url "some-yrl}
   :handler/greet {:name "Alice",  :data-store (ig/ref :data/store)}})

if so - it may solve my issues.

Do you mean the configuration map? The system map is the return value of ig/init.

Yes, sorry, I meant configuration map.

Also why don't you want it to be changed?

I think you want to use the same configuration map in tests as in prod.

from integrant.

kirillsalykin avatar kirillsalykin commented on May 21, 2024

Makes sense.

Thanks for clarification!

Closing issue and PR.

from integrant.

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.