 ;; These functions are the actual implementation of IComponent
 ;; Protocol for IPersistentMap.
 (defn- initialize-component
+  "This function is responsible to initialize the given `component` by
+  initializing the input and ouput manifolds of the component."
   [component]
   (let [default-io-buffer-size (core/get-config :components :io-buffer-size)
-          default-stream-fn #(stream/stream default-io-buffer-size)
-          input-stream-fn   (get component
-                                 :input-stream-fn
-                                 default-stream-fn)
-          output-stream-fn  (get component
-                                 :output-stream-fn
-                                 default-stream-fn)]
+          default-stream-fn    #(stream/stream default-io-buffer-size)
+          input-stream-fn      (get component
+                                    :input-stream-fn
+                                    default-stream-fn)
+          output-stream-fn     (get component
+                                    :output-stream-fn
+                                    default-stream-fn)]
+
       (assert default-io-buffer-size)
       (assoc component
              ::started? false

             ::output   (output-stream-fn))))

(defn- start-component!
  [component context]
  (let [start-fn (::start-fn component)]
      (if (not (started? component))
        (do
          (log/debug "Starting '" (::name component) "' component...")
          (assoc (start-fn component context) ::started? true))

        (do
          (log/debug "Component '" (::name component) "' already started. Skipping...")
          component))))

(defn- stop-component!
  [component]
  (let [stop-fn (::stop-fn component)]
      (if (started? component)

          component))))

(defn- component-started?
  "Returns `true` if the given component is `started?`."
  [component]
  (or (::started? component) false))

(defn- name-of
  "Returns the `name` of the given `component`."
  [component]
  (::name component))

(defn- dependencies-of
  "Returns a collection of dependencies of the given `component`."
  [component]
  (::depends-on component))

(defn- input-of
  "Returns the input manifold of the given `component`.

  The input of the component is a manifold whichis going to receive
  the incoming dataflow from the output of the component upstream."
  [component]
  (assert (::input component) "::input should not be empty. Please file a bug")
  (::input component))

(defn- output-of
  "Returns the output manifold of the given `component`.

  The output of the component is a manifold which should
  flow the output data of the component to the downstream
  component."
  [component]
  (assert (::output component)
          "::input should not be empty. Please file a bug")
