work in progress: csys basics
This commit is contained in:
parent
445c5a5c3b
commit
0eb98e357e
5 changed files with 39 additions and 9 deletions
|
@ -17,7 +17,8 @@
|
|||
(defclass common ()
|
||||
((children :accessor children
|
||||
:initarg children
|
||||
:initform nil)))
|
||||
:initform nil)
|
||||
(actions :accessor actions :initarg :actions :initform nil)))
|
||||
|
||||
(defgeneric parent (cfg)
|
||||
(:method ((cfg common)) nil))
|
||||
|
@ -49,7 +50,8 @@
|
|||
(setf (gethash sl data) dotenv-val)))))))
|
||||
|
||||
(defun root (&rest params &key (class 'root) &allow-other-keys)
|
||||
(setf *root* (apply #'make-instance class params)))
|
||||
(setf *root* (apply #'make-instance class params))
|
||||
(setf *current* *root*))
|
||||
|
||||
;;;; config base class
|
||||
|
||||
|
@ -57,8 +59,7 @@
|
|||
((name :reader name :initarg :name)
|
||||
(parent :accessor parent :initarg :parent)
|
||||
(setup :reader setup :initarg :setup :initform #'(lambda (cfg)))
|
||||
(shutdown :reader shutdown :initarg :shutdown :initform #'(lambda (ctx)))
|
||||
(actions :accessor actions :initarg :actions :initform nil)))
|
||||
(shutdown :reader shutdown :initarg :shutdown :initform #'(lambda (ctx)))))
|
||||
|
||||
(defmethod initialize-instance :after ((cfg base) &key parent &allow-other-keys)
|
||||
(if parent
|
||||
|
|
|
@ -10,8 +10,30 @@
|
|||
(:shape :scopes/shape)
|
||||
(:util :scopes/util)
|
||||
(:alx :alexandria))
|
||||
(:export #:*dispatcher*))
|
||||
(:export #:*dispatcher* #:setup #:start
|
||||
#:printer
|
||||
))
|
||||
|
||||
(in-package :scopes/csys)
|
||||
|
||||
(defvar *dispatcher* nil)
|
||||
|
||||
(defun setup (&optional (cfg config:*root*))
|
||||
(setf *dispatcher* (make-instance 'core:context :config cfg))
|
||||
(setf (core:mailbox *dispatcher*) (async:make-mb))
|
||||
(dolist (a (config:actions cfg))
|
||||
(core:add-action *dispatcher* (car a) (cadr a))))
|
||||
|
||||
(defun start ()
|
||||
(async:init)
|
||||
(actor:start (core:mailbox *dispatcher*)
|
||||
(lambda (msg) (funcall #'handle-message msg))
|
||||
:foreground t))
|
||||
|
||||
(defun handle-message (msg)
|
||||
(print msg))
|
||||
|
||||
;;;; example behaviors / actions
|
||||
|
||||
(defun printer (msg)
|
||||
(print msg))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
:version "0.0.1"
|
||||
:homepage "https://www.cyberconcepts.org"
|
||||
:description "Generic data processing"
|
||||
:depends-on (:scopes-core :scopes-web
|
||||
:depends-on (:scopes-core :scopes-csys :scopes-web
|
||||
:dbi :sxql)
|
||||
:components ((:file "storage/folder" :depends-on ("storage/tracking"))
|
||||
(:file "storage/msgstore" :depends-on ("storage/tracking"))
|
||||
|
@ -16,7 +16,8 @@
|
|||
;;#.(uiop:read-file-string
|
||||
;; (uiop:subpathname *load-pathname* "README.md")))
|
||||
:in-order-to ((test-op
|
||||
(test-op "scopes-core/test" "scopes-web/test" "scopes/test"))))
|
||||
(test-op "scopes-core/test" "scopes-csys/test"
|
||||
"scopes-web/test" "scopes/test"))))
|
||||
|
||||
(defsystem :scopes/test
|
||||
:depends-on (:scopes)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
(config:root)
|
||||
|
||||
(config:add-action '(test) #'csys:printer)
|
||||
|
||||
(config:add :logger :class 'logging:config
|
||||
:loglevel (config:from-env :loglevel :info)
|
||||
:logfile (t:test-path "scopes-test.log" "log")
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
;;;; test runner
|
||||
|
||||
(defun run ()
|
||||
(async:init)
|
||||
(let* ((t:*test-suite* (make-instance 't:test-suite :name "csys")))
|
||||
(load (t:test-path "config-csys" "etc"))
|
||||
(unwind-protect
|
||||
|
@ -31,4 +30,9 @@
|
|||
(t:show-result))))
|
||||
|
||||
(deftest test-basic ()
|
||||
(== csys:*dispatcher* nil))
|
||||
(csys:setup)
|
||||
(!= csys:*dispatcher* nil)
|
||||
(actor:send (core:mailbox csys:*dispatcher*) (message:create '(:test)))
|
||||
(actor:stop (core:mailbox csys:*dispatcher*))
|
||||
(csys:start)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue