Fork me on GitHub

hello everyone. I feel like I'm completely lost. Is there a more than minimal example project using integrant that one can inspect? I'm right now struggling with the ergonomics of having an open connection and using this open connection to do something with it. I have a database connection open and my functions take a connection as a first parameter but having the caller access the system-map every and getting out the currently opened connection feels weird.


to give an additional insight into my current confusion: I see two options, having the caller grab the connection from the system-map and providing it to the callee or have the callee function receive the system-map as arg1 and getting the connection out of there itself


the 2nd option would be fine if it weren't for the repeating of the same code (the get-in) and the bad ergonomics of normal repl development where I have to construct an unnecessarily large map with the right keys just to run my new functions


Generally the idea is to define request handlers as ig/init-keys, then they reference the database connection in their opts. I'm not sure what kind of an application you're building though


(This is how Duct does it)


I'm trying to fit integrant into an already established work in progress system that has quite a bit of state, as it sources events from 5 places and so far I've used mount to keep those systems decoupled


but the state is making repl testing cumbersome so I wanted to try integrant but I don't get how I go from the simple jetty single event handler model to my I have events in several subsystems


maybe I have to redesign it and make a application wide queue and that way I can pipe everything through one place


I think using Integrant in an existing application will be a bit difficult. When building a new Duct app, all your state runs through the integrant map


You don't access it from the "outside" so to speak


So if you're planning on using an existing codebase without making it fit into integrant, I'm not sure if that'll be a good choice (however, anyone can feel free to prove me wrong)


I'm fine with retrofitting it because I would like to gain the ability to test while the dev system is running


You could manipulate a dynamic var with integrant init-keys.. But then it's not much different from using component / mount (I think)


yeah I saw a tutorial on integrant that just used a system atom which is referenced everywhere


that didn't feel like the way to do things 😉


Preferably not no


maybe I should make a new duct application and just get a feel for how it's done there and try to build a minimal example outside of duct because my application has nothing to do with the web


What kind of application is it?


I've never used Integrant outside of webapps


Well I guess that's technically not true, I've used it in Clojurescript


a desktop program (at this point in time, web will come later) that grabs things from all kinds of places and shows them in a GUI while sourcing events from filesystem watcher and window titles, websites and excel files


it's bespoke and there are 10 people in the world that may find it useful that all have the same job as me 😉


so lots of state and trying to keep it from getting out of control using any means necessary


Having a hard time imagining what this application might look like internally 😄


the dependency graph is basically me putting everything into a database and having the GUI try to create its state from the choices in the GUI and the DB only


But the basic gist of Duct is pretty straightforward: [`Database` / logging ] <-- ref --- handler <--- ref --- router <--- ref --- webserver


Then your application starts Integrant with a root key (for example, the webserver), which starts all the dependent components


Router takes all the handlers and puts them in the right place. And the handler references things that it needs. For example a database connection


maybe by thinking in those terms I can solve my mapping issue, I'll try the duct template and try to create some basic CRUD stuff in the database


Also, even though Duct markets itself as a "server-side application framework", I don't think there's anything stopping you from using it in a GUI application


You just don't include the webserver stuff


thanks @kevin.van.rooijen, time to get my hands dirty 😉


Best of luck to you 👍 Duct documentation can be a bit lacking