|
1 | 1 | (ns nvim-app.core |
2 | 2 | (:gen-class) |
3 | | - (:require |
4 | | - [nvim-app.config :as config] |
5 | | - [nvim-app.components.app :as app] |
6 | | - [nvim-app.components.pedestal.core :as pedestal-component] |
7 | | - [nvim-app.components.database :as database-component] |
8 | | - [nvim-app.components.xtdb :as xtdb-component] |
9 | | - [nvim-app.components.sched :as sched-component] |
10 | | - [nvim-app.components.repl :as repl-component] |
11 | | - [nvim-app.utils :refer [ex-format]] |
12 | | - [com.stuartsierra.component :as component] |
13 | | - [clojure.tools.logging :as log])) |
| 3 | + (:require [nvim-app.config :as config] |
| 4 | + [nvim-app.components.app :as app] |
| 5 | + [nvim-app.components.pedestal.core :as pedestal-component] |
| 6 | + [nvim-app.components.database :as database-component] |
| 7 | + [nvim-app.components.xtdb :as xtdb-component] |
| 8 | + [nvim-app.components.sched :as sched-component] |
| 9 | + [nvim-app.components.repl :as repl-component] |
| 10 | + [nvim-app.utils :refer [ex-format]] |
| 11 | + [com.stuartsierra.component :as component] |
| 12 | + [clojure.tools.logging :as log])) |
14 | 13 |
|
15 | | -(defn nvim-database-system [config] |
16 | | - (component/system-map |
17 | | - :database-component (database-component/new config))) |
| 14 | +(defn nvim-database-system |
| 15 | + [config] |
| 16 | + (component/system-map :database-component (database-component/new config))) |
18 | 17 |
|
19 | | -(defn nvim-app-system [config] |
20 | | - (-> |
21 | | - (component/system-map |
22 | | - :repl (repl-component/new config) |
23 | | - :database-component (database-component/new config) |
24 | | - :xtdb-component (xtdb-component/new config) |
25 | | - :pedestal-component (component/using (pedestal-component/new config) |
26 | | - [:database-component]) |
27 | | - :sched (sched-component/new config) |
28 | | - :app (app/new config)) |
29 | | - (component/system-using {:app [:database-component |
30 | | - :xtdb-component |
31 | | - :pedestal-component |
32 | | - :sched :repl]}))) |
| 18 | +(defn nvim-app-system |
| 19 | + [config] |
| 20 | + (-> (component/system-map :repl (repl-component/new config) |
| 21 | + :database-component (database-component/new config) |
| 22 | + ; :xtdb-component (xtdb-component/new config) |
| 23 | + :pedestal-component |
| 24 | + (component/using (pedestal-component/new config) |
| 25 | + [:database-component]) |
| 26 | + :sched (sched-component/new config) |
| 27 | + :app (app/new config)) |
| 28 | + (component/system-using {:app [:database-component |
| 29 | + ; :xtdb-component |
| 30 | + :pedestal-component :sched :repl]}))) |
33 | 31 |
|
34 | | -(defn -main [] |
35 | | - (try |
36 | | - (let [system (-> (config/read-config) |
37 | | - config/assert-valid-config! |
38 | | - nvim-app-system |
39 | | - component/start-system)] |
40 | | - |
41 | | - (.addShutdownHook |
42 | | - (Runtime/getRuntime) |
43 | | - (new Thread #(component/stop-system system)))) |
44 | | - |
45 | | - (catch Exception e |
46 | | - (log/error "Failed to start system component\n" (ex-format e)) |
47 | | - (component/stop (:system (ex-data e)))))) |
| 32 | +(defn -main |
| 33 | + [] |
| 34 | + (try (let [system (-> (config/read-config) |
| 35 | + config/assert-valid-config! |
| 36 | + nvim-app-system |
| 37 | + component/start-system)] |
| 38 | + (.addShutdownHook (Runtime/getRuntime) |
| 39 | + (new Thread #(component/stop-system system)))) |
| 40 | + (catch Exception e |
| 41 | + (log/error "Failed to start system component\n" (ex-format e)) |
| 42 | + (component/stop (:system (ex-data e)))))) |
0 commit comments