integrant

pavlosmelissinos 2023-05-24T19:32:10.873089Z

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

pavlosmelissinos 2023-05-24T19:37:20.510459Z

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

pavlosmelissinos 2023-05-24T19:40:27.247649Z

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?

weavejester 2023-05-25T15:14:06.733709Z

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.

๐Ÿ™ 2
pavlosmelissinos 2023-05-25T15:20:04.347809Z

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

weavejester 2023-05-25T15:21:19.529149Z

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.

๐Ÿ‘ 1