What is the proper way to store a global connection in Clojure?

Viewed 2488

I have the following file that acts as the access point to my DB from my API endpoints. What is the proper way to maintain a single connection (or a connection pool?) for the life of the server?

(ns my-api.repository
  (:require [clojure.java.jdbc :as sql]))

(defn some-query
  (sql/with-connection (System/getenv "DATABASE_URL")
    (sql/with-query-results results
      ;; You get the picture
      )))
4 Answers
Related