duct

richiardiandrea 2021-02-25T19:19:54.002800Z

Hi there, I have a question - I have marked my components with duct/server but then duct/exec receives duct/daemon...does duct/server derive from duct/daemon? Asking because it actually does not seem to launch my servers...if I read the README right it says that they are interchangeable

kwrooijen 2021-02-25T19:32:53.003600Z

if you run your app with :duct/daemon then the :duct/server keys should start yes

richiardiandrea 2021-02-25T19:35:34.003900Z

thank @kevin.van.rooijen what if I don't have that file? probably that's were the problem is...

kwrooijen 2021-02-25T19:37:11.004100Z

Using lein run you should have it. Also if you're creating an uberjar you need ["run" ":duct/compiler"] in your prep-tasks

kwrooijen 2021-02-25T19:37:44.004400Z

uhm sorry, that's not correct

kwrooijen 2021-02-25T19:38:01.004600Z

I think you need the duct middleware in your project.clj :middleware [lein-duct.plugin/middleware]

kwrooijen 2021-02-25T19:42:03.005100Z

If you're using deps.edn then you need to do some extra stuff it get it to work. Haven't done it myself but this should help https://github.com/duct-framework/duct/issues/92

kwrooijen 2021-02-25T19:42:14.005500Z

Good luck!

richiardiandrea 2021-02-25T19:47:38.005700Z

One thing I am a bit unfamiliar is the concept of derivation vs composite keys... If I have something like this in config.edn: [:duct.server/http :infra2.server/pedestal] Would that be automatically started? Cause I am getting a No method in multimethod 'init-key' for dispatch value: :integrant.composite/duct.server.http+infra2.server.pedestal_5851 Do I need to explicitely require the namespaces from my main.clj?

kwrooijen 2021-02-25T19:49:36.006100Z

Basically the way that it works is that a new keyword is created and derived from all the keywords in the vector. https://github.com/weavejester/integrant/blob/b4f77b0fe9618c5d65bf2cafd27510e8e6ba7cdd/src/integrant/core.cljc#L15-L26

kwrooijen 2021-02-25T19:50:08.006500Z

You still have to write an ig/init-key for :infra2.server/pedestal

kwrooijen 2021-02-25T19:50:36.006700Z

Duct will try to find an init-key for either keywords, and if it can find 1 it'll initialize it

richiardiandrea 2021-02-25T19:50:43.006900Z

yep I have that one in place the only missing thing is that it is not required in the main namespace

kwrooijen 2021-02-25T19:51:04.007100Z

In development you mean?

kwrooijen 2021-02-25T19:51:10.007300Z

oh

richiardiandrea 2021-02-25T19:51:12.007500Z

no for prod..

kwrooijen 2021-02-25T19:51:33.007700Z

You mean the namespace where the ig/init-key is defined is not required by main

richiardiandrea 2021-02-25T19:51:38.007900Z

(sorry I inherited this code base and trying to understand the various moving parts also)

richiardiandrea 2021-02-25T19:51:40.008100Z

yeah

kwrooijen 2021-02-25T19:52:15.008300Z

If the namespace is either: infra2.server.pedestal or infra2.server it will automatically be required

kwrooijen 2021-02-25T19:52:39.008700Z

Because it matches the name of the init key

kwrooijen 2021-02-25T19:53:24.008900Z

But if the namespace has a completely different name, it won't be required automatically

richiardiandrea 2021-02-25T19:53:27.009100Z

yeah it's exactly infra2.server containing a ::pedestal key...strange I got that error

kwrooijen 2021-02-25T19:53:56.009300Z

Hmm

kwrooijen 2021-02-25T19:54:42.009500Z

Maybe it won't require it if :duct/server is not derived from :duct/daemon

richiardiandrea 2021-02-25T19:54:53.009700Z

uhm let me try that then

kwrooijen 2021-02-25T19:54:57.009900Z

Because it doesn't need to initialize it

richiardiandrea 2021-02-25T19:55:29.010100Z

I am trying with [:duct/daemon :infra2.server/pedestal]

kwrooijen 2021-02-25T19:55:49.010400Z

I think that should work

richiardiandrea 2021-02-25T19:56:06.010600Z

No method in multimethod 'init-key' for dispatch value: :integrant.composite/duct.daemon+infra2.server.pedestal_5854

richiardiandrea 2021-02-25T19:56:23.010800Z

very weird...I'll have to dig into the code base

kwrooijen 2021-02-25T19:57:35.011Z

It should require the namespace even if it doesn't get initialized

kwrooijen 2021-02-25T19:58:54.012100Z

Sorry I can't think of a reason why it's not requiring 😅

kwrooijen 2021-02-25T19:59:01.012300Z

Unless you're compiling with graalvm

richiardiandrea 2021-02-25T19:59:21.012500Z

well in that piece of code I can't see how composite keys are required..

richiardiandrea 2021-02-25T20:00:33.012700Z

anyways I'll dig...thanks a lot for your help