practicalli / clojure-web-services

Develop production grade server-side web services and APIs using Clojure and REPL driven development
https://practical.li/clojure-web-services
Creative Commons Attribution Share Alike 4.0 International
11 stars 14 forks source link

Introducing Duct #11

Open practicalli-johnny opened 4 years ago

practicalli-johnny commented 4 years ago

Dependencies:

12 Introducing component lifecycle management

13 Introduce Integrant

A section on Duct, including introduction of integrant, atraxy, reitit, etc

Short introduction (not official) 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 :slightly_smiling_face:

Video: James Reeves, the creator of Duct discusses the concepts involved https://www.youtube.com/watch?v=zznwKCifC1A