(all-dependencies m)
gets all dependencies for long form
(all-dependencies {1 #{4 2} 2 #{3} 3 #{5} 4 #{} 5 #{6} 6 #{}}) => {1 #{2 3 4 5 6} 2 #{3 5 6} 3 #{5 6} 4 #{} 5 #{6} 6 #{}}
(-> (long-form {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]}) get-dependencies all-dependencies) => {:model #{}, :ids #{}, :traps #{:ids :model}, :entry #{:ids :model}, :nums #{:ids :traps :model}, :model-tag #{:model}}
gets all dependencies for long form (all-dependencies {1 #{4 2} 2 #{3} 3 #{5} 4 #{} 5 #{6} 6 #{}}) => {1 #{2 3 4 5 6} 2 #{3 5 6} 3 #{5 6} 4 #{} 5 #{6} 6 #{}} (-> (long-form {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]}) get-dependencies all-dependencies) => {:model #{}, :ids #{}, :traps #{:ids :model}, :entry #{:ids :model}, :nums #{:ids :traps :model}, :model-tag #{:model}}
(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 (-> (long-form {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]}) get-dependencies) => {:model #{}, :ids #{}, :traps #{:ids :model}, :entry #{:ids :model}, :nums #{:traps}, :model-tag #{:model}}
get dependencies for long form (-> (long-form {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]}) get-dependencies) => {:model #{}, :ids #{}, :traps #{:ids :model}, :entry #{:ids :model}, :nums #{:traps}, :model-tag #{:model}}
(get-exposed full-topology)
get exposed keys for long form (-> (long-form {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]}) get-exposed) => [:nums :model-tag]
get exposed keys for long form (-> (long-form {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]}) get-exposed) => [:nums :model-tag]
(long-form topology)
converts entire topology to long form
(long-form {:db [identity] :count [{:expose :count} :db]}) => (contains-in {:db {:compile :single, :type :build, :constructor fn?, :import {}, :dependencies ()}, :count {:compile :single, :type :expose, :in :db, :function :count, :dependencies [:db]}})
converts entire topology to long form (long-form {:db [identity] :count [{:expose :count} :db]}) => (contains-in {:db {:compile :single, :type :build, :constructor fn?, :import {}, :dependencies ()}, :count {:compile :single, :type :expose, :in :db, :function :count, :dependencies [:db]}})
(long-form-entry [desc & args])
converts short form entry into long form
(long-form-entry [{:constructor :identity :initialiser :identity}]) => {:type :build :compile :single :constructor :identity :initialiser :identity :import {}, :dependencies ()}
(long-form-entry [[identity]]) => (contains {:compile :array, :type :build, :constructor fn? :import {}, :dependencies ()})
(long-form-entry [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]]) => (contains {:compile :array, :type :build :constructor fn? :import {:model {:type :single, :as :raw}, :ids {:type :element, :as :id}}, :dependencies [:model :ids]})
converts short form entry into long form (long-form-entry [{:constructor :identity :initialiser :identity}]) => {:type :build :compile :single :constructor :identity :initialiser :identity :import {}, :dependencies ()} (long-form-entry [[identity]]) => (contains {:compile :array, :type :build, :constructor fn? :import {}, :dependencies ()}) (long-form-entry [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]]) => (contains {:compile :array, :type :build :constructor fn? :import {:model {:type :single, :as :raw}, :ids {:type :element, :as :id}}, :dependencies [:model :ids]})
(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 {:keys [setup hooks] :as 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
(start-system system)
starts a system (->> (system {:models [[identity] [:files {:type :element :as :fs}]] :files [[identity]]} {:models [{:m 1} {:m 2}] :files [{:id 1} {:id 2}]}) start-system (into {})) => (contains-in {:models [{:m 1, :fs {:id 1}} {:m 2, :fs {:id 2}}], :files [{:id 1} {:id 2}]})
starts a system (->> (system {:models [[identity] [:files {:type :element :as :fs}]] :files [[identity]]} {:models [{:m 1} {:m 2}] :files [{:id 1} {:id 2}]}) start-system (into {})) => (contains-in {:models [{:m 1, :fs {:id 1}} {:m 2, :fs {:id 2}}], :files [{:id 1} {:id 2}]})
(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 {:keys [teardown hooks] :as 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
(stop-system system)
stops a system (stop-system (start-system (system {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]} {:model {:tag :barbie} :ids [1 2 3 4 5] :traps [{} {} {} {} {}] :entry {}}))) => {:model {:tag :barbie}, :ids [1 2 3 4 5], :traps [{} {} {} {} {}], :entry {}}
stops a system (stop-system (start-system (system {:model [identity] :ids [[identity]] :traps [[identity] [:model {:as :raw}] [:ids {:type :element :as :id}]] :entry [identity :model :ids] :nums [[{:expose :id}] :traps] :model-tag [{:expose :tag :setup identity} :model]} {:model {:tag :barbie} :ids [1 2 3 4 5] :traps [{} {} {} {} {}] :entry {}}))) => {:model {:tag :barbie}, :ids [1 2 3 4 5], :traps [{} {} {} {} {}], :entry {}}
(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)
(valid-subcomponents (long-form {:model [identity] :tag [{:expose :tag} :model] :kramer [identity :tag]}) [:model]) => [:model :tag]
returns only the components that will work (for partial systems) (valid-subcomponents (long-form {:model [identity] :tag [{:expose :tag} :model] :kramer [identity :tag]}) [:model]) => [:model :tag]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close