duct

Norman Kabir 2019-12-23T17:54:56.012900Z

Hello. I'm trying to get Duct up and running after researching Component, Mount, Integrant, and Commix. The Duct/Integrant combination is very appealing. However, after following instructions here: https://github.com/duct-framework/duct/wiki/Getting-Started I don't seem to get a Jetty service running on 3000. I've tried the CircleCI tutorial as well. Still no Jetty. Is there a step missing? dev=> (go) :hello.service.example/example-initiated :initiated

kwrooijen 2019-12-23T17:58:22.013300Z

@nkabir This is a better guide: https://github.com/duct-framework/docs/blob/master/GUIDE.rst

kwrooijen 2019-12-23T18:00:30.013900Z

However, this works for me:

lein new duct hello +site +example
cd hello
lein repl
(dev)
(go)

Norman Kabir 2019-12-23T18:15:56.014400Z

@kevin.van.rooijen Thank you! I will give it a try.

Norman Kabir 2019-12-23T18:33:02.016800Z

@kevin.van.rooijen I found the source of the issue. I generated a project folder that includes some common artifacts that I use (e.g. Makefile). Running lein new duct hello --force +site +example on the folder generates different output than when duct is created from scratch. Is that expected behavior?

kwrooijen 2019-12-23T18:50:56.017Z

What do you mean by from scratch?

Norman Kabir 2019-12-23T18:54:52.017900Z

From scratch: create project in new folder With --force: create project in folder that already has content (e.g. Makefile)

kwrooijen 2019-12-23T18:58:17.018700Z

Not sure, I think --force is a lein flag. So that’s not related to duct

Norman Kabir 2019-12-23T19:45:21.019100Z

Ok. I can change the order of my scripts. Thanks for your help!

Norman Kabir 2019-12-23T21:22:40.023700Z

In my effort to understand Duct, I've come across this discussion: https://clojureverse.org/t/want-to-learn-duct-check-out-this-guide-from-circleci/4740 It made sense. But then I found this tutorial that combines ring, reitit, and integrant: https://clojurewalk.com/watch/part-1-reitit-and-swagger-14c0f19dc9ce Then I found this project: https://github.com/walkable-server/realworld-fulcro/blob/master/project.clj Which uses duct, ataraxy, and reitit. What I wasn't able to find are the trade offs. Since Integrant may be used with different libraries, what are Duct's advantages compared to Ring and Reitit (which seems simpler)?

kwrooijen 2019-12-23T21:35:53.032400Z

Duct (Integrant) is a framework for configuring your project. It handles setting up all daemons (http server, for example) and dependencies between components (web handlers need the database to connected, so handlers are dependent on database). Ring is an HTTP server abstraction, so that actually has nothing to do with Duct. Default Duct actually uses Ring, so you don’t need to compare them. Reitit is a routing library, again not comparable with Duct. Default Duct uses Ataraxy for routing, which can be compared to Reitit. Ataraxy vs Reitit is just preference, but Reitit is more mature / popular at the moment. You can compare integrant with Component or Mount. Those two are also meant to manage your applications state. The main difference between Integrant and the other two options I mentioned are that Integrant is Data driven. It tries to configure your application in Data (EDN), and keep the actual code minimal. The benefit of this is transparency, you can look at static data and understand what it is. Function calls on the other hand can do anything. Duct / Integrant might be a bit difficult to get your head wrapped around, but I believe once you understand the concepts you can build really clear / clean applications. Just finished my first “real” production application in Duct at work today 🙂 Here’s a video where the creator of Duct talks about his ideas, he probably explains it a lot better than I do: https://www.youtube.com/watch?v=zznwKCifC1A

Norman Kabir 2019-12-23T21:39:50.035Z

Thank you! In your comment, you combine Duct and Integrant: ... Duct (Integrant) is a framework for configuring your project. ... That's the part that confuses me. Based on my limited impression, Integrant seems to be responsible for structuring the application, configuration, dependencies, and state management. I will watch the talk to see if it clears that up.

kwrooijen 2019-12-23T21:41:27.035300Z

The talk isn’t about Duct, so that question won’t be answered

kwrooijen 2019-12-23T21:42:56.036900Z

To put it simply; integrant is the system that Duct uses to configure your application. And Duct is a collection of plugins, and standards, to setting it up

kwrooijen 2019-12-23T21:43:18.037400Z

Duct basically adds an extra layer on top of Integrant

Norman Kabir 2019-12-23T21:44:55.039200Z

I see. So Duct specifies a collection of conventions that provide a de facto standard for extensions.

kwrooijen 2019-12-23T21:44:57.039300Z

For example, Duct adds profiles for test / production / local. To help structure your application between development and production. You can do this with raw integrant, but Duct gives you tools to make it easy

kwrooijen 2019-12-23T21:49:58.039800Z

There’s also a talk in youtube about Duct, iirc it’s called “Productive Duct”

kwrooijen 2019-12-23T21:50:26.040200Z

Don’t remember if it makes it clearer though

kwrooijen 2019-12-23T21:50:41.040600Z

Transparency through data is a great talk however

Norman Kabir 2019-12-23T21:53:54.040900Z

Your clarification is much appreciated!

kwrooijen 2019-12-23T21:55:16.041100Z

You’re very welcome 🙂