Fork me on GitHub
#integrant
<
2024-04-01
>
Dameon15:04:40

I’m wondering if there’s a way to swap out init keys based on the profile being run? I know it’s possible to pass different values to an init key based on the profile, like passing different refs or strings to a DB config. What I’m interested in is using a separate implementation of the init-key based on the profile. For example a :dev/file-server that just writes to disk, and a :prod/file-server that actually sends the file to a file server over the network. What it seems to be doing now is just initializing both. Apologies if this is a common question, I searched for a while and couldn’t find anything.

lassemaatta17:04:15

I think https://github.com/weavejester/integrant/issues/81#issuecomment-615906828 comment describes how you can use derived keys to do what you want. You specify some abstract root keyword (e.g. :application/file-server or whatever), refer to it in all those components that need a file server dependency and finally derive both :dev/file-server and :prod/file-server from the common root keyword. Checkout derived keys and composite keys in the integrant readme.

👍 1