Coverage report: /home/ellis/comp/core/app/skel/core/db.lisp
Kind | Covered | All | % |
expression | 31 | 75 | 41.3 |
branch | 1 | 2 | 50.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; db.lisp --- Skel Database Protocol
6
(in-package :skel/core/db)
8
(load-database-backend :rdb)
10
(defvar *skel-db-path* (merge-homedir-pathnames ".stash/skel/db/"))
11
(defun skel-db-path (path) (merge-pathnames path *skel-db-path*))
13
(defun skel-db-spec (path &optional (backend :rdb))
14
"Return a list which can be safely stored in the SPEC slot of a STORE."
15
(list backend (directory-path (skel-db-path path))))
17
(defvar *default-skel-db-spec* (skel-db-spec "default"))
19
(defclass skel-db (rdb-database)
22
:db (make-db :rocksdb :name "skel-db" :opts (default-rdb-opts))))
24
(defmethod make-db ((engine (eql :skel)) &rest initargs &key name path &allow-other-keys)
25
(let ((name (or name (when path (namestring path)))))
28
(let ((db (apply 'make-instance 'skel-db initargs)))
29
(when name (setf (name db) name))
32
(defaccessor name ((self skel-db)) (rdb-name (db self)))
33
(defaccessor path ((self skel-db)) (rdb-name (db self)))
35
(defmethod initialize-instance :before ((self skel-db) &rest initargs &key name path &allow-other-keys)
36
(declare (ignore initargs))
39
(setf name (namestring path)))))
41
(defmethod start :after ((self skel-db))
42
(setq *db* (open-db self)))
44
(defclass skel-store (store) ()
45
(:default-initargs :spec *default-skel-db-spec*))
47
(defmethod start :after ((self skel-store))
50
(defclass skel-db-schema (upgradable-schema)
51
((collection :type (vector rdb-schema) :initarg :collection :accessor schema-collection))
55
(defclass skel-object-schema (object-schema) ())
57
(defclass skel-record (id) ()
58
(:metaclass stored-class))
60
(defvar *skel-registry-db* (make-db :skel :path (skel-db-path "registry") :schema *skel-registry-schema*))
61
(defvar *skel-cache-db* (make-db :skel :path (skel-db-path "cache") :schema *skel-cache-schema*))
62
;; (with-db (db :db *skel-cache-db* :open t :close t))