use more general term context (instead of service)
This commit is contained in:
parent
27542c5c40
commit
8611caaa8f
3 changed files with 15 additions and 6 deletions
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
(in-package :scopes/config)
|
(in-package :scopes/config)
|
||||||
|
|
||||||
|
;;;; common base class for all config classes
|
||||||
|
|
||||||
(defclass common ()
|
(defclass common ()
|
||||||
((children :accessor children
|
((children :accessor children
|
||||||
:initarg children
|
:initarg children
|
||||||
|
@ -19,6 +21,8 @@
|
||||||
(defgeneric parent (cfg)
|
(defgeneric parent (cfg)
|
||||||
(:method ((cfg common)) nil))
|
(:method ((cfg common)) nil))
|
||||||
|
|
||||||
|
;;;; config root (top-level) class with no parent
|
||||||
|
|
||||||
(defclass root (common)
|
(defclass root (common)
|
||||||
((env-keys :reader env-keys
|
((env-keys :reader env-keys
|
||||||
:initform nil
|
:initform nil
|
||||||
|
@ -45,12 +49,15 @@
|
||||||
(setf (gethash sl data) env-val)
|
(setf (gethash sl data) env-val)
|
||||||
(setf (gethash sl data) dotenv-val))))))
|
(setf (gethash sl data) dotenv-val))))))
|
||||||
|
|
||||||
|
;;;; config base class
|
||||||
|
|
||||||
(defclass base (common)
|
(defclass base (common)
|
||||||
((parent :reader parent
|
((parent :reader parent
|
||||||
:initarg :parent)))
|
:initarg :parent)))
|
||||||
|
|
||||||
(defmethod initialize-instance :after ((cfg base) &key parent &allow-other-keys)
|
(defmethod initialize-instance :after ((cfg base) &key parent &allow-other-keys)
|
||||||
(push cfg (children parent)))
|
(if parent
|
||||||
|
(push cfg (children parent))))
|
||||||
|
|
||||||
(defmethod (setf parent) ((cfg base) (parent common))
|
(defmethod (setf parent) ((cfg base) (parent common))
|
||||||
(push cfg (children parent)))
|
(push cfg (children parent)))
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
(:local-nicknames (:config :scopes/config))
|
(:local-nicknames (:config :scopes/config))
|
||||||
(:export #:config
|
(:export #:config
|
||||||
#:message
|
#:message
|
||||||
#:service #:name #:send))
|
#:context #:name #:send))
|
||||||
|
|
||||||
(in-package :scopes/core)
|
(in-package :scopes/core)
|
||||||
|
|
||||||
(defclass config (config:root)
|
(defclass config (config:base)
|
||||||
(services))
|
(services))
|
||||||
|
|
||||||
(defclass message ()
|
(defclass message ()
|
||||||
|
@ -21,10 +21,12 @@
|
||||||
(timestamp)
|
(timestamp)
|
||||||
(data)))
|
(data)))
|
||||||
|
|
||||||
(defclass service ()
|
(defclass context ()
|
||||||
((name :initarg :name :reader name)))
|
((name :initarg :name :reader name)))
|
||||||
|
|
||||||
(defgeneric send (rcvr msg)
|
(defgeneric send (rcvr msg)
|
||||||
(:method ((rcvr service) msg)
|
(:method ((rcvr context) msg)
|
||||||
rcvr
|
rcvr
|
||||||
msg))
|
msg))
|
||||||
|
|
||||||
|
(defvar *context* nil)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
(defvar *config* nil)
|
(defvar *config* nil)
|
||||||
|
|
||||||
(defclass test-suite (t:test-suite)
|
(defclass test-suite (t:test-suite)
|
||||||
((receiver :initform (make-instance 'core:service :name :test-rcvr)
|
((receiver :initform (make-instance 'core:context :name :test-rcvr)
|
||||||
:reader receiver)))
|
:reader receiver)))
|
||||||
|
|
||||||
(defun run ()
|
(defun run ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue