mount/test/app/nyse.clj

19 lines
706 B
Clojure
Raw Permalink Normal View History

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