hikari-cp icon indicating copy to clipboard operation
hikari-cp copied to clipboard

Add is-closed? and is-running? functions

Open lukaszkorecki opened this issue 7 months ago • 3 comments

This is useful to check the state of the connection pool when it's wrapped in a Component (or similar) to avoid issues when trying to close a pool that's already been closed but its instance is still around.

Plus a bunch of improvements:

  • Updates all dependencies
  • Closes #97
  • A proper connection test with H2
  • Updated documentation to use next.jdbc

Lastly, I'd be more than happy to rewrite all tests to use clojure.test - It's probably the first time I'm seeing expectations and run into weird issues with it, for example:

;; this works:
  (let [running? (hikari-cp/is-running? pool)
        closed? (hikari-cp/is-closed? pool)]
    (expect true running?)
    (expect false closed?))

;; but this doesn't (always returns false!)

(expect true (hikari-cp/is-running? pool))

Given that there's very little difference between:

(expect false (hikari-cp/is-closed? pool))

and

(is (false? (hikari-cp/is-closed? pool)))

I think it would be a simple refactoring, and one less dependency to worry about.

Lastly, expectations has a bunch of reflection warnings - I've enabled them globally in project.clj

lukaszkorecki avatar Nov 29 '23 18:11 lukaszkorecki