Allow calling code to manage connection disconnects #256
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.
Resolves #255
The current implementation in this branch is not exactly what was discussed in #255. I got more familiar with the code and wanted to put something out there and discuss further.
The change in this branch appears to be the one that requires the fewest changes. The
Database
record now does not calldisconnect*
if:managed-connection?
is set on the:db
config.Alternative that was discussed in #255 was to create a new implementation of
Store
. This would require:proto/make-store
that I guess would check for the:store
to be:managed-database
, example config:(I haven't looked through all of the code to see what else might need to change to handle a new
:store
key.)2. Most of the functionality inside the
Database
record would need to factored out into standalone functions that bothDatabase
and the newManagedDatabase
could call.A second alternative that I thought of would be to introduce either a protocol or a multimethod that is used by the
disconnect*
function (and perhaps for consistency,connect*
as well).I'm currently leaning towards doing this, since it will mean the
disconnect*
function will be safe to use in the future, without the calling code needing to worry about whether the disconnect should really happen.