actor:message: provide base class with customer slot
This commit is contained in:
parent
37b39c596f
commit
0bc84cc02e
4 changed files with 12 additions and 7 deletions
|
@ -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))))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))))
|
||||
|
|
Loading…
Add table
Reference in a new issue