work in progress: storage/msglog: table creation OK
This commit is contained in:
parent
94c515a191
commit
75d63e0c89
5 changed files with 39 additions and 7 deletions
|
@ -12,8 +12,7 @@
|
|||
|
||||
(defclass message (shape:record)
|
||||
((shape:head-fields :initform '(:domain :action :class :item))
|
||||
(sender :reader sender :initarg :sender :initform nil)
|
||||
(timestamp)))
|
||||
(sender :reader sender :initarg :sender :initform nil)))
|
||||
|
||||
(defun create (head &key data sender)
|
||||
(make-instance 'message :head head :data data :sender sender))
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
:version "0.0.1"
|
||||
:homepage "https://www.cyberconcepts.org"
|
||||
:description "Generic data processing."
|
||||
:depends-on (:dbi :sxql
|
||||
:scopes-core :scopes-web)
|
||||
:components ((:file "storage/storage")
|
||||
:depends-on (:scopes-core :scopes-web
|
||||
:dbi :sxql)
|
||||
:components ((:file "storage/msglog" :depends-on ("storage/tracking"))
|
||||
(:file "storage/storage")
|
||||
(:file "storage/tracking" :depends-on ("storage/storage")))
|
||||
:long-description "scopes: generic data processing facilities."
|
||||
;;#.(uiop:read-file-string
|
||||
|
|
19
storage/msglog.lisp
Normal file
19
storage/msglog.lisp
Normal file
|
@ -0,0 +1,19 @@
|
|||
;;;; cl-scopes/storage/msglog - storing message data in a SQL database
|
||||
|
||||
(defpackage :scopes/storage/msglog
|
||||
(:use :common-lisp)
|
||||
(:local-nicknames (:message :scopes/core/message)
|
||||
(:storage :scopes/storage)
|
||||
(:tracking :scopes/storage/tracking))
|
||||
(:export #:make-container #:save))
|
||||
|
||||
(in-package :scopes/storage/msglog)
|
||||
|
||||
(defclass pmsg (message:message tracking:track) ())
|
||||
|
||||
(defun make-container (storage)
|
||||
(make-instance 'tracking:container
|
||||
:item-class 'pmsg
|
||||
:table-name :messages
|
||||
:indexes '((domain action class item))
|
||||
:storage storage))
|
|
@ -9,6 +9,7 @@
|
|||
(:jzon :com.inuoe.jzon))
|
||||
(:export #:track #:trackid #:time-stamp
|
||||
#:container #:insert
|
||||
#:item-class #:table-name #:indexes #:storage
|
||||
#:make-item
|
||||
#:get-track
|
||||
#:create-indexes #:create-table))
|
||||
|
@ -25,8 +26,8 @@
|
|||
|
||||
(defclass container ()
|
||||
((item-class :reader item-class :initarg :item-class :initform 'track)
|
||||
(table-name :reader table-name :initform :tracks)
|
||||
(indexes :reader indexes :initform '((taskid username) (username)))
|
||||
(table-name :reader table-name :initarg :table-name :initform :tracks)
|
||||
(indexes :reader indexes :initarg :indexes :initform '((taskid username) (username)))
|
||||
(storage :reader storage :initarg :storage)))
|
||||
|
||||
(defun item-head-fields (cont)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
(:local-nicknames (:config :scopes/config)
|
||||
(:core :scopes/core)
|
||||
(:logging :scopes/logging)
|
||||
(:message :scopes/core/message)
|
||||
(:msglog :scopes/storage/msglog)
|
||||
(:shape :scopes/shape)
|
||||
(:storage :scopes/storage)
|
||||
(:tracking :scopes/storage/tracking)
|
||||
|
@ -34,6 +36,7 @@
|
|||
(core:setup-services)
|
||||
(let ((ctx (core:find-service :storage)))
|
||||
(test-track ctx)
|
||||
(test-msglog ctx)
|
||||
(t:show-result)))
|
||||
|
||||
(deftest test-track (ctx)
|
||||
|
@ -55,3 +58,12 @@
|
|||
(== (shape:head tr2) '("t01" "john"))
|
||||
(== (gethash :desc (shape:data tr2)) "scopes/storage: queries")
|
||||
))
|
||||
|
||||
(deftest test-msglog (ctx)
|
||||
(let ((st (storage:storage ctx))
|
||||
(data (make-hash-table))
|
||||
cont msg)
|
||||
(setf cont (msglog:make-container st))
|
||||
(storage:drop-table st :messages)
|
||||
(tracking:create-table cont)
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue