             (format "'%s' component is not started yet." name)
             {:cause "Cassandra component"}))))
 
+
+;; Public functions ----------------------------------------
 (defn select-keyspace
+  "Use the given keyspace name or throw an exception if the keyspace was
+  missing"
   [session keyspace]
   (try
     (alia/execute session (format "USE %s;" keyspace))

   [hellhound.core                 :as hellhound]))


(spec/def ::cassanda-configuration
  (spec/keys :req [::connection ::keyspace]))

(defn cassandra-config
  []
  (:cassandra (:db (hellhound/application-config))))

(defn- connect
  [config]
  (let [cluster (alia/cluster (:connecttion config))]

      (throw
       (ex-info "Keyspace is not present. You need to migrate first." {})))))

(defn cassandra-config
  "Returns the cassandra configuration"
  []
  (:cassandra (:db (hellhound/application-config))))


(defn make-cassandra-client
  "Create an instance of `Cassandra` record to be used with a `component`
  compatible system."
  ([]
   (make-cassandra-client {}))
  ([options]
   (let [config (merge (cassandra-config) options)]
     (->Cassandra config))))

(defn new-cassandra-client
  "Create an instance from cassandra component. This function is meant
  to be used with `hellhound.system.defsystem` macro."
  ([system-map]
   (new-cassandra-client system-map {}))
  ([system-map options]
   (let [config (merge (cassandra-config) options)]
     (update-in system-map [:components :cassandra] (->Cassandra config)))))


;; Component record ----------------------------------------
(defrecord Cassandra [options]

  ;; Lifecycle implementation.
