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)
|
(defclass message (shape:record)
|
||||||
((shape:head-fields :initform '(:domain :action :class :item))
|
((shape:head-fields :initform '(:domain :action :class :item))
|
||||||
(sender :reader sender :initarg :sender :initform nil)
|
(sender :reader sender :initarg :sender :initform nil)))
|
||||||
(timestamp)))
|
|
||||||
|
|
||||||
(defun create (head &key data sender)
|
(defun create (head &key data sender)
|
||||||
(make-instance 'message :head head :data data :sender sender))
|
(make-instance 'message :head head :data data :sender sender))
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
:version "0.0.1"
|
:version "0.0.1"
|
||||||
:homepage "https://www.cyberconcepts.org"
|
:homepage "https://www.cyberconcepts.org"
|
||||||
:description "Generic data processing."
|
:description "Generic data processing."
|
||||||
:depends-on (:dbi :sxql
|
:depends-on (:scopes-core :scopes-web
|
||||||
:scopes-core :scopes-web)
|
:dbi :sxql)
|
||||||
:components ((:file "storage/storage")
|
:components ((:file "storage/msglog" :depends-on ("storage/tracking"))
|
||||||
|
(:file "storage/storage")
|
||||||
(:file "storage/tracking" :depends-on ("storage/storage")))
|
(:file "storage/tracking" :depends-on ("storage/storage")))
|
||||||
:long-description "scopes: generic data processing facilities."
|
:long-description "scopes: generic data processing facilities."
|
||||||
;;#.(uiop:read-file-string
|
;;#.(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))
|
(:jzon :com.inuoe.jzon))
|
||||||
(:export #:track #:trackid #:time-stamp
|
(:export #:track #:trackid #:time-stamp
|
||||||
#:container #:insert
|
#:container #:insert
|
||||||
|
#:item-class #:table-name #:indexes #:storage
|
||||||
#:make-item
|
#:make-item
|
||||||
#:get-track
|
#:get-track
|
||||||
#:create-indexes #:create-table))
|
#:create-indexes #:create-table))
|
||||||
|
@ -25,8 +26,8 @@
|
||||||
|
|
||||||
(defclass container ()
|
(defclass container ()
|
||||||
((item-class :reader item-class :initarg :item-class :initform 'track)
|
((item-class :reader item-class :initarg :item-class :initform 'track)
|
||||||
(table-name :reader table-name :initform :tracks)
|
(table-name :reader table-name :initarg :table-name :initform :tracks)
|
||||||
(indexes :reader indexes :initform '((taskid username) (username)))
|
(indexes :reader indexes :initarg :indexes :initform '((taskid username) (username)))
|
||||||
(storage :reader storage :initarg :storage)))
|
(storage :reader storage :initarg :storage)))
|
||||||
|
|
||||||
(defun item-head-fields (cont)
|
(defun item-head-fields (cont)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
(:core :scopes/core)
|
(:core :scopes/core)
|
||||||
(:logging :scopes/logging)
|
(:logging :scopes/logging)
|
||||||
|
(:message :scopes/core/message)
|
||||||
|
(:msglog :scopes/storage/msglog)
|
||||||
(:shape :scopes/shape)
|
(:shape :scopes/shape)
|
||||||
(:storage :scopes/storage)
|
(:storage :scopes/storage)
|
||||||
(:tracking :scopes/storage/tracking)
|
(:tracking :scopes/storage/tracking)
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
(core:setup-services)
|
(core:setup-services)
|
||||||
(let ((ctx (core:find-service :storage)))
|
(let ((ctx (core:find-service :storage)))
|
||||||
(test-track ctx)
|
(test-track ctx)
|
||||||
|
(test-msglog ctx)
|
||||||
(t:show-result)))
|
(t:show-result)))
|
||||||
|
|
||||||
(deftest test-track (ctx)
|
(deftest test-track (ctx)
|
||||||
|
@ -55,3 +58,12 @@
|
||||||
(== (shape:head tr2) '("t01" "john"))
|
(== (shape:head tr2) '("t01" "john"))
|
||||||
(== (gethash :desc (shape:data tr2)) "scopes/storage: queries")
|
(== (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