(all-dependencies m)gets all dependencies for long form
gets all dependencies for long form
(array {:keys [constructor]} config)creates an array of components
(def recs (start (array {:constructor map->Database} [{:id 1} {:id 2}]))) (count (seq recs)) => 2 (first recs) => (just {:id 1 :status "started"})
creates an array of components
(def recs (start (array {:constructor map->Database} [{:id 1} {:id 2}])))
(count (seq recs)) => 2
(first recs) => (just {:id 1 :status "started"})(array? x)checks if object is a component array
(array? (array map->Database [])) => true
checks if object is a component array (array? (array map->Database [])) => true
(component? x)checks if an instance extends IComponent
(component? (Database.)) => true
checks if an instance extends IComponent (component? (Database.)) => true
(constructor x)returns the constructor from topology
returns the constructor from topology
(get-dependencies full-topology)get dependencies for long form
get dependencies for long form
(get-exposed full-topology)get exposed keys for long form
get exposed keys for long form
(handles topology config)(handles topology config {:keys [suffix]})generates handles stop start and restart for the namespace
(component/handles +topology+ +config+)
generates handles `stop` `start` and `restart` for the namespace (component/handles +topology+ +config+)
(kill-all)(long-form topology)converts entire topology to long form
converts entire topology to long form
(long-form-entry [desc & args])converts short form entry into long form
converts short form entry into long form
(long-form-imports args)converts short form imports to long form
(long-form-imports [:db [:file {:as :fs}]]) => {:db {:type :single, :as :db}, :file {:type :single, :as :fs}}
(long-form-imports [[:ids {:type :element :as :id}]]) => {:ids {:type :element, :as :id}}
converts short form imports to long form
(long-form-imports [:db [:file {:as :fs}]])
=> {:db {:type :single, :as :db},
:file {:type :single, :as :fs}}
(long-form-imports [[:ids {:type :element :as :id}]])
=> {:ids {:type :element, :as :id}}(perform-hooks component functions hook-ks)perform hooks before main function
(perform-hooks (Database.) {:init (fn [x] 1)} [:init]) => 1
perform hooks before main function
(perform-hooks (Database.)
{:init (fn [x] 1)}
[:init])
=> 1(primitive? x)checks if a component is a primitive type
(primitive? 1) => true
(primitive? {}) => false
checks if a component is a primitive type
(primitive? 1) => true
(primitive? {}) => false(properties component)returns properties of the system
(properties (Database.)) => {}
(properties (Filesystem.)) => {:hello "world"}
returns properties of the system
(properties (Database.)) => {}
(properties (Filesystem.)) => {:hello "world"}(start component)(start component opts)starts a component/array/system
(start (Database.)) => {:status "started"}
starts a component/array/system
(start (Database.))
=> {:status "started"}(start-array carr)starts an array of components
starts an array of components
(started? component)checks if a component has been started
(started? 1) => true
(started? {}) => false
(started? (start {})) => true
(started? (Database.)) => false
(started? (start (Database.))) => true
(started? (stop (start (Database.)))) => false
checks if a component has been started
(started? 1)
=> true
(started? {})
=> false
(started? (start {}))
=> true
(started? (Database.))
=> false
(started? (start (Database.)))
=> true
(started? (stop (start (Database.))))
=> false(stop component)(stop component opts)stops a component/array/system
(stop (start (Database.))) => {}
stops a component/array/system
(stop (start (Database.))) => {}(stop-array carr)stops an array of components
stops an array of components
(stopped? component)checks if a component has been stopped
(stopped? 1) => false
(stopped? {}) => true
(stopped? (start {})) => false
(stopped? (Database.)) => true
(stopped? (start (Database.))) => false
(stopped? (stop (start (Database.)))) => true
checks if a component has been stopped
(stopped? 1)
=> false
(stopped? {})
=> true
(stopped? (start {}))
=> false
(stopped? (Database.))
=> true
(stopped? (start (Database.)))
=> false
(stopped? (stop (start (Database.))))
=> true(system topology config)(system topology config {:keys [partial? tag display] :as opts})creates a system of components
;; The topology specifies how the system is linked (def topo {:db [map->Database] :files [[map->Filesystem]] :catalogs [[map->Catalog] [:files {:type :element :as :fs}] :db]})
;; The configuration customises the system (def cfg {:db {:type :basic :host "localhost" :port 8080} :files [{:path "/app/local/1"} {:path "/app/local/2"}] :catalogs [{:id 1} {:id 2}]})
;; system will build it and calling start initiates it
(def sys (-> (system topo cfg) start))
;; Check that the :db entry has started
(:db sys)
=> (just {:status "started",
:type :basic,
:port 8080,
:host "localhost"})
;; Check the first :files entry has started
(-> sys :files first)
=> (just {:status "started",
:path "/app/local/1"})
;; Check that the second :store entry has started
(->> sys :catalogs second)
=> (contains-in {:id 2
:status "started"
:db {:status "started",
:type :basic,
:port 8080,
:host "localhost"}
:fs {:path "/app/local/2", :status "started"}})
creates a system of components
;; The topology specifies how the system is linked
(def topo {:db [map->Database]
:files [[map->Filesystem]]
:catalogs [[map->Catalog] [:files {:type :element :as :fs}] :db]})
;; The configuration customises the system
(def cfg {:db {:type :basic
:host "localhost"
:port 8080}
:files [{:path "/app/local/1"}
{:path "/app/local/2"}]
:catalogs [{:id 1}
{:id 2}]})
;; `system` will build it and calling `start` initiates it
(def sys (-> (system topo cfg) start))
;; Check that the `:db` entry has started
(:db sys)
=> (just {:status "started",
:type :basic,
:port 8080,
:host "localhost"})
;; Check the first `:files` entry has started
(-> sys :files first)
=> (just {:status "started",
:path "/app/local/1"})
;; Check that the second `:store` entry has started
(->> sys :catalogs second)
=> (contains-in {:id 2
:status "started"
:db {:status "started",
:type :basic,
:port 8080,
:host "localhost"}
:fs {:path "/app/local/2", :status "started"}})(system-deport component import)deports a component from the system
deports a component from the system
(system-expose _ system {:keys [in function] :as opts})exposes a component into the system
exposes a component into the system
(system-import component system import)imports a component into the system
imports a component into the system
(system-string sys)returns the system for display
(system-string (system {:a [identity] :b [identity]} {:a 1 :b 2} {:tag "happy"})) => "#happy {:a 1, :b 2}"
returns the system for display
(system-string (system {:a [identity]
:b [identity]}
{:a 1 :b 2}
{:tag "happy"}))
=> "#happy {:a 1, :b 2}"(system? x)checks if object is a component system
(system? (system {} {})) => true
checks if object is a component system
(system? (system {} {}))
=> true(valid-subcomponents full-topology keys)returns only the components that will work (for partial systems)
returns only the components that will work (for partial systems)
(with [var expr & more] & body)helper for testing a temporary system
(component/with [sys (system topology {:database {:status "stopped"}})] (-> sys :database :status)) => "started"
helper for testing a temporary system
(component/with [sys (system topology {:database {:status "stopped"}})]
(-> sys :database :status))
=> "started"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 |