Skip to content

Commit

Permalink
EclipseStore
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsz committed Sep 24, 2024
1 parent c33ef34 commit 197c571
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
* Changes
** 0.5.5-SNAPSHOT
- Init-fn for Mariadb component.
- Support for EclipseStore, persistable atom component
** 0.5.4
- Support for multiple API handlers, which are siloed handlers with their own prefix, middleware and dependencies.
** 0.5.3
Expand Down
24 changes: 24 additions & 0 deletions src/system/components/eclipsestore.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(ns system.components.eclipsestore
(:require [com.stuartsierra.component :as component])
(:import [org.eclipse.store.storage.embedded.types EmbeddedStorage]))

(def storage-manager (EmbeddedStorage/start))

(defrecord EclipseStore []
component/Lifecycle
(start [component]
(let [data (if (.root storage-manager)
(atom (.root storage-manager))
(atom {}))]
(add-watch data :watcher
(fn [key atom old-state new-state]
(.setRoot storage-manager new-state)
(.storeRoot storage-manager)))
(assoc component :db data)))
(stop [component]
(remove-watch (:db component) :watcher)
(.shutdown storage-manager)
(assoc component :db nil)))

(defn new-eclipsestore [& {:keys []}]
(map->EclipseStore {}))

0 comments on commit 197c571

Please sign in to comment.