use more general term context (instead of service)

This commit is contained in:
Helmut Merz 2024-06-09 10:17:33 +02:00
parent 27542c5c40
commit 8611caaa8f
3 changed files with 15 additions and 6 deletions

View file

@ -11,6 +11,8 @@
(in-package :scopes/config)
;;;; common base class for all config classes
(defclass common ()
((children :accessor children
:initarg children
@ -19,6 +21,8 @@
(defgeneric parent (cfg)
(:method ((cfg common)) nil))
;;;; config root (top-level) class with no parent
(defclass root (common)
((env-keys :reader env-keys
:initform nil
@ -45,12 +49,15 @@
(setf (gethash sl data) env-val)
(setf (gethash sl data) dotenv-val))))))
;;;; config base class
(defclass base (common)
((parent :reader parent
:initarg :parent)))
(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))
(push cfg (children parent)))

View file

@ -5,11 +5,11 @@
(:local-nicknames (:config :scopes/config))
(:export #:config
#:message
#:service #:name #:send))
#:context #:name #:send))
(in-package :scopes/core)
(defclass config (config:root)
(defclass config (config:base)
(services))
(defclass message ()
@ -21,10 +21,12 @@
(timestamp)
(data)))
(defclass service ()
(defclass context ()
((name :initarg :name :reader name)))
(defgeneric send (rcvr msg)
(:method ((rcvr service) msg)
(:method ((rcvr context) msg)
rcvr
msg))
(defvar *context* nil)

View file

@ -14,7 +14,7 @@
(defvar *config* nil)
(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)))
(defun run ()