mount/dev/clj/app/nyse.clj

22 lines
752 B
Clojure
Raw Normal View History

2015-10-20 12:53:09 +00:00
(ns app.nyse
2015-11-17 05:09:45 +00:00
(:require [mount.core :as mount :refer [defstate]]
2015-10-20 01:33:56 +00:00
[datomic.api :as d]
2015-10-20 12:53:09 +00:00
[clojure.tools.logging :refer [info]]
[app.conf :refer [config]]))
2015-10-20 01:33:56 +00:00
(defn- new-connection [conf]
(info "conf: " conf)
(let [uri (get-in conf [:datomic :uri])]
(info "creating a connection to datomic:" uri)
(d/create-database uri)
(d/connect uri)))
(defn disconnect [conf conn]
(let [uri (get-in conf [:datomic :uri])]
(info "disconnecting from " uri)
2015-10-20 12:36:00 +00:00
(.release conn) ;; usually it's not released, here just to illustrate the access to connection on (stop)
2015-10-20 01:33:56 +00:00
(d/delete-database uri)))
(defstate conn :start (new-connection config)
:stop (disconnect config conn))