Skip to content
Snippets Groups Projects
Commit 30a85023 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

style tweaks.

parent ffd0fc83
No related branches found
No related tags found
No related merge requests found
......@@ -109,7 +109,7 @@
(when-let [pool (get @connection-pools id)]
(log/debug (u/format-color 'red "Closing connection pool for database %d ..." id))
;; remove the cached reference to the pool so we don't try to use it anymore
(reset! connection-pools (dissoc @connection-pools id))
(swap! connection-pools dissoc id)
;; now actively shut down the pool so that any open connections are closed
(.close ^ComboPooledDataSource (:datasource pool))))
......@@ -120,12 +120,9 @@
(if (contains? @connection-pools id)
;; we have an existing pool for this database, so use it
(get @connection-pools id)
;; need to create a new pool
(let [new-pool (create-connection-pool database)]
;; add the newly created pool to the cache so we maintain a reference to it
(reset! connection-pools (assoc @connection-pools id new-pool))
;; just return the newly created pool
new-pool)))
;; create a new pool and add it to our cache, then return it
(u/prog1 (create-connection-pool database)
(swap! connection-pools assoc id <>))))
(defn db->jdbc-connection-spec
"Return a JDBC connection spec for DATABASE. Normally this will have a C3P0 pool as its datasource, unless the database is `short-lived`."
......
......@@ -7,7 +7,7 @@
[metabase.models.database :refer [Database]]))
(def ^:const driver-notifications-topics
(def ^:const ^:private driver-notifications-topics
"The `Set` of event topics which are subscribed to for use in driver notifications."
#{:database-update})
......@@ -23,12 +23,12 @@
"Handle processing for a single event notification received on the driver-notifications-channel"
[driver-notifications-event]
;; try/catch here to prevent individual topic processing exceptions from bubbling up. better to handle them here.
(try
(when-let [{topic :topic database :item} driver-notifications-event]
(when-let [{topic :topic database :item} driver-notifications-event]
(try
;; notify the appropriate driver about the updated database
(driver/notify-database-updated (driver/engine->driver (:engine database)) database))
(catch Throwable e
(log/warn (format "Failed to process driver notifications event. %s" (:topic driver-notifications-event)) e))))
(driver/notify-database-updated (driver/engine->driver (:engine database)) database)
(catch Throwable e
(log/warn (format "Failed to process driver notifications event. %s" (:topic driver-notifications-event)) e)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment