Fork me on GitHub
#component
<
2016-11-01
>
josh.freckleton18:11:19

In using component + duct, I'm faced with routing config (stored in local edn file) into non-components. How do I get a constant, immutable directory location (just a string) routed into function that needs it, without making that function a component (since it's never really started and stopped in any meaningful way)

josh.freckleton18:11:05

i could just have a def at the top of that namespace, but that feels like an anti-pattern compared to having it in config

hiredman18:11:27

pass it as an argument

josh.freckleton18:11:35

ah, so then whichever component needs that non-component, will also need the config for the non-component passed in to it

josh.freckleton18:11:32

that seems a bit cumbersome since certain components shouldn't need to care about the non-component's details, right?

josh.freckleton19:11:18

also, i just realized that in my case, the config is a string, a path to a local private key, that could be loaded once and read many times, but if I always just pass that string as a parameter, I'll be doing a ton of IO unecessarily...

josh.freckleton19:11:42

should I make a file IO component?

josh.freckleton19:11:04

and maybe a boundary/protocol specific to that key file?

seancorfield19:11:16

Sounds like you have a “config” Component — when you start it you read the files etc, and then you can read freely from it.

josh.freckleton19:11:24

thanks sean, i'm still trying to wrap my brain around how things should be flowing through components, and systems

josh.freckleton20:11:59

ah I found my problem here: https://github.com/duct-framework/duct/blob/master/duct/src/duct/util/system.clj#L17 notice that components receive config, but endpoints do not.

josh.freckleton20:11:29

woo, solved it. If I include a key in config, i just need to add a dependency to that key. I thought dependencies were just to components, but I guess I can depend on config too