Add before
and after
options to refresh middleware
#233
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm still refining the elisp bits for this, but am posting the middleware changes for review. The options are passed in as namespace-qualified function names, which must have zero arity.
before
is invoked before refreshing, and refreshing does not proceed if it throws an exception.after
is invoked after refreshing.refresh-tracker
is now an agent, and the logic for refreshing dispatched usingsend-off
- this means that only onerefresh
request will be being processed at any given time, so you don't have to worry about yourbefore
andafter
functions running concurrently or being retried. This is also means they won't lock up an nREPL thread if they block for a long time.*out*
and*err*
are both captured and streamed back to the client while invoking bothbefore
andafter
, and if an exception is thrown either during their execution or while reloading, it is printed to*out*
as it would be at the REPL (usingclojure.main/repl-caught
) and sent back to the client in stacktrace format for rendering in the error buffer.Here's the client UI so far (a log buffer that prints the output of
before
andafter
, the list of namespaces being refreshed, and whether or not it was successful):