-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reloading with component *without* introducing global state #189
Comments
You don't want to use Lein-Ring with Component (except possibly for creating war files). Instead, prefer the reloaded workflow pattern, perhaps with a library such as reloaded.repl. |
I should have provided a little more context concerning my particular motivation and use-case. Whilst I like the reloaded workflow in cider - based on a variation of Stuart Sierra's This has been working tremendously well over the past couple of months for me, prior to seeking a dependency-injection solution to improve my tests/mocking. With host volume mounts to the various projects, when I change the code for any service in the composition, I suppose I could introduce something "Heath Robinson" like a I've just finished porting the project over to |
Sorry, I'm not completely clear on your use case. Is this Docker composition in a development or production environment? Is there a reason you can't just open an nREPL connection to it? |
I'm the one who should apologise, I should have given the use-case straight away and less ambiguously. My concern is rapid acceptance-test driven development. I have 8-10 micro-services from our portfolio (if you will) and bring up a docker composition with host volumes mounting each micro-service project directory. I built some tooling called It's been working great, but in my most recent project I want to introduce some proper dependency injection and So as you say I could run an As I mentioned before, I suggest we close this issue unless you have a further interest in the approach I'm taking and want to discuss that more. Many thanks for your time and consideration in reply to the issue. |
Perhaps it would help if I described my typical setup. I use reloaded.repl, which gives me useful REPL functions like I connect to my application through Cider, and Cider has a useful function called ((nil . ((cider-refresh-before-fn . "reloaded.repl/suspend")
(cider-refresh-after-fn . "reloaded.repl/resume")))) In my (defun cider-save-and-refresh ()
(interactive)
(save-buffer)
(call-interactively 'cider-refresh))
(global-set-key (kbd "s-r") 'cider-save-and-refresh) This setup is more nuanced that reloading files on save, as it allows me to save temporary work without messing up the running application. However, if you want to skip the Cider integration, you can still have reset-on-save functionality by hooking up a file watcher to For example, using Hawk something like this should work: (hawk.core/watch! [{:paths ["src" "test"], :handler (fn [ctx _] (reset) ctx)}]) |
Hmm, the extra control sounds appealing and I'll give that a try over the weekend. Thanks for the advice. |
Firstly, thanks for your amazing work for the Clojure community.
I've been using
lein-ring
for some time now and in particular theauto-reload
facility which I find very helpful.However, I'm just getting started with
component
, and have reached an impasse where I cannot see a way of getting the reloading benefits oflein ring
without introducing global state.I've created a minimal re-production of where I have got to and was hoping someone could advise on whether what I'm aiming for is possible.
https://github.com/codeasone/component-reload-issue
The text was updated successfully, but these errors were encountered: