Core system lifecycle management for biff-datalevin.
Provides a simple map-based component system inspired by Biff's architecture. Components are functions that take a system map and return a modified system map.
Core system lifecycle management for biff-datalevin. Provides a simple map-based component system inspired by Biff's architecture. Components are functions that take a system map and return a modified system map.
(assoc-stop system stop-fn)Helper to add a stop function to the system map.
Example: (-> system (assoc :my-resource (create-resource)) (assoc-stop #(close-resource (:my-resource system))))
Helper to add a stop function to the system map.
Example:
(-> system
(assoc :my-resource (create-resource))
(assoc-stop #(close-resource (:my-resource system))))(start-system initial-system components)Starts the system by threading the initial system map through each component.
Components are functions that take a system map and return a modified system map. Each component can add a cleanup function under :biff/stop which will be called during shutdown (in reverse order).
Example: (start-system {:biff.datalevin/db-path "data/myapp"} [use-datalevin my-custom-component])
Starts the system by threading the initial system map through each component.
Components are functions that take a system map and return a modified system map.
Each component can add a cleanup function under :biff/stop which will be called
during shutdown (in reverse order).
Example:
(start-system {:biff.datalevin/db-path "data/myapp"}
[use-datalevin
my-custom-component])(stop-system system)Stops the system by calling all cleanup functions in reverse order.
Cleanup functions are stored under :biff/stop as a vector of no-arg functions.
Stops the system by calling all cleanup functions in reverse order. Cleanup functions are stored under :biff/stop as a vector of no-arg functions.
(use-config system config)Component that merges configuration into the system map.
Accepts a config map and merges it into the system map. Useful for loading configuration from files or environment variables.
Example: (use-config system {:port 8080 :base-url "http://localhost:8080"})
Component that merges configuration into the system map.
Accepts a config map and merges it into the system map.
Useful for loading configuration from files or environment variables.
Example:
(use-config system {:port 8080 :base-url "http://localhost:8080"})(use-datalevin {:biff.datalevin/keys [db-path schema opts] :as system})Component that initializes a Datalevin connection.
Required keys in system map: :biff.datalevin/db-path - Path to the Datalevin database directory
Optional keys: :biff.datalevin/schema - Datalevin schema map :biff.datalevin/opts - Additional options passed to d/get-conn
Adds to system map: :biff.datalevin/conn - The Datalevin connection :biff/db - Current database snapshot (for Biff compatibility)
Component that initializes a Datalevin connection. Required keys in system map: :biff.datalevin/db-path - Path to the Datalevin database directory Optional keys: :biff.datalevin/schema - Datalevin schema map :biff.datalevin/opts - Additional options passed to d/get-conn Adds to system map: :biff.datalevin/conn - The Datalevin connection :biff/db - Current database snapshot (for Biff compatibility)
(use-session-cleanup {:biff.datalevin/keys [conn] :as system})Component that periodically removes expired sessions.
Required keys in system map: :biff.datalevin/conn - Datalevin connection
Optional keys: :biff.datalevin.session/cleanup-interval-ms - Interval between runs (default 3600000) :biff.datalevin.session/run-cleanup-on-start? - Run once during startup (default true) :biff.datalevin.session/cleanup-fn - Override cleanup function; primarily useful for testing
Adds to system map: :biff.datalevin.session/cleanup-executor - Scheduled executor for cleanup
Component that periodically removes expired sessions. Required keys in system map: :biff.datalevin/conn - Datalevin connection Optional keys: :biff.datalevin.session/cleanup-interval-ms - Interval between runs (default 3600000) :biff.datalevin.session/run-cleanup-on-start? - Run once during startup (default true) :biff.datalevin.session/cleanup-fn - Override cleanup function; primarily useful for testing Adds to system map: :biff.datalevin.session/cleanup-executor - Scheduled executor for cleanup
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |