From 0bc84cc02efd9a40a80494018bd55a739a069af7 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 4 Jul 2025 10:41:22 +0200 Subject: [PATCH] actor:message: provide base class with customer slot --- core/actor.lisp | 12 ++++++++---- core/message.lisp | 2 +- csys/csys.lisp | 2 +- web/server.lisp | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/actor.lisp b/core/actor.lisp index 99276de..f07077c 100644 --- a/core/actor.lisp +++ b/core/actor.lisp @@ -6,7 +6,7 @@ (:shape :scopes/shape) (:util :scopes/util)) (:export #:start #:stop #:create #:send #:become - #:message #:content #:customer #:set-content + #:customer-message #:message #:content #:customer #:set-content #:*logger* #:*root* #:echo #:inc #:lgi #:calculator #:plus #:minus #:show)) @@ -21,14 +21,18 @@ (defgeneric customer (msg) (:method (msg) nil)) -(defclass message () - ((content :reader content :initarg :content :initform nil) - (customer :reader customer :initarg :customer :initform nil))) +(defclass customer-message () + ((customer :reader customer :initarg :customer :initform nil))) + +(defclass message (customer-message) + ((content :reader content :initarg :content :initform nil))) (defun message (content &optional customer) (make-instance 'message :content content :customer customer)) (defgeneric set-content (msg fn) + (:documentation "Create a new message with content returned by calling `fn` + with the content of the input `msg`.") (:method (msg fn) (funcall fn msg)) (:method ((msg message) fn) (message (funcall fn (content msg)) (customer msg)))) diff --git a/core/message.lisp b/core/message.lisp index b0e8795..e84308f 100644 --- a/core/message.lisp +++ b/core/message.lisp @@ -15,7 +15,7 @@ (defun message-meta () (make-instance 'shape:record-meta :head-fields '(:domain :action :class :item))) -(defclass message (shape:record actor:message) +(defclass message (shape:record actor:customer-message) ((shape:meta :initform (message-meta) :allocation :class))) (defun create (head &key data customer) diff --git a/csys/csys.lisp b/csys/csys.lisp index 54135e4..150d07e 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -56,7 +56,7 @@ (setf (gethash key *sensors*) tsks)) (util:lgw "no action selected" msg)))))) -;;;; neurons (= behavior generators) and synapses (connection generators) +;;;; neurons (= behavior factories) and synapses (connection factories) (defun neuron (proc &optional state syns (env *environment*)) (lambda (msg) diff --git a/web/server.lisp b/web/server.lisp index 6647170..f433812 100644 --- a/web/server.lisp +++ b/web/server.lisp @@ -85,6 +85,7 @@ (let* ((rel-path (str:join "/" message-head)) (file-app (make-instance 'lack/app/file:lack-app-file :file rel-path :root doc-root))) + ;(request:process message-head ctx env) (lack/component:call file-app env)))) (defun message-handler (ctx env &key html-responder) @@ -93,7 +94,7 @@ :data (plist (post-data env)) :customer (core:mailbox resp)))) ;(util:lgd msg) - ; (check-auth ctx msg env) => (response:render-unauthorized resp) + ;(request:process msg ctx env :response resp) (if (core:handle-message ctx msg) (response:render resp) (response:render-not-found resp))))