Fork me on GitHub
#duct
<
2019-12-23
>
Norman Kabir17:12:56

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

Kevin18:12:30

However, this works for me:

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

Norman Kabir18:12:56

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

Norman Kabir18:12:02

@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?

Kevin18:12:56

What do you mean by from scratch?

Norman Kabir18:12:52

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

Kevin18:12:17

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

Norman Kabir19:12:21

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

Norman Kabir21:12:40

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)?

Kevin21:12:53

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 Kabir21:12:50

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.

Kevin21:12:27

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

Kevin21:12:56

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

Kevin21:12:18

Duct basically adds an extra layer on top of Integrant

Norman Kabir21:12:55

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

Kevin21:12:57

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

Kevin21:12:58

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

Kevin21:12:26

Don’t remember if it makes it clearer though

Kevin21:12:41

Transparency through data is a great talk however

Norman Kabir21:12:54

Your clarification is much appreciated!

Kevin21:12:16

You’re very welcome 🙂