Fork me on GitHub
#integrant
<
2023-05-24
>
pavlosmelissinos19:05:10

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 ๐Ÿงต

pavlosmelissinos19:05:20

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 configuration

pavlosmelissinos19:05:27

I 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?

weavejester15:05:06

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.

๐Ÿ™ 4
pavlosmelissinos15:05:04

Nice, I'll check it out, thanks for integrant @U0BKWMG5B!

weavejester15:05:19

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.

๐Ÿ‘ 2