Basic implementation of realm.core with the following features:
Basic implementation of realm.core with the following features: - use alternative keywords for add/remove/deps/rename (but only one of each!) - validation of component map - start/init/etc fn should return a non nil value, which will be stored in the system - passes only deps into component's start/init etc, not whole system - stop/halt/etc removes key and value from system - passes component itself to remove/stop/halt etc, not whole system - tap>s when starting or stopping a component by default - deps/uses can be a keyword or a collection of keywords - use rename/use-as to rename keys in map passed to start/init etc - wrap start and stop with try/catch and rethrow with more info - updates system var for dev reloaded workflow and/or stopping system on service/job shutdown - stop/holt/etc and deps/uses are optional, start/init/etc isn't. - throw when start/init/etc function returns a non-nil value - start and stop fns are idempotent, meaning, they have no effect when component is already added to or removed from the old context - start and stop functions below throw when any component throws when started or stopped by default - start and stop functions can be customized by passing in opts to configure realm.core starter and stopper functions.
(create-opts)(create-opts
{:keys [start-event stop-event error-handler]
:or {start-event (fn* [p1__1701#] (tap> (str "Starting " p1__1701#)))
stop-event (fn* [p1__1702#] (tap> (str "Stopping " p1__1702#)))
error-handler (fn* [p1__1703#] (throw (ex-info "error" p1__1703#)))}})Returns opts to pass to realm.core starter and stopper functions, with the following keys:
Returns opts to pass to realm.core starter and stopper functions, with the following keys: - start-event: a function that takes a component id and is called when a component is started, default is to tap> a string of 'Starting ' and the component id. - stop-event: a function that takes a component id and is called when a component is stopped, default is to tap> a string of 'Stopping ' and the component id. - error-handler: a function that takes an error map and is called when any component throws an error during start or stop, default is to throw an exception with the error map as data. The error map has the following keys: - :e - the exception thrown by the component - :sys - the system at the time of the error - :arg - the argument passed to the start or stop function of the component - :id - the id of the component that threw the error - :action - either :start or :stop, depending on whether the error was thrown during start or stop
(force-stop sys-var cmps cmp-id)(force-stop sys-var cmps cmp-id opts)Stops a component by id, regardless of dependents, updating the system var. Use with caution, as this may leave some components in a running state if they depend on the component being stopped.
Stops a component by id, regardless of dependents, updating the system var. Use with caution, as this may leave some components in a running state if they depend on the component being stopped.
(hard-reset sys-var)Hard resets a system, use with extreme caution, as this will not invoke any stop functions and may leave components in a running state.
Hard resets a system, use with extreme caution, as this will not invoke any stop functions and may leave components in a running state.
(start sys-var cmps cmp-id)(start sys-var cmps cmp-id opts)Starts a component by id, updating the system var. Dependency order is respected, meaning that a component will not be started until all its dependencies are started, recursively.
Starts a component by id, updating the system var. Dependency order is respected, meaning that a component will not be started until all its dependencies are started, recursively.
(start-all sys-var cmps)(start-all sys-var cmps opts)Starts all components, updating the system var. No guarantees on the order of starting components, other than that dependencies will be started before their dependents.
Starts all components, updating the system var. No guarantees on the order of starting components, other than that dependencies will be started before their dependents.
(start-single-cmp sys-var cmps cmp-id)(start-single-cmp sys-var cmps cmp-id opts)Starts a single component by id, without starting its dependencies, updating the system var. This is useful when you want to start a component that has already started dependencies, or when you want to start a component without starting its dependencies for testing purposes. Note that this function will not check if the dependencies are started or not, so use it with caution.
Starts a single component by id, without starting its dependencies, updating the system var. This is useful when you want to start a component that has already started dependencies, or when you want to start a component without starting its dependencies for testing purposes. Note that this function will not check if the dependencies are started or not, so use it with caution.
(stop sys-var cmps cmp-id)(stop sys-var cmps cmp-id opts)Stops a component by id, updating the system var. Dependency order is respected, meaning that a component will be stopped before any dependencies, recursively.
Stops a component by id, updating the system var. Dependency order is respected, meaning that a component will be stopped before any dependencies, recursively.
(stop-all sys-var cmps)(stop-all sys-var cmps opts)Stops all components, updating the system var. No guarantees on the order of stopping components, other than that dependents will be stopped before their dependencies.
Stops all components, updating the system var. No guarantees on the order of stopping components, other than that dependents will be stopped before their dependencies.
(stop-single-cmp sys-var cmps cmp-id)(stop-single-cmp sys-var cmps cmp-id opts)Stops a single component by id, without stopping its dependencies, updating the system var. This is useful when you want to stop a component that has already stopped dependencies, or when you want to stop a component without stopping its dependencies for testing purposes. Note that this function will not check if the dependents are stopped or not, so use it with caution.
Stops a single component by id, without stopping its dependencies, updating the system var. This is useful when you want to stop a component that has already stopped dependencies, or when you want to stop a component without stopping its dependencies for testing purposes. Note that this function will not check if the dependents are stopped or not, so use it with caution.
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 |