I'm trying to derive new components out of other components by prepping the derived ones but that obviously doesn't work because the keys don't exist in the map (so prep-key doesn't run). What's the right way to do that with integrant? Example in ๐งต
Given this configuration
{:aws/config {:x :y}}
I want to end up with something like:
{:aws/s3-client cognitect.aws.client.impl.Client
:aws/sqs-client cognitect.aws.client.impl.Client
...}
I don't need aws/config but I don't mind if it remains there. What I do want is to have the new keys for these specific clients. I also don't want to require them in the configurationI have init-key defmethods for :aws/s3-client and :aws/sqs-client and they work if the keys exist. When the keys don't exist I get the result that I want if I manually assoc the values when loading the config (and before I run ig/init) but that feels like cheating. Is there a way to force integrant to initialize the components (S3 and SQS in the example) even when their keys are missing?
No, not currently. Duct has a layer on top of Integrant that does that; basically there's a pre-processing step where certain keys can modify the configuration. You could do something similar, perhaps adding a method that expands the key or updates the whole configuration.
Nice, I'll check it out, thanks for integrant @weavejester!
No problem! Thanks for posing the question; it's one I thought about a lot when creating Duct, but coming back to it fresh has given me a few ideas.