duct

2019-11-06T01:27:30.171700Z

In theory that should work…

2019-11-06T01:28:34.172800Z

Ah, I see the problem, @ccann. The :duct.core/requires key wasn’t designed to be used outside of Duct core, so it’s being overwritten. I need to create a proper public key for requirements.

2019-11-06T01:30:19.174200Z

Try creating a key: :<http://your.app/requires|your.app/requires>. Since it won’t be automatically removed, you can make it derive from :duct/const to have Integrant ignore it.

2019-11-06T01:30:39.174700Z

I’ll create a proper requires key that’s designed for public use.

2019-11-06T01:30:58.175100Z

In the next Duct version. Feel free to add an issue to remind me.

2019-11-06T10:47:08.177300Z

@weavejester: I think I ran into the same problem as @ccann after our chat yesterday; but I’d tried it in our app rather than a minimal test case. However I’ve now got it failing in a minimal test case; and it seems to fail even with the solution you’re suggesting. Here’s my minimal example:

(require '[duct.core :as duct])

  (derive :example.profile/b-one :duct/profile)
  (derive :example.profile/a-two :duct/profile)

  (derive :<http://my.app/requires|my.app/requires> :duct/const)

  (duct/prep-config {:example.profile/b-one {:a {:replace-me :init}
                                             :b [:b-one]}

                     :example.profile/a-two {:a {:replace-me :replaced}
                                             :b [:b-two]
                                             :c [:c-two]
                                             :<http://my.app/requires|my.app/requires> (ig/ref :example.profile/b-one)}}
                    #{:example.profile/b-one :example.profile/a-two})

2019-11-06T10:49:40.179600Z

The profiles are named b-one a-two to guarantee the sort ordering is the opposite to the dependency order; and I’d like to see the order be [one two] (where two) takes precedence. I expect to see the result contain {:a {replace-me :replaced} rather than {:a replace-me :init} which is what I get.

2019-11-06T10:50:03.180100Z

complete result output is:

{:a {:replace-me :init},
 :b [:b-two :b-one],
 :c [:c-two],
 :<http://my.app/requires|my.app/requires> {:key :example.profile/b-one}}

2019-11-06T10:50:19.180500Z

Did I understand correctly what you meant by derive your own requires key?

2019-11-06T10:56:02.181500Z

It looks like duct/prep-config doesn’t walk in dependency order. duct/build-config seems to yield the same too.

2019-11-06T10:57:10.182300Z

hmmm something must be up; possibly with my example… build-config calls ig/init so not sure why it’s not obeying the dependency order.

2019-11-06T10:59:57.183100Z

the result of ig/prep inside build-config is:

#:example.profile{:b-one
                  {:a {:replace-me :init},
                   :b [:b-one],
                   :duct.core/requires {:key :duct.profile/base}},
                  :a-two
                  {:a {:replace-me :replaced},
                   :b [:b-two],
                   :c [:c-two],
                   :<http://my.app/requires|my.app/requires> {:key :example.profile/b-one},
                   :duct.core/requires {:key :duct.profile/base}}}

2019-11-06T11:07:40.184900Z

Ok, I think I see what the problem is. When we call fold-modules we’ve forgotten the dependencies between profiles/modules. So the functions then evaluate in key-comparator order 😞

2019-11-06T11:10:32.186300Z

We lose that info at ig/init in build-config. So to summarise I think the profiles are initialised in the right order; but aren’t folded/applied to the meta-system in the right order in fold-modules.

2019-11-06T14:46:52.190900Z

@rickmoynihan The dependencies should be held in the metadata of the system, so when ig/fold is called in fold-modules, the dependency order should be correct. I’ll look into this and try to figure out what’s going wrong, but I won’t have much time until Sunday. Feel free to open an issue to remind me.

2019-11-06T14:48:52.192100Z

ahh thanks for that James, that’s helpful… I’ll take a look and try and see if I can see what’s going on… I’ll open an issue when I’ve done a bit more digging for sure :thumbsup:

2019-11-06T14:49:55.192900Z

Oh, and while you’re here, just to get some feedback - do you use any Duct modules, or just profiles and components?

2019-11-06T14:55:28.195900Z

Yeah we use the following:

:duct.module/logging {}
 :duct.module.web/api {}
 :duct.module.web/site {}

 :app.module.project/inject-all {} 
The final one is the only module we have that is ours at the minute… it essentially injects an identifier/slug for the project into every component.

2019-11-06T14:56:07.196700Z

Though I don’t think any of the above are configured through the module config… they’re just used to bring in the defaults; and then we override the bits we need but at a component level, rather than module level.

2019-11-06T14:57:34.198Z

ataraxy might use the module config… though no I think even with that we strayed out of the easy config, and use the component layer to configure it.

2019-11-06T14:58:09.198300Z

yeah all ataraxy keys are configured through :duct.router/ataraxy

2019-11-06T14:58:43.198600Z

Thanks; that’s pretty useful.

2019-11-06T15:02:30.200200Z

I think with ataraxy we moved away from the module config primarily because it enforced a convention of having handlers in a handler namespace. And we prefer to have a project structured by feature rather than layer. I think we’ve spoken about that before.

2019-11-06T15:21:39.202800Z

@weavejester Ok I think I see the problem now… Which is I think essentially what you said earlier about :duct.core/requires not being designed to be used outside of duct… however the reason that creating your own :<http://your.app/requires|your.app/requires> key doesn’t work is because it’s not the requires key that’s special; but anything deriving deriving from :duct/profile gets all of its refs deactivated and made into InertRef’s.

2019-11-06T15:22:38.203100Z

This happens in the postwalk here:

2019-11-06T15:24:23.204400Z

I’ll write this up on an issue after I’ve got some (late) lunch.

2019-11-06T15:40:52.204600Z

Ah, that makes sense.

2019-11-06T15:41:30.205400Z

Because the refs need to be merged as well, and not resolved right away.

2019-11-06T18:10:32.206Z

@weavejester: I’ve written up the profile issue here: https://github.com/duct-framework/core/issues/31

2019-11-06T19:38:31.207600Z

Thanks for the writeup, @rickmoynihan. I’m interested in your opinions about the possible solution I outlined.

👀 1