Liking cljdoc? Tell your friends :D

hara.core.component


*registry*clj


all-dependenciesclj

(all-dependencies m)

gets all dependencies for long form

gets all dependencies for long form
raw docstring

arrayclj

(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"})
raw docstring

array?clj

(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
raw docstring

component?clj

(component? x)

checks if an instance extends IComponent

(component? (Database.)) => true

checks if an instance extends IComponent

(component? (Database.))
=> true
raw docstring

constructorclj

(constructor x)

returns the constructor from topology

returns the constructor from topology
raw docstring

get-dependenciesclj

(get-dependencies full-topology)

get dependencies for long form

get dependencies for long form
raw docstring

get-exposedclj

(get-exposed full-topology)

get exposed keys for long form

get exposed keys for long form
raw docstring

handlescljmacro

(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+)
raw docstring

kill-allclj

(kill-all)

long-formclj

(long-form topology)

converts entire topology to long form

converts entire topology to long form
raw docstring

long-form-entryclj

(long-form-entry [desc & args])

converts short form entry into long form

converts short form entry into long form
raw docstring

long-form-importsclj

(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}}
raw docstring

perform-hooksclj

(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
raw docstring

primitive?clj

(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
raw docstring

propertiesclj

(properties component)

returns properties of the system

(properties (Database.)) => {}

(properties (Filesystem.)) => {:hello "world"}

returns properties of the system

(properties (Database.)) => {}

(properties (Filesystem.)) => {:hello "world"}
raw docstring

startclj

(start component)
(start component opts)

starts a component/array/system

(start (Database.)) => {:status "started"}

starts a component/array/system

(start (Database.))
=> {:status "started"}
raw docstring

start-arrayclj

(start-array carr)

starts an array of components

starts an array of components
raw docstring

start-systemclj

(start-system system)

starts a system

starts a system
raw docstring

started?clj

(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
raw docstring

stopclj

(stop component)
(stop component opts)

stops a component/array/system

(stop (start (Database.))) => {}

stops a component/array/system

(stop (start (Database.))) => {}
raw docstring

stop-arrayclj

(stop-array carr)

stops an array of components

stops an array of components
raw docstring

stop-systemclj

(stop-system system)

stops a system

stops a system
raw docstring

stopped?clj

(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
raw docstring

systemclj

(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"}})
raw docstring

system-deportclj

(system-deport component import)

deports a component from the system

deports a component from the system
raw docstring

system-exposeclj

(system-expose _ system {:keys [in function] :as opts})

exposes a component into the system

exposes a component into the system
raw docstring

system-importclj

(system-import component system import)

imports a component into the system

imports a component into the system
raw docstring

system-stringclj

(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}"
raw docstring

system?clj

(system? x)

checks if object is a component system

(system? (system {} {})) => true

checks if object is a component system

(system? (system {} {}))
=> true
raw docstring

valid-subcomponentsclj

(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)
raw docstring

withcljmacro

(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"
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close