       (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.

            (format "'%s' component is not started yet." name)
            {:cause "Cassandra component"}))))

(defn select-keyspace
  [session keyspace]
  (try
    (alia/execute session (format "USE %s;" keyspace))

        (assoc this :keyspace (:name keyspace-config)))))

  (teardown [this]))
