Is possible to use the mapping in duct_hierachy.edn
to devise a group of keys that should be instanciated by passing a single key (the group's key) as a command line argument? If so, how would that look like?
If not, I guess I have to "implement" a group key that does nothing else than having dependencies, right?
@branch14 Yes, it is possible. Let's say you want to call your group key :duct/example-group-key
. And your individual keys :duct.example-group-key/key-one
, :duct.example-group-key/key-two
and :duct.example-group-key/key-three
.
You add the following to your duct_hierarchy.edn
file:
{:duct.example-group-key/key-one [:duct/example-group-key]
:duct.example-group-key/key-two [:duct/example-group-key]
:duct.example-group-key/key-three [:duct/example-group-key]}
And then you add :duct.example-group-key/key-one
, :duct.example-group-key/key-two
and :duct.example-group-key/key-three
in config.edn
as regular top level keys.
In dev
mode all top level keys will be always initiated, so you won't see the effect of the previous configuration. But if you build the uberjar and run it without any additional parameters (e.g.,`java -jar my-uberjar.jar`), you will see your individual keys will not be initiated. On the other hand, if you run the uberjar with java -jar my-uber-jar.jar duct/daemon :duct/example-group-key
[1] you will see that all of your individual keys are initiated.
You could even derive your group key from :duct/daemon
or :duct/server
if you wanted to be automatically initiated without specifying it in the command line (see https://github.com/duct-framework/duct/wiki/Configuration#top-level-components)
[1] You need to include :duct/daemon
because once you specify a key to be initiated in the command line, the default :duct/daemon
key is no longer added automatically (assuming you don't touch the -main
function created by Duct).Thx @iarenaza for the great writeup!