Coverage report: /home/ellis/comp/core/lib/rdb/cfg.lisp
Kind | Covered | All | % |
expression | 0 | 95 | 0.0 |
branch | 0 | 4 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; cfg.lisp --- RDB Configuration
3
;; Base Configuration Protocol for RDB Databases and Stores
7
;; The RDB-CONFIG object may be used to specify initialization values for
8
;; RDB-DATABASE/RDB/RDB-STORE.
10
;; You may call BUILD on an RDB-CONFIG to return the uninitialize RDB db or
16
(defconfig rdb-config (ast id db-config)
17
((path :initform (std::tmpize-pathname "/tmp/rdb") :initarg :path :type (or pathname string))
18
(logger :initform (default-logger-config) :initarg :logger :type (or null log::logger-config))
19
(schema :initform (make-instance 'rdb-schema) :initarg :schema :type rdb-schema)))
21
(defmethod print-object ((self rdb-config) stream)
22
(print-unreadable-object (self stream :type t)
23
(format stream "~S ~A" :id (format-sxhash (id:id self)))))
25
(defun find-rdb-symbol (s)
26
(find-symbol* (symbol-name s) :rdb nil))
28
(defmethod load-ast ((self rdb-config))
29
(with-slots (ast) self
31
;; ast is valid, modify object, set ast nil
33
(sb-int:doplist (k v) ast
34
(when-let ((s (find-rdb-symbol k))) ;; needs to be correct package
38
(:logger (make-config :logger :ast v))
40
(setf (slot-value self s) v))))
41
(setf (ast:ast self) nil)
43
;; invalid ast, signal error
44
(error 'syntax-error))))
46
(defmethod build-ast ((self rdb-config) &key (nullp nil) (exclude '(ast id logger)))
54
(defmethod build ((self rdb-config) &key)
55
(make-db (slot-value self 'backend)
56
:opts (slot-value self 'options)
57
:logger (when-let ((l (slot-value self 'logger))) (build l))
58
:name (slot-value self 'path)))
60
(defmethod make-config ((self (eql :rdb)) &rest args)
61
(apply 'make-instance 'rdb-config args))
63
(defun init-rdbrc (&optional (file (merge-homedir-pathnames ".rdbrc")))
64
(let ((cfg (make-instance 'rdb-config)))
66
(with-open-file (out file
68
:if-does-not-exist :create)
69
(write-ast cfg out :fmt :canonical))))