id
int64 0
45.1k
| file_name
stringlengths 4
68
| file_path
stringlengths 14
193
| content
stringlengths 32
9.62M
| size
int64 32
9.62M
| language
stringclasses 1
value | extension
stringclasses 6
values | total_lines
int64 1
136k
| avg_line_length
float64 3
903k
| max_line_length
int64 3
4.51M
| alphanum_fraction
float64 0
1
| repo_name
stringclasses 779
values | repo_stars
int64 0
882
| repo_forks
int64 0
108
| repo_open_issues
int64 0
90
| repo_license
stringclasses 8
values | repo_extraction_date
stringclasses 146
values | sha
stringlengths 64
64
| __index_level_0__
int64 0
45.1k
| exdup_ids_cmlisp_stkv2
sequencelengths 1
47
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
25,314 | mixins.lisp | open-rsx_rsb-cl/src/introspection/mixins.lisp | ;;;; mixins.lisp --- Mixins for introspection-related classes.
;;;;
;;;; Copyright (C) 2012, 2013, 2014, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.introspection)
;;; `introspection-participant-mixin'
(defclass introspection-participant-mixin (participant
composite-participant-mixin
lazy-child-making-mixin
child-container-mixin
configuration-inheritance-mixin)
()
(:default-initargs
:scope +introspection-scope+)
(:documentation
"This class is intended to be mixed into introspection participant
classes that have to send and receive events."))
(defmethod make-child-initargs ((participant introspection-participant-mixin)
(which t)
(kind t)
&key)
(list* :introspection? nil
:converters *introspection-all-converters*
(call-next-method)))
(defmethod make-child-scope ((participant introspection-participant-mixin)
(which (eql :participants))
(kind t))
(introspection-participants-scope (participant-scope participant)))
;;; `participant-table-mixin'
(defclass participant-table-mixin ()
((participants :type hash-table
:accessor introspection-%participants
:initform (make-hash-table :test #'equalp)
:documentation
"Stores a mapping of participant ids to
`participant-info' instances."))
(:documentation
"This mixin class adds a table of `participant-info' instances
indexed by id."))
(defmethod print-items:print-items append ((object participant-table-mixin))
`((:num-participants ,(length (introspection-participants object)) " (~D)")))
(defmethod introspection-participants ((container participant-table-mixin))
(hash-table-values (introspection-%participants container)))
(defmethod (setf introspection-participants) ((new-value sequence)
(container participant-table-mixin))
(map nil (lambda (participant)
(setf (find-participant (participant-id participant) container)
participant))
new-value))
(defmethod find-participant ((id uuid:uuid)
(container participant-table-mixin)
&key
parent-id
(if-does-not-exist #'error))
(declare (ignore parent-id))
(let+ (((&structure-r/o introspection- %participants) container)
(key (uuid:uuid-to-byte-array id)))
(or (gethash key %participants)
(error-behavior-restart-case
(if-does-not-exist
(no-such-participant-error :container container :id id))))))
(defmethod (setf find-participant) ((new-value t)
(id uuid:uuid)
(container participant-table-mixin)
&key
parent-id
if-does-not-exist)
(declare (ignore parent-id if-does-not-exist))
(let+ (((&structure-r/o introspection- %participants) container)
(key (uuid:uuid-to-byte-array id)))
(setf (gethash key %participants) new-value)))
(defmethod (setf find-participant) ((new-value (eql nil))
(id uuid:uuid)
(container participant-table-mixin)
&key
parent-id
(if-does-not-exist #'error))
(declare (ignore parent-id))
(let+ (((&structure-r/o introspection- %participants) container)
(key (uuid:uuid-to-byte-array id)))
(if (gethash key %participants)
(remhash key %participants)
(error-behavior-restart-case
(if-does-not-exist
(simple-error ; TODO condition
:format-control "~@<Cannot remove unknown participant ~
with id ~A~@:>"
:format-arguments (list id))
:warning-condition simple-warning)))))
(defmethod ensure-participant ((id uuid:uuid)
(container participant-table-mixin)
(participant t))
(or (find-participant id container :if-does-not-exist nil)
(setf (find-participant id container) participant)))
(defmethod ensure-participant ((id uuid:uuid)
(container participant-table-mixin)
(participant cons)) ; (CLASS . INITARGS)
(let ((existing (find-participant id container :if-does-not-exist nil)))
(typecase existing
(null
(setf (find-participant id container)
(apply #'make-instance participant)))
(participant-entry-proxy
(setf (find-participant id container)
(apply #'change-class existing participant)))
(t
existing))))
;;; `lockable-database-mixin'
(defclass lockable-database-mixin ()
((lock :reader database-%lock
:initform (bt:make-lock "Database lock")))
(:documentation
"This mixins add a lock for use in introspection database
classes."))
(defmethod call-with-database-lock ((database lockable-database-mixin)
(thunk function))
(bt:with-lock-held ((database-%lock database))
(funcall thunk)))
(defmacro with-database-lock ((database) &body body)
`(call-with-database-lock ,database (lambda () ,@body)))
;;; `change-hook-mixin'
(defclass change-hook-mixin ()
((change-hook :type list
:initform '()
:documentation
"Stores a list of handlers to run when something
changes in the object."))
(:documentation
"This class is intended to be mixed into database classes that
notify handlers of changes."))
(defmethod database-change-hook ((database change-hook-mixin))
(hooks:object-hook database 'change-hook))
| 6,355 | Common Lisp | .lisp | 133 | 34.827068 | 82 | 0.573387 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e73cda1fb275b4c135fee35b60df11fefdb040f07195c4946e477bf35cbe9136 | 25,314 | [
-1
] |
25,315 | package.lisp | open-rsx_rsb-cl/src/filter/package.lisp | ;;;; package.lisp --- Package definition filter module.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.filter
(:use
#:cl
#:alexandria
#:let-plus
#:more-conditions
#:rsb)
;; Conditions
(:export
#:filter-construction-error
#:filter-construction-error-spec)
;; Filter protocol
(:export
#:matches?)
;; Filter function protocol
(:export
#:filter-function
#:compute-filter-function)
;; Filter construction
(:export
#:make-filter)
;; `function-caching-mixin' class
(:export
#:function-caching-mixin
#:update-filter-function)
;; `funcallable-filter-mixin' class
(:export
#:funcallable-filter-mixin)
;; Composite filter protocol
(:export
#:composite-filter
#:filter-children)
;; `conjoin-filter' class
(:export
#:conjoin-filter)
;; `complement-filter' class
(:export
#:complement-filter)
;; `disjoin-filter' class
(:export
#:disjoin-filter)
;; `fallback-policy-mixin' class
(:export
#:fallback-policy-mixin
#:filter-fallback-policy)
;; `payload-matching-mixin' class
(:export
#:payload-matches?
#:payload-matching-mixin)
;; `scope-filter' class
(:export
#:scope-filter
#:filter-scope
#:filter-exact?)
;; `type-filter' class
(:export
#:type-filter
#:filter-type)
;; `origin-filter' class
(:export
#:origin-filter
#:filter-origin)
;; `regex-filter' class
(:export
#:regex-filter
#:filter-regex
#:filter-case-sensitive?
#:compile-regex)
;; `method-filter' class
(:export
#:method-filter
#:filter-method)
;; `meta-data-filter' class
(:export
#:meta-data-filter
#:filter-key
#:filter-predicate)
;; `cause-filter' class
(:export
#:cause-filter
#:filter-cause)
;; `xpath-filter' class
(:export
#:xpath-filter
#:filter-xpath
#:filter-compiled-xpath)
;; DSL
(:export
#:filter)
(:documentation
"This package contains event filters. In general, filters are unary
predicates that discriminate arbitrary object and in particular
`rsb:event' instances. The filters in this package are implemented as
funcallable classes with a specialized `matches?' method as the
funcallable instance function."))
| 2,314 | Common Lisp | .lisp | 100 | 19.63 | 70 | 0.689356 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f9ddd455ca410c3fcd11ccda7799003080fc0da59ad3a758a90cf9b73e55e148 | 25,315 | [
-1
] |
25,316 | util.lisp | open-rsx_rsb-cl/src/filter/util.lisp | ;;;; util.lisp --- Utilities used in the filter module.
;;;;
;;;; Copyright (C) 2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
(defun ensure-uuid (thing)
(etypecase thing
(uuid:uuid thing)
(string (uuid:make-uuid-from-string thing))
(nibbles:octet-vector (uuid:byte-array-to-uuid thing))))
| 398 | Common Lisp | .lisp | 11 | 33.727273 | 61 | 0.651948 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | c03fa260bae5fd3d3a2ec9bf3b6982f55371453813c7b55c4345a61f7797a498 | 25,316 | [
-1
] |
25,317 | protocol.lisp | open-rsx_rsb-cl/src/filter/protocol.lisp | ;;;; protocol.lisp --- Protocol for event filtering.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
;;; Filter protocol
(defgeneric matches? (filter event)
(:documentation
"Return non-nil if EVENT matches the criteria of FILTER."))
;; Default behavior
(defmethod matches? ((filter function) (event t))
(funcall filter event))
;;; Payload matching protocol
(defgeneric payload-matches? (filter payload)
(:documentation
"Return non-nil if PAYLOAD matches the criteria of FILTER."))
;;; Filter function protocol
(defgeneric filter-function (filter)
(:documentation
"Return the effective filter function of FILTER.
The returned function takes an event as its sole argument and
returns a Boolean indicating whether the event matches the
criteria of FILTER."))
(defgeneric compute-filter-function (filter &key next)
(:documentation
"Compute and return an effective filter function for FILTER.
The returned function takes an event as its sole argument and
returns a Boolean indicating whether the event matches the
criteria of FILTER.
The computed function can call the function NEXT in case it cannot
decide whether the event matches the criteria of FILTER."))
;;; Filter service
(service-provider:define-service filter
(:documentation
"Providers of this service implement event filtering strategies by
via methods on the `matches?' generic function.
Filter instances should also be funcallable."))
(defun make-filter (name &rest args)
"Construct an instance of the filter class designated by NAME using
ARGS as initargs."
(apply #'service-provider:make-provider 'filter name args))
;;; Filter construction mini-DSL
(defgeneric filter (spec
&rest args
&key &allow-other-keys)
(:documentation
"Construct and return a filter instance according to SPEC and
ARGS. SPEC is either a keyword designating a filter class or a
list of the form
(CLASS (CHILDSPEC1) (CHILDSPEC2) ...)
where CLASS designates a filter class and CHILDSPECN is of the
same form as SPEC. When this second form is used, CLASS has to
designate a composite filter class for which will `make-instance'
will be called with initargs consisting of ARGS and an additional
:children initarg. The value of this initarg is computed by
recursively applying `filter' to each CHILDSPECN."))
(defmethod filter ((spec symbol) &rest args &key)
(handler-bind
((error (lambda (condition)
(error 'filter-construction-error
:spec (cons spec args)
:cause condition))))
(apply #'make-filter spec args)))
(defmethod filter ((spec list) &rest args &key)
(let+ (((class &rest child-specs) spec)
(children (map 'list (curry #'apply #'filter) child-specs)))
(apply #'filter class :children children args)))
| 3,006 | Common Lisp | .lisp | 68 | 39.25 | 70 | 0.723499 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 94b681d351f0b974b366dd2c126b15812f66c678f4e75103c45b54647cfd3ae9 | 25,317 | [
-1
] |
25,318 | types.lisp | open-rsx_rsb-cl/src/filter/types.lisp | ;;;; types.lisp --- Types used in the filter module.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
;;; Event-ID related types
(deftype uuid-designator ()
`(or uuid:uuid string (nibbles:octet-vector 16)))
(deftype cause-pattern/origin ()
`(cons uuid:uuid (eql *)))
(deftype cause-pattern/sequence-number ()
`(cons (eql *) sequence-number))
(deftype cause-pattern ()
`(or (eql t)
event-id uuid:uuid
cause-pattern/origin
cause-pattern/sequence-number))
;;; Filter behavior-related types
(deftype fallback-policy ()
"Designators for fallback filter behaviors."
'(member :match :do-not-match))
| 727 | Common Lisp | .lisp | 22 | 30.181818 | 61 | 0.701578 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b33b2b62520a3468940e3b64f803bc9f4a2e95949d1803a414704c4bfc3d2df8 | 25,318 | [
-1
] |
25,319 | filter-mixins.lisp | open-rsx_rsb-cl/src/filter/filter-mixins.lisp | ;;;; filter-mixins.lisp --- Mixin classes for filters.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
;;; `function-caching-mixin'
(defclass function-caching-mixin ()
((function :type function
:reader filter-function
:writer (setf filter-%function)))
(:documentation
"This mixin caches a computed filter function."))
(defmethod shared-initialize :around ((instance function-caching-mixin)
(slot-names t)
&key)
(call-next-method)
(update-filter-function instance))
(defmethod matches? ((filter function-caching-mixin)
(event t))
(funcall (the function (filter-function filter)) event))
(defun update-filter-function (filter)
(setf (filter-%function filter) (compute-filter-function filter)))
;;; `funcallable-filter-mixin'
(defclass funcallable-filter-mixin ()
()
(:metaclass closer-mop:funcallable-standard-class)
(:documentation
"This mixin makes instances of its subclasses funcallable.
It can be used in conjunction with `function-caching-mixin'."))
(defmethod (setf filter-%function) :after ((new-value function)
(instance funcallable-filter-mixin))
(closer-mop:set-funcallable-instance-function instance new-value))
;;; `fallback-policy-mixin'
(defclass fallback-policy-mixin ()
((fallback-policy :initarg :always
:initarg :fallback-policy
:type fallback-policy
:accessor filter-fallback-policy
:initform :match
:documentation
"The value of this slots determines the behavior
of the filter in case it primary discrimination
mechanism is not applicable to an event."))
(:metaclass closer-mop:funcallable-standard-class)
(:documentation
"This mixin class is intended to be mixed into filter classes that
cannot process all events using their primary discrimination
method and thus need a fallback policy."))
(service-provider:register-provider/class 'filter :constant
:class 'fallback-policy-mixin)
(defmethod compute-filter-function :around ((filter fallback-policy-mixin)
&key next)
(declare (ignore next))
;; Decide whether EVENT should match FILTER based on FILTER's
;; fallback policy. This method is only called, if no more specific
;; method on `matches?' made a decision.
(let ((fallback-result (case (filter-fallback-policy filter)
(:match t)
(:do-not-match nil))))
(call-next-method filter :next (lambda (event)
(declare (ignore event))
fallback-result))))
(defmethod matches? ((filter fallback-policy-mixin)
(event t))
;; Decide whether EVENT should match FILTER based on FILTER's
;; fallback policy. This method is only called, if no more specific
;; method on `matches?' made a decision.
(ecase (filter-fallback-policy filter)
(:match t)
(:do-not-match nil)))
(defmethod print-items:print-items append ((object fallback-policy-mixin))
`((:fallback-policy ,(filter-fallback-policy object) " or ~A")))
;;; `payload-matching-mixin'
(defclass payload-matching-mixin ()
()
(:metaclass closer-mop:funcallable-standard-class)
(:documentation
"This mixin class is intended to be mixed into filter classes that
discriminate event based on their payload."))
(defmethod rsb.ep:access? ((processor payload-matching-mixin)
(part (eql :data))
(mode (eql :read)))
t)
(defmethod compute-filter-function :around ((filter payload-matching-mixin)
&key next)
(let ((function (call-next-method filter :next next)))
(declare (type function function))
(lambda (event)
(funcall function (event-data event)))))
(defmethod matches? ((filter payload-matching-mixin) (event event))
;; Decide whether EVENT matches FILTER by calling `payload-matches?'
;; on the payload of EVENT.
(case (payload-matches? filter (event-data event))
(:cannot-tell (call-next-method))
((nil) nil)
(t t)))
(defmethod payload-matches? ((filter payload-matching-mixin) (payload t))
;; The default behavior is not to decide based on the payload.
:cannot-tell)
;;; Class `composite-filter-mixin'
(defclass composite-filter-mixin ()
((children :type list
:accessor filter-children
:initform '()
:documentation
"A list of subordinate filters."))
(:metaclass closer-mop:funcallable-standard-class)
(:documentation
"Instances of subclasses of this class implement complex filtering
behavior by combining decisions of a set of subordinate
filters. On rare occasions is it useful to make instances of this
class itself rather than subclasses."))
(defmethod shared-initialize :after ((instance composite-filter-mixin)
(slot-names t)
&key
(children nil children-supplied?))
(when children-supplied?
(setf (filter-children instance) children)))
(defmethod rsb.ep:access? ((processor composite-filter-mixin)
(part t)
(mode t))
(rsb.ep:access? (filter-children processor) part mode))
(defmethod (setf filter-children) :after ((new-value t)
(filter composite-filter-mixin))
(update-filter-function filter))
(defmethod print-items:print-items append ((object composite-filter-mixin))
`((:child-count ,(length (filter-children object)) "(~D)")))
| 6,043 | Common Lisp | .lisp | 128 | 37.828125 | 80 | 0.631391 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | c7728c605fe8da4258b02cc8031924e9dbbae989e36d31879587dd0831e78933 | 25,319 | [
-1
] |
25,320 | composite-filter.lisp | open-rsx_rsb-cl/src/filter/composite-filter.lisp | ;;;; composite-filter.lisp --- Composite filters.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
;;; Class `complement-filter'
(defclass complement-filter (composite-filter-mixin
function-caching-mixin
funcallable-filter-mixin
print-items:print-items-mixin)
()
(:metaclass closer-mop:funcallable-standard-class)
(:default-initargs
:children (missing-required-initarg 'complement-filter :children))
(:documentation
"Instances of this class make filtering decisions by forming the
logical complement of the decisions made by their single
subordinate filter."))
(service-provider:register-provider/class
'filter :complement :class 'complement-filter)
(service-provider:register-provider/class
'filter :not :class 'complement-filter)
(defmethod shared-initialize :before ((instance complement-filter)
(slot-names t)
&key
(children '() children-supplied?))
(unless (or (not children-supplied?) (length= 1 children))
(error "~@<~A can only have a single subordinate filter (not ~D).~@:>"
(class-of instance) (length children))))
(defmethod compute-filter-function ((filter complement-filter) &key next)
(declare (ignore next))
(let ((function (%maybe-filter-function (first (filter-children filter)))))
(declare (type function function))
(lambda (event)
(not (funcall function event)))))
;;; Classes `conjoin-filter' and `disjoin-filter'
(macrolet
((define-composite-filter ((name &rest designators)
operation-name
empty-value
short-circuit-condition short-circuit-value)
`(progn
(defclass ,name (composite-filter-mixin
function-caching-mixin
funcallable-filter-mixin
print-items:print-items-mixin)
()
(:metaclass closer-mop:funcallable-standard-class)
(:documentation
,(format nil "Instances of this class make filtering ~
decisions by forming the logical ~A of the ~
decisions made by their subordinate ~
filters."
operation-name)))
,@(mapcar
(lambda (designator)
`(service-provider:register-provider/class 'filter ,designator
:class ',name))
designators)
(defmethod compute-filter-function ((filter ,name) &key next)
(declare (ignore next))
(let ((children (filter-children filter)))
(case (length children)
(0
(constantly ,empty-value))
(1
(%maybe-filter-function (first children)))
(t
(let ((functions (mapcar #'%maybe-filter-function children)))
(named-lambda match (event)
(loop :for function :of-type function :in functions
,short-circuit-condition (funcall function event)
:do (return-from match ,short-circuit-value))
,empty-value)))))))))
(define-composite-filter (conjoin-filter :conjoin :and)
"and" t :unless nil)
(define-composite-filter (disjoin-filter :disjoin :or)
"or" nil :when t))
;;; Utilities functions
(defun %maybe-filter-function (child)
(cond
((compute-applicable-methods
#'filter-function (list child))
(filter-function child))
((functionp child)
child)
(t
(curry #'matches? child))))
| 3,949 | Common Lisp | .lisp | 89 | 31.685393 | 78 | 0.569943 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 451db0bfaab8ba3dbd75707686c9c173669995393319a6374a2f5b3d65c5cf36 | 25,320 | [
-1
] |
25,321 | origin-filter.lisp | open-rsx_rsb-cl/src/filter/origin-filter.lisp | ;;;; origin-filter.lisp --- Event filtering based on origin id.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
(defclass origin-filter (function-caching-mixin
funcallable-filter-mixin
print-items:print-items-mixin)
((origin :type uuid:uuid
:reader filter-origin
:writer (setf filter-%origin)
:documentation
"Stores the origin id to which the filter should restrict
events."))
(:metaclass closer-mop:funcallable-standard-class)
(:default-initargs
:origin (missing-required-initarg 'origin-filter :origin))
(:documentation
"This filter discriminates based on the origin id of events."))
(service-provider:register-provider/class 'filter :origin
:class 'origin-filter)
(defmethod shared-initialize :after ((instance origin-filter)
(slot-names t)
&key
(origin nil origin-supplied?))
(when origin-supplied?
(setf (filter-%origin instance) (ensure-uuid origin))))
(defmethod rsb.ep:access? ((processor origin-filter)
(part (eql :origin))
(mode (eql :read)))
t)
(defmethod compute-filter-function ((filter origin-filter) &key next)
(declare (ignore next))
(let ((filter-origin (filter-origin filter)))
(lambda (event)
(when-let ((event-origin (event-origin event)))
(uuid:uuid= filter-origin (event-origin event))))))
(defmethod print-items:print-items append ((object origin-filter))
`((:origin ,(filter-origin object) "~/rsb::print-id/")))
| 1,777 | Common Lisp | .lisp | 40 | 35.275 | 69 | 0.615029 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 164c956da0bb4cbd64a480cfaaeadd7f3fde64826dc33e6265a8d74140b29cf9 | 25,321 | [
-1
] |
25,322 | conditions.lisp | open-rsx_rsb-cl/src/filter/conditions.lisp | ;;;; conditions.lisp --- Conditions used in the filter module.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
(define-condition filter-construction-error (rsb-error
chainable-condition)
((spec :initarg :spec
:type list
:reader filter-construction-error-spec
:documentation
"The filter specification for which the attempt to construct
a filter instance failed."))
(:default-initargs
:spec (missing-required-initarg 'filter-construction-error :spec))
(:report
(lambda (condition stream)
(format stream "~@<Failed to construct filter based on ~
specification ~
~S~/more-conditions:maybe-print-cause/~@:>"
(filter-construction-error-spec condition)
condition)))
(:documentation
"This error is signaled when an attempt to construct a filter
instance based on a filter specification fails."))
| 1,090 | Common Lisp | .lisp | 26 | 33.730769 | 69 | 0.641243 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | eb7c4f0a76ff220298d66013baf94dfdf9ff49d3498d481729e9ea37ac4baf1b | 25,322 | [
-1
] |
25,323 | method-filter.lisp | open-rsx_rsb-cl/src/filter/method-filter.lisp | ;;;; method-filter.lisp --- Event filtering based on method.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
(defclass method-filter (function-caching-mixin
funcallable-filter-mixin
print-items:print-items-mixin)
((method :initarg :method
:type (or null keyword)
:reader filter-method
:documentation
"Stores the method name to which the filter should restrict
events."))
(:metaclass closer-mop:funcallable-standard-class)
(:default-initargs
:method (missing-required-initarg 'method-filter :method))
(:documentation
"This filter discriminates based on the method of events.
Valid method values are either strings which match events with
identical method strings or NIL which matches events without
methods."))
(service-provider:register-provider/class 'filter :method
:class 'method-filter)
(defmethod rsb.ep:access? ((processor method-filter)
(part (eql :method))
(mode (eql :read)))
t)
(defmethod compute-filter-function ((filter method-filter) &key next)
(declare (ignore next))
(let ((method (filter-method filter)))
(lambda (event)
(eq method (event-method event)))))
(defmethod print-items:print-items append ((object method-filter))
`((:method ,(filter-method object))))
| 1,503 | Common Lisp | .lisp | 36 | 34.833333 | 70 | 0.660274 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 46e061288d01ee1a09ca6a82494cbaeac342011b09f4c39cdf50fe032416f33a | 25,323 | [
-1
] |
25,324 | scope-filter.lisp | open-rsx_rsb-cl/src/filter/scope-filter.lisp | ;;;; scope-filter.lisp --- A filter that discriminates based on scopes.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
(defclass scope-filter (function-caching-mixin
funcallable-filter-mixin
scope-mixin
print-items:print-items-mixin)
((rsb::scope :reader filter-scope
:documentation
"A superscope of the scopes of matching events.")
(exact? :initarg :exact?
:type boolean
:reader filter-exact?
:initform nil
:documentation
"Do events have to have exactly the specified scope or
are sub-scopes permitted?"))
(:metaclass closer-mop:funcallable-standard-class)
(:documentation
"Discriminate based on the scopes of events.
Depending on whether exact matches are requested, event scopes
match the scope of the filter, either if they are identical or if
they are identical or sub-scopes."))
(service-provider:register-provider/class 'filter :scope
:class 'scope-filter)
(defmethod rsb.ep:access? ((processor scope-filter)
(part (eql :scope))
(mode (eql :read)))
t)
(defmethod compute-filter-function ((filter scope-filter) &key next)
(declare (ignore next))
;; The event is matched by comparing its scope to the scope of
;; FILTER.
(let+ (((&structure-r/o filter- scope exact?) filter))
(declare (type scope scope))
(if exact?
(lambda (event)
(scope=/no-coerce (event-scope event) scope))
(lambda (event)
(sub-scope?/no-coerce (event-scope event) scope)))))
(defmethod print-items:print-items append ((object scope-filter))
`((:relation ,(if (filter-exact? object) #\= #\<) "~C")
(:scope ,(scope-string (filter-scope object)) " ~A"
((:after :relation)))))
| 2,028 | Common Lisp | .lisp | 47 | 34.595745 | 71 | 0.612969 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 127fa4bb4830d770cf8928e074ddc7653a64fc4a57048bde692022067cbe9924 | 25,324 | [
-1
] |
25,325 | xpath-filter.lisp | open-rsx_rsb-cl/src/filter/xpath-filter.lisp | ;;;; xpath-filter.lisp --- XPath-based filtering.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
;;; `xpath-filter' class
(defclass xpath-filter (function-caching-mixin
funcallable-filter-mixin
print-items:print-items-mixin)
((xpath :type xpath::xpath-expr
:reader filter-xpath
:writer (setf filter-%xpath)
:documentation
"The XPath used by the filter to discriminate events.")
(namespaces :initarg :namespaces
:type (or null (cons (cons string string) list))
:reader filter-namespaces
:initform '()
:documentation
"Stores a mapping of prefixes to namespace URIs as
an alist with elements of the form
(PREFIX . NAMESPACE-URI)
.")
(compiled-xpath :type function
:reader filter-compiled-xpath
:writer (setf filter-%compiled-xpath)
:documentation
"A compiled version of the XPath of the filter.")
(navigator :accessor filter-%navigator
:initform (xpath-navigator)
:documentation
"Stores the navigator to be used when evaluating
the xpath."))
(:metaclass closer-mop:funcallable-standard-class)
(:default-initargs
:xpath (missing-required-initarg 'xpath-filter :xpath))
(:documentation
"Discriminate events based on XPath expressions.
It is applicable to payloads for which an implementation of the
XPath interface is available. Examples include strings (via XML
parsing), XML DOM objects and protocol buffer messages."))
(service-provider:register-provider/class 'filter :xpath
:class 'xpath-filter)
(defmethod shared-initialize :after ((instance xpath-filter)
(slot-names t)
&key
(xpath nil xpath-supplied?)
(builder t builder-supplied?))
(when xpath-supplied?
(setf (filter-%xpath instance) xpath))
(when builder-supplied?
(setf (filter-%navigator instance) (xpath-navigator :builder builder))))
(defmethod (setf filter-%xpath) :before ((new-value t)
(filter xpath-filter))
(check-type new-value xpath::xpath-expr
"an XPath string or an XPath sexp expression")
(setf (filter-%compiled-xpath filter)
(let ((xpath::*dynamic-namespaces*
(append (filter-namespaces filter)
xpath::*dynamic-namespaces*)))
(xpath:compile-xpath new-value))))
(defmethod rsb.ep:access? ((processor xpath-filter)
(part t)
(mode (eql :read)))
t)
(defmethod compute-filter-function ((filter xpath-filter) &key next)
(declare (ignore next))
(let+ (((&structure-r/o filter- compiled-xpath %navigator) filter))
(lambda (event)
(xpath-result->filter-result
%navigator
(architecture.builder-protocol.xpath:evaluate-using-navigator
compiled-xpath %navigator event :node-order nil)))))
(defmethod print-items:print-items append ((object xpath-filter))
`((:xpath ,(filter-xpath object) "~S")))
;;; Utility functions
(defun xpath-navigator (&key (builder t))
(make-instance 'architecture.builder-protocol.xpath:navigator
:builder builder
:peek-function (rsb.builder:universal-builder-for-event-data)
:printers `((,(lambda (builder node)
(declare (ignore builder))
(typep node 'scope))
.
,(lambda (builder node)
(declare (ignore builder))
(scope-string node)))
(,(lambda (builder node)
(declare (ignore builder))
(typep node '(or uuid:uuid local-time:timestamp)))
.
,(lambda (builder node)
(declare (ignore builder))
(princ-to-string node))))))
(defun xpath-result->filter-result (navigator result)
;; Return a non-nil if RESULT represents a matching XPath result and
;; nil otherwise.
(typecase result
(xpath:node-set (let ((xpath:*navigator* navigator))
(not (xpath:node-set-empty-p result))))
(t (architecture.builder-protocol.xpath:unwrap
navigator result))))
| 5,047 | Common Lisp | .lisp | 103 | 33.990291 | 88 | 0.53946 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | a6b9e3c53a9e7e5f6325dbc1e9933a0f2bc5fa476318ade0c32419207b081c57 | 25,325 | [
-1
] |
25,326 | type-filter.lisp | open-rsx_rsb-cl/src/filter/type-filter.lisp | ;;;; type-filter.lisp --- A filter that discriminates event based on their type.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.filter)
(defclass type-filter (function-caching-mixin
funcallable-filter-mixin
payload-matching-mixin
print-items:print-items-mixin)
((type :initarg :type
:type (or list symbol)
:reader filter-type
:documentation
"The type of matching events."))
(:metaclass closer-mop:funcallable-standard-class)
(:default-initargs
:type (missing-required-initarg 'type-filter :type))
(:documentation
"Discriminate based on the type of event payloads."))
(service-provider:register-provider/class 'filter :type
:class 'type-filter)
(defmethod compute-filter-function ((filter type-filter) &key next)
(declare (ignore next))
(let+ ((type (filter-type filter))
((&values function &ign failure?)
(block compile
(handler-bind (((and warning (not style-warning))
(lambda (condition)
(return-from compile (values nil condition t)))))
(let ((*error-output* (make-broadcast-stream)))
(with-compilation-unit (:override t)
(compile nil `(lambda (payload)
(typep payload ',type)))))))))
(when failure?
(error 'simple-type-error
:datum type
:type '(or cons symbol)
:format-control "~@<~S is not a valid type specifier.~@:>"
:format-arguments (list type)))
function))
(defmethod print-items:print-items append ((object type-filter))
`((:type ,(filter-type object))))
| 1,857 | Common Lisp | .lisp | 43 | 33.55814 | 80 | 0.589276 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 552fc814630e2012bfabb959f998c2f4be4e9a190e5f463fff04751b0a681255 | 25,326 | [
-1
] |
25,327 | package.lisp | open-rsx_rsb-cl/src/converter/package.lisp | ;;;; package.lisp --- Package definition for converter module.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.converter
(:nicknames :rsb.conv)
(:use
#:cl
#:alexandria
#:let-plus
#:iterate
#:more-conditions
#:nibbles
#:rsb)
;; Conditions
(:export
#:conversion-error
#:conversion-error-wire-schema
#:wire->domain-conversion-error
#:conversion-error-encoded
#:conversion-error-domain-type
#:domain->wire-conversion-error
#:conversion-error-domain-object
#:conversion-error-wire-type)
;; Converter protocol
(:export
#:domain->wire?
#:wire->domain?
#:domain->wire
#:wire->domain)
;; Converter service and creation
(:export
#:converter ; service
#:make-converter)
;; Converter mixins
(:export
#:wire->domain-cache-mixin
#:domain->wire-cache-mixin)
;; Caching converter
(:export
#:caching-converter
#:converter-target)
;; void converter
(:export
#:+no-value+ ; marker value
#:no-value ; type
)
;; `force-wire-schema' converter class
(:export
#:force-wire-schema
#:converter-wire-schema)
(:documentation
"This package contains mechanisms for converting between domain
object (which are Lisp object) and data representation in
different kinds of wire formats."))
| 1,394 | Common Lisp | .lisp | 56 | 21.214286 | 66 | 0.69161 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 81cae0b03f66e38e859e28c706613c65dcda4a63cd138645208dfa18fc1a2b77 | 25,327 | [
-1
] |
25,328 | fundamental.lisp | open-rsx_rsb-cl/src/converter/fundamental.lisp | ;;;; fundamental.lisp --- Converters for fundamental types.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
;;; Special fundamental converters
(defconstant +no-value+ '%no-value
"This object is used to represent the absence of a value.")
(deftype no-value ()
"Instances of this type represent the absence of a value."
'(eql %no-value))
;; "No payload" case. Lisp: `+no-value+' marker. Wire: empty octet
;; vector.
(define-constant +empty-wire-data+
(make-array 0 :element-type '(unsigned-byte 8))
:test #'equalp)
(define-simple-converter (:fundamental-void :void no-value
:wire-type (simple-array (unsigned-byte 8) (0))
:data-type-class (eql +no-value+))
(+no-value+)
(+empty-wire-data+))
;; In some settings (e.g. bridge), it can happen that we want to send
;; an event containing the `%dropped-payload' marker as its
;; payload. These methods translate such a payload into a void payload
;; on the wire. The reason for identifying the marker via `string=' is
;; avoiding dependencies between the converter and transform modules.
(defmethod domain->wire? ((converter (eql :fundamental-void))
(domain-object symbol))
(when (string= domain-object '#:%dropped-payload)
(values converter '(simple-array (unsigned-byte 8) (0)) :void)))
(defmethod domain->wire ((converter (eql :fundamental-void))
(domain-object symbol))
(if (string= domain-object '#:%dropped-payload)
(values +empty-wire-data+ :void)
(error "~<Cannot convert domain object: ~S.~@:>" domain-object)))
;; "No conversion" case. Use domain object as wire data and vice
;; versa.
(define-simple-converter (:fundamental-null t t
:wire-type t
:wire-type-class t)
(wire-data)
(domain-object))
;;; Numeric fundamental types
(define-simple-converter (:fundamental-bool :bool boolean
:data-type-class t)
((case (aref wire-data 0)
(0 nil)
(1 t)
(t (error "~@<Invalid value: ~D~@:>"
(aref wire-data 0)))))
((octet-vector (if domain-object 1 0))))
(macrolet
((define-number-converter (wire-schema data-type size accessor
&key data-type-class)
(let ((name (format-symbol :keyword "FUNDAMENTAL-~A" wire-schema)))
`(define-simple-converter (,name ,wire-schema ,data-type
,@(when data-type-class
`(:data-type-class ,data-type-class)))
((,accessor wire-data 0))
((let ((result (make-octet-vector ,size)))
(setf (,accessor result 0) domain-object)
result))))))
(define-number-converter :uint32 (unsigned-byte 32) 4 ub32ref/le
:data-type-class integer)
(define-number-converter :int32 (signed-byte 32) 4 sb32ref/le
:data-type-class integer)
(define-number-converter :uint64 (unsigned-byte 64) 8 ub64ref/le
:data-type-class integer)
(define-number-converter :int64 (signed-byte 64) 8 sb64ref/le
:data-type-class integer)
(define-number-converter :float single-float 4 ieee-single-ref/le)
(define-number-converter :double double-float 8 ieee-double-ref/le))
;;; Sequence-like fundamental types
(define-simple-converter
(:fundamental-ascii-string :ascii-string string)
((sb-ext:octets-to-string wire-data :external-format :ascii))
((sb-ext:string-to-octets domain-object :external-format :ascii)))
(define-simple-converter
(:fundamental-utf-8-string :utf-8-string string)
((sb-ext:octets-to-string wire-data :external-format :utf-8))
((sb-ext:string-to-octets domain-object :external-format :utf-8)))
(define-simple-converter
(:fundamental-bytes :bytes (vector (unsigned-byte 8))
:data-type-class simple-array)
(wire-data)
((coerce domain-object 'octet-vector)))
;;; RSB objects
(define-simple-converter
(:fundamental-scope :scope scope)
((make-scope (sb-ext:octets-to-string wire-data :external-format :ascii)))
((sb-ext:string-to-octets (scope-string domain-object))))
| 4,293 | Common Lisp | .lisp | 92 | 39.880435 | 79 | 0.649928 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ec58a7a307cc24841ecf478546a790525f9d36da59608bc929f931b641132dd9 | 25,328 | [
-1
] |
25,329 | protocol.lisp | open-rsx_rsb-cl/src/converter/protocol.lisp | ;;;; protocol.lisp --- Wire <-> domain conversion protocol.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
;;; Converter query protocol
(defgeneric wire->domain? (converter wire-data wire-schema)
(:documentation
"Return non-nil if CONVERTER can convert WIRE-DATA into a Lisp
object using the interpretation designated by WIRE-SCHEMA.
If such a conversion is possible, return two values: 1) CONVERTER
2) the type of the Lisp object that the conversion would produce.
Example:
RSB.CONVERTER> (wire->domain? :fundamental-utf-8-string #(102 111 111) :utf-8-string)
=> :fundamental-utf-8-string 'string"))
(defgeneric domain->wire? (converter domain-object)
(:documentation
"Return non-nil if CONVERTER can convert DOMAIN-OBJECT to its
wire-type.
If such a conversion is possible, return three values: 1)
CONVERTER 2) the wire-type 3) the wire-schema the conversion would
produce.
Example:
RSB.CONVERTER> (domain->wire? :fundamental-utf-8-string \"foo\")
=> :fundamental-utf-8-string 'octet-vector :utf-8-string"))
;; Default behavior
(defmethod no-applicable-method ((function (eql (fdefinition 'wire->domain?)))
&rest args)
;; If there is no method on `wire->domain?' for a given combination
;; of converter, wire-data and wire-schema, the converter cannot
;; handle the data.
(declare (ignore args))
nil)
(defmethod no-applicable-method ((function (eql (fdefinition 'domain->wire?)))
&rest args)
;; If there is no method on `domain->wire?' for a given pair of
;; converter and data, the converter cannot handle the data.
(declare (ignore args))
nil)
;;; Converter protocol
(defgeneric wire->domain (converter wire-data wire-schema)
(:documentation
"Decode WIRE-DATA into a Lisp object using an interpretation
according to WIRE-SCHEMA and CONVERTER. Return the decoded Lisp
object.
Example:
RSB.CONVERTER> (wire->domain :fundamental-string #(102 111 111) :string)
=> \"foo\""))
(defgeneric domain->wire (converter domain-object)
(:documentation
"Encode the Lisp object DOMAIN-OBJECT into the wire representation
associated to CONVERTER. Return two values: the constructed wire
representation and the wire-schema.
Example:
RSB.CONVERTER> (domain->wire :fundamental-string \"foo\")
=> #(102 111 111) :string"))
;; Default behavior
(defmethod wire->domain :around ((converter t)
(wire-data t)
(wire-schema t))
;; Establish "retry" and "use-value" restarts around the call to the
;; next `wire->domain' method.
(iter
(restart-case
(with-condition-translation
(((error wire->domain-conversion-error)
:wire-schema wire-schema
:encoded wire-data
:domain-type :undetermined))
(return (call-next-method)))
(retry ()
:report (lambda (stream)
(format stream "~@<Retry converting ~S (in ~S ~
schema) using converter ~A.~@:>"
wire-data wire-schema converter))
nil)
(use-value (value)
:report (lambda (stream)
(format stream "~@<Supply a replacement value ~
to use instead of converting ~
~S (in ~S schema) using ~
converter ~A.~@:>"
wire-data wire-schema converter))
:interactive (lambda ()
(format *query-io* "Enter replacement value (evaluated): ")
(list (read *query-io*)))
(return value)))))
(defmethod domain->wire :around ((converter t)
(domain-object t))
;; Establish "retry" and "use-value" restarts around the call to the
;; next `domain->wire' method.
(iter
(restart-case
(with-condition-translation
(((error domain->wire-conversion-error)
:wire-schema :undetermined
:domain-object domain-object
:wire-type :undetermined))
(return (call-next-method)))
(retry ()
:report (lambda (stream)
(format stream "~@<Retry converting ~A using ~
converter ~A.~@:>"
domain-object converter))
nil)
(use-value (value)
:report (lambda (stream)
(format stream "~@<Supply a replacement value ~
to use instead of converting ~A ~
using converter ~A.~@:>"
domain-object converter))
:interactive (lambda ()
(format *query-io* "Enter replacement value (evaluated): ")
(list (read *query-io*)))
(return value)))))
;;; Converter implementations
(service-provider:define-service converter
(:documentation
"Providers convert payload to a particular wire-type."))
(defun make-converter (name &rest args)
"Construct an instance of the converter class designated by NAME
using ARGS as initargs."
(apply #'service-provider:make-provider 'converter name args))
| 5,498 | Common Lisp | .lisp | 124 | 34.080645 | 89 | 0.59772 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ef90a3889ea49d31a795ab15c1492dec18ff1a2caaccdb748a2717a8242fa047 | 25,329 | [
-1
] |
25,330 | reader.lisp | open-rsx_rsb-cl/src/converter/reader.lisp | ;;;; reader.lisp --- A converter that uses the Lisp reader/printer.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(defun %normalize-type (type-specifier)
(cond
((subtypep type-specifier 'string)
'string)
((subtypep type-specifier 'vector)
'vector)
((subtypep type-specifier 'integer)
'integer)
(t
type-specifier)))
(defmethod wire->domain? ((converter (eql :reader))
(wire-data string)
(wire-schema t))
(values converter wire-schema))
(defmethod domain->wire? ((converter (eql :reader))
(domain-object t))
(values converter
'string
(%normalize-type (type-of domain-object))))
(defmethod wire->domain ((converter (eql :reader))
(wire-data string)
(wire-schema t))
(with-standard-io-syntax
(read-from-string wire-data)))
(defmethod wire->domain :around ((converter (eql :reader))
(wire-data string)
(wire-schema t))
(let ((expected-type wire-schema)
(result (call-next-method)))
(unless (typep result expected-type)
(error 'wire->domain-conversion-error
:wire-schema wire-schema
:encoded wire-data
:domain-type expected-type
:format-control "~@<The value is not ~A is not of the ~
expected type ~A.~@:>"
:format-arguments `(,result ,expected-type)))
result))
(defmethod domain->wire ((converter (eql :reader))
(domain-object t))
(values
(with-standard-io-syntax
(prin1-to-string domain-object))
(%normalize-type (type-of domain-object))))
| 1,926 | Common Lisp | .lisp | 50 | 28.96 | 70 | 0.560193 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 82dc2291a452a4db2ac09eceda076779240a5155221a74eed4c0396793fdbfdc | 25,330 | [
-1
] |
25,331 | conditions.lisp | open-rsx_rsb-cl/src/converter/conditions.lisp | ;;;; conditions.lisp --- Conditions used in the converter module.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(define-condition conversion-error (rsb-error
chainable-condition)
((wire-schema :initarg :wire-schema
:type symbol
:reader conversion-error-wire-schema
:documentation
"This wire-schema to or from which the failed
conversion would have converted."))
(:documentation
"This condition class can be used as a superclass for
conversion-related condition classes."))
(define-condition wire->domain-conversion-error (conversion-error)
((encoded :initarg :encoded
:type t
:reader conversion-error-encoded
:documentation
"The wire-data that could not be converted into a
domain object.")
(domain-type :initarg :domain-type
:type t
:reader conversion-error-domain-type
:documentation
"The type of the domain object object that would have
been produced by a successful conversion."))
(:report
(lambda (condition stream)
(let+ (((&structure-r/o conversion-error- wire-schema encoded domain-type)
condition)
(octet-sequence? (and (typep encoded 'sequence)
(every (of-type 'octet) encoded))))
(format stream "~@<The wire-data~
~:@_~:@_~
~<│ ~@;~:[~S~:;~,,,16@:/utilities.binary-dump:print-binary-dump/~]~:>~
~:@_~:@_~
(in ~S wire-schema) could not be converted to ~
domain type ~:_~S.~
~/more-conditions:maybe-print-cause/~:>"
(list octet-sequence? encoded) wire-schema domain-type
condition))))
(:documentation
"This error is signaled when wire data cannot be converted to a
domain object."))
(define-condition domain->wire-conversion-error (conversion-error)
((domain-object :initarg :domain-object
:type t
:reader conversion-error-domain-object
:documentation
"The domain object that could not be converter into
a wire representation.")
(wire-type :initarg :wire-type
:type t
:reader conversion-error-wire-type
:documentation
"The type of the wire-data that would have been
produced by a successful conversion."))
(:report
(lambda (condition stream)
(let+ (((&structure-r/o conversion-error- wire-schema domain-object wire-type)
condition))
(format stream "~@<The domain object ~S could not be converted ~
to a wire-type ~S representation using the ~
wire-schema ~
~S.~/more-conditions:maybe-print-cause/~@:> "
domain-object wire-type wire-schema condition))))
(:documentation
"This error is signaled when a domain object cannot be converted to
a wire-type representation."))
| 3,405 | Common Lisp | .lisp | 73 | 33.726027 | 95 | 0.561298 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5bf7e68c4d30398821e5b450f03ff3cf62f8cb8c74229d30ead3c7f53cbdcb0a | 25,331 | [
-1
] |
25,332 | annotating.lisp | open-rsx_rsb-cl/src/converter/annotating.lisp | ;;;; annotating.lisp --- Annotates unconverted wire-data with wire-schema
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(defclass annotating ()
()
(:documentation
"This converter returns the unconverted wire-data annotated with
the wire-schema."))
(service-provider:register-provider/class
'converter :annotating :class 'annotating)
(defstruct (annotated
(:constructor make-annotated (wire-data wire-schema))
(:predicate nil)
(:copier nil))
(wire-data nil :read-only t)
(wire-schema nil :read-only t))
(defmethod wire->domain? ((converter annotating)
(wire-data t)
(wire-schema t))
;; The converter can handle arbitrary wire-data.
(values converter 'annotated))
(defmethod domain->wire? ((converter annotating)
(domain-object annotated))
;; The converter can handle annotations it previously produced.
(let+ (((&structure-r/o annotated- wire-data wire-schema) domain-object))
(values converter (type-of wire-data) wire-schema)))
(defmethod wire->domain ((converter annotating)
(wire-data t)
(wire-schema t))
;; The wire-data is not modified, but the wire-schema is attached.
(make-annotated wire-data wire-schema))
(defmethod domain->wire ((converter annotating)
(domain-object annotated))
;; The domain object is not modified, but it is separated from the
;; wire-schema.
(let+ (((&structure-r/o annotated- wire-data wire-schema) domain-object))
(values wire-data wire-schema)))
| 1,740 | Common Lisp | .lisp | 40 | 36.45 | 75 | 0.653073 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6d3237891638c1954c9db30a1f160884959849be947dd0437c2452833d4b28be | 25,332 | [
-1
] |
25,333 | force-wire-schema.lisp | open-rsx_rsb-cl/src/converter/force-wire-schema.lisp | ;;;; force-wire-schema.lisp --- A converter that sets a given wire-schema.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(defclass force-wire-schema ()
((wire-schema :initarg :wire-schema
:type keyword
:accessor converter-wire-schema
:initform :bytes
:documentation
"Stores the wire-schema that should be used when
performing domain->wire \"conversions\"."))
(:documentation
"Attaches a given wire-schema and passes through the data.
Do not perform any changes when converting between wire-data and
domain-data in either direction but set a given wire-schema when
producing wire-data, wire-schema pairs."))
(service-provider:register-provider/class
'converter :force-wire-schema :class 'force-wire-schema)
(defmethod wire->domain? ((converter force-wire-schema)
(wire-data t)
(wire-schema t))
;; The converter can handle arbitrary wire-data.
(values converter t))
(defmethod domain->wire? ((converter force-wire-schema)
(domain-object t))
;; The converter can handle arbitrary domain objects.
(let+ (((&structure-r/o converter- wire-schema) converter))
(values converter t wire-schema)))
(defmethod wire->domain ((converter force-wire-schema)
(wire-data t)
(wire-schema t))
;; The wire-data is not modified.
wire-data)
(defmethod domain->wire ((converter force-wire-schema)
(domain-object t))
;; The domain object is not modified, but the configured wire-schema
;; is set.
(let+ (((&structure-r/o converter- wire-schema) converter))
(values domain-object wire-schema)))
(defmethod print-object ((object force-wire-schema) stream)
(print-unreadable-object (object stream :type t :identity t)
(format stream "~A" (converter-wire-schema object))))
| 2,077 | Common Lisp | .lisp | 45 | 38.244444 | 74 | 0.647553 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b9145b44cf29d30c44159713baa47483d602179239d06d2e4d7f46ffbea377ea | 25,333 | [
-1
] |
25,334 | caching.lisp | open-rsx_rsb-cl/src/converter/caching.lisp | ;;;; caching.lisp --- Caches {wire->domain,domain->wire}? and delegates.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(defclass caching-converter (wire->domain-cache-mixin
domain->wire-cache-mixin)
((target :initarg :target
:reader converter-target
:documentation
"Stores the target converter for which
{wire->domain,domain->wire}? queries should be cached."))
(:default-initargs
:target (missing-required-initarg 'caching-converter :target))
(:documentation
"Caches {wire->domain,domain->wire}? queries to a target converter."))
(service-provider:register-provider/class
'rsb.converter::converter :caching :class 'caching-converter)
(defmethod wire->domain? ((converter caching-converter)
(wire-data t)
(wire-schema t))
(wire->domain? (converter-target converter) wire-data wire-schema))
(defmethod domain->wire? ((converter caching-converter)
(domain-object t))
(domain->wire? (converter-target converter) domain-object))
;;; The following two methods are provided for convenience and should
;;; not be called normally: `wire->domain?' and `domain->wire?' are
;;; supposed to be called first and return the converter that should
;;; be used in the `wire->domain' and `domain->wire' calls. This
;;; returned converter will never be the caching converter but the
;;; target converter (or another converter the target converter
;;; delegates to).
(defmethod wire->domain ((converter caching-converter)
(wire-data t)
(wire-schema t))
(let ((converter (or (wire->domain? converter wire-data wire-schema)
(converter-target converter))))
(wire->domain converter wire-data wire-schema)))
(defmethod domain->wire ((converter caching-converter)
(domain-object t))
(let ((converter (or (domain->wire? converter domain-object)
(converter-target converter))))
(domain->wire converter domain-object)))
| 2,220 | Common Lisp | .lisp | 44 | 42.409091 | 73 | 0.653137 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 48edbaef3136c584629f35c3cc007ef4dfffe1fc321603e4d65a8873ba9d02c9 | 25,334 | [
-1
] |
25,335 | macros.lisp | open-rsx_rsb-cl/src/converter/macros.lisp | ;;;; macros.lisp --- Macros related to defining converters.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(defmacro define-simple-converter ((name wire-schema data-type
&key
(wire-type 'octet-vector)
(wire-type-class 'simple-array)
(data-type-class data-type data-type-class-supplied?))
(&body wire->domain)
(&body domain->wire))
"Define a converter named NAME that acts on the triple
\(WIRE-TYPE WIRE-SCHEMA DATA-TYPE)
as specified by the forms WIRE->DOMAIN and DOMAIN->WIRE.
The WIRE->DOMAIN form receives the wire-data and wire-schema in
variables called WIRE-DATA and WIRE-SCHEMA. The form should return
a single value which is the deserialized domain object.
The DOMAIN->WIRE form receives the domain object in a variable
called DOMAIN-OBJECT. The form has to return a single value which
is the serialized representation of the domain object."
(let ((specializer (typecase wire-schema
(keyword `(eql ,wire-schema))
(t wire-schema))))
`(progn
(defmethod wire->domain? ((converter (eql ,name))
(wire-data ,wire-type-class)
(wire-schema ,specializer))
(when (typep wire-data ',wire-type)
(values converter ',data-type)))
(defmethod domain->wire? ((converter (eql ,name))
(domain-object ,data-type-class))
,(let ((return `(values converter ',wire-type ,wire-schema)))
(if data-type-class-supplied?
`(when (typep domain-object ',data-type)
,return)
return)))
(defmethod wire->domain ((converter (eql ,name))
(wire-data ,wire-type-class)
(wire-schema ,specializer))
(check-type wire-data ,wire-type)
,@wire->domain)
(defmethod domain->wire ((converter (eql ,name))
(domain-object ,data-type-class))
(check-type domain-object ,data-type)
(values (progn ,@domain->wire) ,wire-schema)))))
| 2,475 | Common Lisp | .lisp | 47 | 37.702128 | 95 | 0.544063 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | da2f9c8fceb10466ae98ca00c556b506f9fcd906a24c16b4d506574be2015eb2 | 25,335 | [
-1
] |
25,336 | mixins.lisp | open-rsx_rsb-cl/src/converter/mixins.lisp | ;;;; mixins.lisp --- Mixin classes for converter classes.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
;;; `wire->domain-cache-mixin'
(defclass wire->domain-cache-mixin ()
((wire->domain-cache :type hash-table
:reader converter-%wire->domain-cache
:initform (make-hash-table :test #'eq)
:documentation
"Stores a cache for values returned by the
`wire->domain?' method."))
(:documentation
"This class is intended to be mixed into converter classes that
perform expensive but cachable computations in the `wire->domain?'
method.
Caching is performed on the WIRE-SCHEMA argument using `eq'
comparison."))
(defmethod wire->domain? :around ((converter wire->domain-cache-mixin)
(wire-data t)
(wire-schema t))
(values-list (ensure-gethash
wire-schema (converter-%wire->domain-cache converter)
(multiple-value-list (call-next-method)))))
;;; `domain->wire-cache-mixin'
(defclass domain->wire-cache-mixin ()
((domain->wire-cache :type hash-table
:reader converter-%domain->wire-cache
:initform (make-hash-table :test #'eq)
:documentation
"Stores a cache for the values returned by the
`domain->wire?' method."))
(:documentation
"This class is intended to be mixed into converter classes that
perform expensive but cachable computations in the `wire->domain?'
method.
Caching is performed on the `class-of' the DOMAIN-OBJECT argument
using `eq' comparison."))
(defmethod domain->wire? :around ((converter domain->wire-cache-mixin)
(domain-object t))
(values-list (ensure-gethash
(class-of domain-object)
(converter-%domain->wire-cache converter)
(multiple-value-list (call-next-method)))))
| 2,175 | Common Lisp | .lisp | 46 | 36 | 74 | 0.592453 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2e1407c62a0c4d8bcb7e4780af2ce2fee6095aa32af7d502b2366ab0cc3427df | 25,336 | [
-1
] |
25,337 | protocol-buffers.lisp | open-rsx_rsb-cl/src/converter/protocol-buffers.lisp | ;;;; protocol-buffers.lisp --- Converter for protocol buffer wire schemas.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.converter)
(defmethod wire->domain? ((converter (eql :protocol-buffer))
(wire-data simple-array)
(wire-schema symbol))
(when-let* ((descriptor (pb:find-descriptor wire-schema :error? nil))
(class (pb:descriptor-class descriptor :error? nil)))
(let ((classes (list (load-time-value (find-class 'simple-array)) class)))
(declare (dynamic-extent classes))
(when (c2mop:compute-applicable-methods-using-classes
#'pb:unpack classes)
(values converter (class-name class))))))
(defmethod domain->wire? ((converter (eql :protocol-buffer))
(domain-object standard-object))
(let* ((class (class-of domain-object))
(classes (list class)))
(declare (dynamic-extent classes))
(when (c2mop:compute-applicable-methods-using-classes
#'pb:pack classes)
(values converter 'octet-vector (class-name class)))))
(defmethod wire->domain ((converter (eql :protocol-buffer))
(wire-data simple-array)
(wire-schema symbol))
(check-type wire-data octet-vector)
(let* ((descriptor (pb:find-descriptor (string wire-schema)))
(class (pb:descriptor-class descriptor)))
(nth-value 0 (pb:unpack wire-data class))))
(defmethod domain->wire ((converter (eql :protocol-buffer))
(domain-object standard-object))
(let* ((descriptor (pb:message-descriptor domain-object))
(wire-schema (intern (pb:descriptor-qualified-name descriptor)
:keyword)))
(values (pb:pack* domain-object) wire-schema)))
| 1,904 | Common Lisp | .lisp | 37 | 42.108108 | 78 | 0.620097 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8ec05305998a5c9062f076a0a2c1203e85ee2a1cde1dbb5cf008c3c8123a4bd6 | 25,337 | [
-1
] |
25,338 | transport.lisp | open-rsx_rsb-cl/src/transport/transport.lisp | ;;;; transport.lisp --- First class transport objects.
;;;;
;;;; Copyright (C) 2015, 2016, 2017, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
;;; Constructing a connector instance involves two services and works
;;; roughly like this:
;;;
;;; TRANSPORT-SERVICE TRANSPORT-INSTANCE : `transport'
;;; (make-provider │ │
;;; 'transport │ │
;;; (SCHEMA . DIRECTION)) │ │
;;; ─────────────────────────▷│ │
;;; │ (make-provider │
;;; │ TRANSPORT-INSTANCE │
;;; │ DIRECTION │
;;; │ :schema SCHEMA) │
;;; │────────────────────▷│
;;; │ │
;;; │ │──▷CONNECTOR-INSTANCE
;;; │ │ │
;;; │ │ │
;;;
;;; Note that TRANSPORT-INSTANCE is an instance of the `transport'
;;; class and acts as
;;;
;;; 1) a provider of TRANSPORT-SERVICE (the service
;;; registered under the name 'transport)
;;;
;;; 2) a service the providers of which are connectors for different
;;; directions (i.e. :in-pull, :in-pull and :out)
;;; `transport' class
(defclass transport (service-provider:standard-service)
((schemas :type list
:reader transport-schemas
:accessor transport-%schemas
:documentation
"Stores a list of schemas supported by the transport.")
(wire-type :initarg :wire-type
:reader transport-wire-type
:documentation
"Stores the wire-type of the transport.")
(remote? :initarg :remote?
:reader transport-remote?
:initform t
:documentation
"True if the transport implements remote
communication."))
(:default-initargs
:schemas (missing-required-initarg 'transport :schemas)
:wire-type (missing-required-initarg 'transport :wire-type))
(:documentation
"Instances of this class represent transport implementations.
Each transport instance is registered as a provider of the
`transport' but is also itself a service and the associated
connectors are providers of that service."))
(defmethod shared-initialize :after ((instance transport)
(slot-names t)
&key
(schemas nil schemas-supplied?))
(when schemas-supplied?
(setf (transport-%schemas instance) (ensure-list schemas))))
(defmethod print-items:print-items append ((object transport))
`((:remote? ,(transport-remote? object) " ~:[local~:;remote~]"
((:after :provider-count)))))
(defmethod describe-object ((object transport) stream)
(format stream "~A~
~2&Schemas: ~{~S~^, ~}~
~&Wire-type: ~S~
~&Remote: ~S~
~@[~2&Connectors:~
~&~{~A~^~&~}~]~
~@[~2&Documentation:~&~A~]"
object
(transport-schemas object)
(transport-wire-type object)
(transport-remote? object)
(service-provider:service-providers object)
(documentation object t)))
(defmethod service-provider:provider-name ((provider transport))
(service-provider:service-name provider))
(defmethod service-provider:make-provider
((service t) (provider transport)
&rest args &key
(schema (missing-required-argument :schema))
(direction (missing-required-argument :direction)))
(declare (ignore schema))
;; PROVIDER is also a service:
(apply #'service-provider:make-provider provider direction
(remove-from-plist args :direction)))
;;; `connector-provider'
(defclass connector-provider (service-provider:class-provider)
()
(:documentation
"Provider class for connector classes."))
(defmethod shared-initialize :after ((instance connector-provider)
(slot-names t)
&key)
(closer-mop:finalize-inheritance
(service-provider:provider-class instance)))
;;; Registration
(defun register-transport (name &rest initargs
&key
(transport-class 'transport)
&allow-other-keys)
(apply #'service-provider:register-provider
'transport name transport-class
(remove-from-plist initargs :transport-class)))
(defun register-connector (transport-name direction class-name)
(check-type direction direction "one of :IN-PUSH, :IN-PULL, :OUT")
(service-provider:register-provider
(service-provider:find-provider 'transport transport-name)
direction 'connector-provider :class class-name))
| 5,268 | Common Lisp | .lisp | 114 | 37.22807 | 76 | 0.554797 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 71e682c0f1e3c373ec16f30e6c1dd5462fc336be30fd64d0a1b072316ea6d33b | 25,338 | [
-1
] |
25,339 | connector-mixins.lisp | open-rsx_rsb-cl/src/transport/connector-mixins.lisp | ;;;; connector-mixins.lisp --- Mixin for connector classes.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
;;; Mixin class `error-handling-pull-receiver-mixin'
(defclass error-handling-pull-receiver-mixin (error-policy-mixin)
()
(:documentation
"This class is intended to be mixed into in-direction, pull-style
connector classes to provide client-supplied error handling policies
for the `emit' method."))
(defmethod emit :around ((connector error-handling-pull-receiver-mixin)
(block? t))
;; Call the actual `emit' method with a condition handler that
;; applies the error policy of CONNECTOR.
(with-error-policy (connector) (call-next-method)))
;;; Mixin class `error-handling-push-receiver-mixin'
(defclass error-handling-push-receiver-mixin (error-policy-mixin)
()
(:documentation
"This class is intended to be mixed into in-direction, push-style
connector classes to provide client-supplied error handling policies
for the `receive-messages' method."))
(defmethod receive-messages :around ((connector error-handling-push-receiver-mixin))
;; Call the actual `receive-messages' method with a condition
;; handler that applies the error policy of CONNECTOR.
(with-error-policy (connector) (call-next-method)))
;;; Mixin class `error-handling-sender-mixin'
;;;
;;; Note: almost identical to `rsb.ep:error-policy-handler-mixin' but
;;; not completely. Differences: 1) semantic difference 2) method is
;;; specialized on `event' instead of `t'.
(defclass error-handling-sender-mixin (error-policy-mixin)
()
(:documentation
"This class is intended to be mixed into out-direction connector
classes to provide client-supplied error handling policies for the
`handle' method."))
(defmethod handle :around ((sink error-handling-sender-mixin)
(data event))
;; Call the actual `handle' method with a condition handler that
;; applies the error policy of CONNECTOR.
(with-error-policy (sink) (call-next-method)))
;;; Mixin class `restart-notification-sender-mixin'
(defclass restart-notification-sender-mixin ()
()
(:documentation
"This class is intended to be mixed into connector classes that
have to provide the usual restarts when sending notifications in a
`send-notification' method and converting the events to notifications
in a `event->notification' method."))
(defmethod send-notification :around ((connector restart-notification-sender-mixin)
(notification t))
;; Call the next method with `continue' restart established which
;; discards NOTIFICATION.
(restart-case
(call-next-method)
(continue (&optional condition)
:test (lambda (condition)
(typep condition '(not connection-closed)))
:report (lambda (stream)
(format stream "~@<Ignore the failed sending attempt ~
and continue with the next ~
notification.~@:>"))
(declare (ignore condition)))))
(defmethod event->notification :around ((connector restart-notification-sender-mixin)
(notification t))
;; Call the next method with `continue' restart established that
;; causes NOTIFICATION to be discarded.
(restart-case
(call-next-method)
(continue (&optional condition)
:report (lambda (stream)
(format stream "~@<Ignore the failed encoding and ~
continue with the next event.~@:>"))
(declare (ignore condition)))))
;;; Mixin class `restart-notification-receiver-mixin'
(defclass restart-notification-receiver-mixin ()
()
(:documentation
"This class is intended to be mixed into connector classes that
have to provide the usual restarts when receiving notifications in a
`receive-notification' method and converting the received
notifications to events in a `notification->event' method."))
(defmethod receive-notification :around ((connector restart-notification-receiver-mixin)
(block? t))
;; Call the next method with `continue' restart established that
;; retries receiving a notification.
(iter (restart-case
(return-from receive-notification (call-next-method))
(continue (&optional condition)
:test (lambda (condition)
(typep condition '(not connection-closed)))
:report (lambda (stream)
(format stream "~@<Ignore the failed receiving ~
attempt and continue with the ~
next notification.~@:>"))
(declare (ignore condition))))))
(defmethod notification->event :around ((connector restart-notification-receiver-mixin)
(notification t)
(wire-schema t))
;; Call the next method with `continue' restart established that
;; causes the call to return nil instead of an `event' instance.
(restart-case
(call-next-method)
(continue (&optional condition)
:report (lambda (stream)
(format stream "~@<Ignore the failed decoding and ~
continue with the next event.~@:>"))
(declare (ignore condition)))))
;;; Mixin class `conversion-mixin'
(defclass conversion-mixin ()
((converter :initarg :converter
:accessor connector-converter
:documentation
"A converter to which the actual conversion work is
delegated."))
(:default-initargs
:converter (missing-required-initarg 'conversion-mixin :converter))
(:documentation
"This mixin adds methods on `domain->wire' and `wire->domain' for
the subclass which delegate the conversion tasks to a stored
converter."))
(defmethod domain->wire ((connector conversion-mixin)
(domain-object t))
;; Delegate conversion of DOMAIN-OBJECT to the converter stored in
;; CONNECTOR.
(domain->wire (connector-converter connector) domain-object))
(defmethod wire->domain ((connector conversion-mixin)
(wire-data t)
(wire-schema t))
;; Delegate the conversion of WIRE-DATA, WIRE-SCHEMA to the
;; converter stored in CONNECTOR.
(wire->domain (connector-converter connector) wire-data wire-schema))
(defmethod print-object ((object conversion-mixin) stream)
(let+ (((&structure-r/o connector- converter) object)
(sequence? (typep converter 'sequence)))
(print-unreadable-object (object stream :type t :identity t)
(format stream "~:[~S~;(~D)~]"
sequence? (if sequence? (length converter) converter)))))
;;; Mixin class `timestamping-receiver-mixin'
(defclass timestamping-receiver-mixin ()
()
(:documentation
"This class is intended to be mixed into connector classes that
perform two tasks:
1) receive notifications
2) decode received notifications
The associated protocol is designed to be
direction-agnostic (i.e. should work for both push and pull)."))
(defmethod notification->event :around ((connector timestamping-receiver-mixin)
(notification t)
(wire-schema t))
;; Add a :receive timestamp to the generated event, if any.
(when-let ((event (call-next-method)))
(setf (timestamp event :receive) (local-time:now))
event))
;;; Mixin class `timestamping-sender-mixin'
(defclass timestamping-sender-mixin ()
()
(:documentation
"This class is intended to be mixed into connector classes that
send events."))
(defmethod event->notification :before ((connector timestamping-sender-mixin)
(event event))
(setf (timestamp event :send) (local-time:now)))
;;; `expose-transport-metrics-mixin'
(defclass expose-transport-metrics-mixin ()
((expose :type list
:accessor connector-expose
:initform '()
:documentation
"Controls which metrics of received notifications the
connector should expose in events constructed from these
notifications."))
(:metaclass connector-class)
(:options
(:expose &slot expose))
(:documentation
"This class is intended to be mixed into connector classes that
should be able to store transport metrics of received notifications in
the events constructed from the notifications."))
(defmethod shared-initialize :after ((instance expose-transport-metrics-mixin)
(slot-names t)
&key
(expose '() expose-supplied?))
(when expose-supplied?
(setf (connector-expose instance) expose)))
(defmethod connector-expose? ((connector expose-transport-metrics-mixin)
(metric symbol))
(declare (notinline member))
(member metric (connector-expose connector) :test #'eq))
(defmethod (setf connector-expose?) ((new-value (eql nil))
(connector expose-transport-metrics-mixin)
(metric symbol))
(removef (connector-expose connector) metric)
new-value)
(defmethod (setf connector-expose?) ((new-value t)
(connector expose-transport-metrics-mixin)
(metric symbol))
(pushnew metric (connector-expose connector))
new-value)
(defmethod (setf connector-expose) ((new-value symbol)
(connector expose-transport-metrics-mixin))
(setf (connector-expose connector) (list new-value))
new-value)
;;; Mixin class `threaded-receiver-mixin'
(defclass threaded-receiver-mixin ()
((thread :type (or null bt:thread)
:accessor connector-thread
:reader connector-started?
:initform nil
:documentation
"Stores the receiver thread of the
connector. Additionally used to indicate the state of the connector,
i.e. if non-nil thread is running and did its setup stuff.")
(control-mutex :reader connector-control-mutex
:initform (bt:make-recursive-lock
"Receiver Control Mutex")
:documentation
"Required for thread startup synchronization.")
(control-condition :reader connector-control-condition
:initform (bt:make-condition-variable
:name "Receiver Control Condition")
:documentation
"Required for thread startup synchronization."))
(:documentation
"This mixin class is intended to be mixed into message receiving
connector classes which want do so in a dedicated thread. This mixin
class takes care of managing the starting and joining of the
thread."))
(defmethod start-receiver ((connector threaded-receiver-mixin))
(let+ (((&structure connector- started? control-mutex control-condition)
connector))
;; Launch the thread.
(log:debug "~@<~A is starting worker thread~@:>" connector)
(bt:make-thread (curry #'receive-messages connector)
:name (format nil "Worker for ~A" connector))
;; Wait until the thread has entered `receive-messages'.
(bt:with-lock-held (control-mutex)
(iter (until started?)
(bt:condition-wait control-condition control-mutex)))
(log:debug "~@<~A started worker thread~@:>" connector)))
(defmethod stop-receiver ((connector threaded-receiver-mixin))
(let+ (((&structure connector- thread control-mutex) connector))
(bt:with-lock-held (control-mutex)
(cond
;; If there is no thread, do nothing.
((not thread))
;; If this is called from the receiver thread, there is no
;; need for an interruption. We can just unwind normally.
((eq thread (bt:current-thread))
(log:debug "~@<~A is in receiver thread; aborting~@:>" connector)
(exit-receiver))
;; If a second thread is trying to stop the receiver thread,
;; try joining and fall back to interrupting.
(t
(iter (while (bt:thread-alive-p thread))
;; The thread should be terminating or already have
;; terminated.
(log:debug "~@<~A is joining receiver thread~@:>" connector)
(handler-case
(when
#-sbcl (bt:with-timeout (2) (bt:join-thread thread) t)
#+sbcl (not (eq (nth-value
1 (sb-thread:join-thread
thread :timeout 2 :default nil))
:timeout))
(return))
#-sbcl (bt:timeout ())
(error (condition)
(log:warn "~@<~A failed to join receiver thread ~A: ~
~A Giving up~@:>"
connector thread condition)
(return)))
(log:warn "~@<~A timed out joining receiver thread ~
~A. Interrupting~@:>"
thread connector)
;; Interrupt the receiver thread and abort.
(log:debug "~@<~A is interrupting receiver thread ~A ~
with abort~@:>"
connector thread)
(handler-case
(bt:interrupt-thread thread #'exit-receiver)
(error (condition)
(log:warn "~@<~A failed to interrupt receiver ~
thread ~A: ~A Retrying~@:>"
connector thread condition)))))))
;; This is necessary to allow restarting the connector.
(setf thread nil)))
(defmethod receive-messages :around ((connector threaded-receiver-mixin))
;; Catch the 'terminate tag that is thrown to indicate interruption
;; requests.
;;
;; Notify the thread which is waiting in `start-receiver'.
(restart-case
(let+ (((&structure connector- thread control-mutex control-condition)
connector))
(bt:with-lock-held (control-mutex)
(setf thread (bt:current-thread))
(bt:condition-notify control-condition))
(log:debug "~@<~A is entering receive loop~@:>" connector)
(call-next-method))
(abort (&optional condition)
:report (lambda (stream)
(format stream "~@<Abort processing for ~A~@:>" connector))
(declare (ignore condition))))
(log:debug "~@<~A left receive loop~@:>" connector))
(defun exit-receiver ()
;; Cause a receiver thread to exit. Has to be called from the
;; receiver thread.
(ignore-errors (abort)))
;;; `threaded-message-receiver-mixin'
(defclass threaded-message-receiver-mixin (threaded-receiver-mixin)
()
(:documentation
"This mixin class combines receiving of messages and management of
a dedicated thread for receiving messages. It can therefore supply a
default implementation of the receive loop which runs in the receiver
thread."))
(defmethod receive-messages ((connector threaded-message-receiver-mixin))
;; Receive a message that can be decoded into an event. Return the
;; event.
(iter (let+ (((&values notification wire-schema)
(receive-notification connector t))
;; Try to convert NOTIFICATION into one or zero events
;; (in the latter case, EVENT is nil).
(event (when notification
(notification->event connector notification wire-schema))))
;; Due to fragmentation of large events into multiple
;; notifications and error handling policies, we may not
;; obtain an `event' instance from the notification.
(when event
(dispatch connector event)))))
| 16,240 | Common Lisp | .lisp | 336 | 38.255952 | 90 | 0.628863 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | be610a994cc53ce2018cd68abc13b8c7c6d6ac9ff0dde70566b9fd2d7637167d | 25,339 | [
-1
] |
25,340 | package.lisp | open-rsx_rsb-cl/src/transport/package.lisp | ;;;; package.lisp --- Package definition for the transport module.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.transport
(:nicknames #:rsb.tp)
(:use
#:cl
#:alexandria
#:let-plus
#:iterate
#:more-conditions
#:nibbles
#:rsb
#:rsb.event-processing
#:rsb.converter)
;; Conditions
(:export
#:connector-construction-failed
#:connector-construction-failed-name
#:connector-construction-failed-direction
#:connector-construction-failed-args
#:connection-closed
#:connection-closed-connection
#:connection-unexpectedly-closed
#:no-suitable-converter
#:connector-construction-failed-wire-type
#:connector-construction-failed-candidates
#:decoding-error
#:decoding-error-encoded
#:encoding-error
#:encoding-error-event)
;; Types
(:export
#:notification-index
#:wire-notification
#:wire-notification-buffer
#:wire-notification-end
#:make-wire-notification)
;; Variables
(:export
#:*transport-metrics*)
;; Transport protocol
(:export
#:transport-schemas ; work on transport names,
#:transport-wire-type ; transport instances, connector
#:transport-remote?) ; classes and connector instances
;; Connector protocol
(:export
#:connector-transport
#:connector-direction ; work on connector classes and instances
#:connector-url ; work on connector instances
#:connector-relative-url
#:connector-direct-options
#:connector-options)
;; Transport and connector registration protocol
(:export
#:register-transport
#:register-connector)
;; `transport' class and service
(:export
#:transport)
;; Connector creation
(:export
#:make-connector
#:make-connectors)
;; `connector-class' metaclass
(:export
#:connector-class
#:&slot)
;; `connector' class
(:export
#:connector)
;; `conversion-mixin' class
(:export
#:conversion-mixin
#:connector-converter)
;; Notification receiver protocol
(:export
#:receive-notification
#:notification->event)
;; Notification sender protocol
(:export
#:send-notification
#:event->notification)
;; Threaded receiver protocol and `threaded-receiver-mixin' class
(:export
#:start-receiver
#:stop-receiver
#:exit-receiver
#:receive-messages
#:threaded-receiver-mixin
#:connector-started?
#:connector-thread)
;; `timestamping-receiver-mixin' class
(:export
#:timestamping-receiver-mixin)
;; `timestamping-sender-mixin' class
(:export
#:timestamping-sender-mixin)
;; Error handling mixin classes
(:export
#:error-handling-push-receiver-mixin
#:error-handling-pull-receiver-mixin
#:error-handling-sender-mixin)
;; `restart-notification-receiver-mixin' class
(:export
#:restart-notification-receiver-mixin)
;; `restart-notification-sender-mixin' class
(:export
#:restart-notification-sender-mixin)
;; `threaded-message-receiver-mixin' class
(:export
#:threaded-message-receiver-mixin)
;; `expose-transport-metrics-mixin' class
(:export
#:expose-transport-metrics-mixin
#:connector-expose
#:connector-expose?)
(:documentation
"This package contains the transport layer.
The central concepts of the transport layer are \"transport\" and
\"connector\". Connector instances handle incoming and outgoing
events (see `rsb.event-processing:handle'). The function
`make-connector' can be used to create connector instances for
different transports.
The efficiency of data handling can be increased by notifying
connectors of restrictions that can be applied to the otherwise
broadcast-style event delivery."))
| 3,832 | Common Lisp | .lisp | 130 | 25.576923 | 77 | 0.71694 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6d2c4affbbf27eb98e6c04a75ca22f0148b8173785f53160636fc063970e78f7 | 25,340 | [
-1
] |
25,341 | protocol.lisp | open-rsx_rsb-cl/src/transport/protocol.lisp | ;;;; protocol.lisp --- Protocol of the transport module.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
;;; Transport service
(service-provider:define-service transport
(:documentation
"Transports implement possibly networked communication protocols.
Each transport is implemented by associated connector classes for
incoming and outgoing communication. The \"directions\" of
connector classes are :in-push, :in-pull and :out. Instances of
connector classes of a particular transport are created to
actually perform communication."))
(defmethod service-provider:find-provider
((service (eql (service-provider:find-service 'transport)))
(provider symbol)
&key if-does-not-exist)
(declare (ignore if-does-not-exist))
(or (call-next-method)
(find provider (service-provider:service-providers service)
:test #'member :key #'transport-schemas)))
(defmethod service-provider:find-provider
((service (eql (service-provider:find-service 'transport)))
(provider cons)
&key if-does-not-exist)
(let+ (((schema . direction) provider))
(check-type direction direction "one of :IN-PUSH, :IN-PULL, :OUT")
(when-let ((provider (service-provider:find-provider
service schema
:if-does-not-exist if-does-not-exist)))
(service-provider:find-provider
provider direction :if-does-not-exist if-does-not-exist))))
(defmethod service-provider:make-provider
((service (eql (service-provider:find-service 'transport)))
(provider cons)
&rest args &key)
(let+ (((schema . direction) provider))
(check-type direction direction "one of :IN-PUSH, :IN-PULL, :OUT")
(apply #'call-next-method service provider :schema schema args)))
;;; Transport protocol
(defgeneric transport-schemas (transport)
(:documentation
"Return a list of the (URI-)schemas supported by TRANSPORT.
TRANSPORT can be a symbol designating a transport, a transport
object, a connector class or a connector instance."))
(defgeneric transport-wire-type (transport)
(:documentation
"Return the wire-type of TRANSPORT.
TRANSPORT can be a symbol designating a transport, a transport
object, a connector class or a connector instance."))
(defgeneric transport-remote? (transport)
(:documentation
"Return true if TRANSPORT implements remote communication."))
;; Default behavior
(macrolet ((define-transport-accessor (name)
`(defmethod ,name ((transport symbol))
;; When given a symbol, try to look up the designated
;; transport and retrieving the requested slot value
;; from it.
(,name (service-provider:find-provider 'transport transport)))))
(define-transport-accessor transport-schemas)
(define-transport-accessor transport-wire-type)
(define-transport-accessor transport-remote?))
;;; Connector protocol
(defgeneric connector-url (connector)
(:documentation
"Return a base URL that can be used to locate resources via
CONNECTOR."))
(defgeneric connector-relative-url (connector thing)
(:documentation
"Return a complete URL suitable for locating the resource THING via
CONNECTOR."))
;;; Connector introspection protocol
(defgeneric connector-transport (connector)
(:documentation
"Return the transport of CONNECTOR.
CONNECTOR can be a connector class or a connector instance."))
(defgeneric connector-direction (connector)
(:documentation
"Return the communication direction of CONNECTOR.
CONNECTOR can be a connector class or a connector instance."))
(defgeneric connector-direct-options (connector)
(:documentation
"Return a description of the options defined in CONNECTOR.
The returned description is a list of \"direct\" options, i.e.
defined in CONNECTOR but not its superclasses. Items are of the
form
(NAME TYPE &key DEFAULT DESCRIPTION)
where NAME is a keyword which names the option, TYPE is the type
of acceptable values of the option, DEFAULT is a form that
computes a default value and description is a description of the
option.
CONNECTOR can be a connector class or a connector instance."))
(defgeneric connector-options (connector)
(:documentation
"Return a description of the options accepted by CONNECTOR.
The returned description is a list of \"transitive\" options,
i.e. accumulated along superclasses. Items are of the form
(NAME TYPE &key DEFAULT DESCRIPTION)
where NAME is a keyword which names the option, TYPE is the type
of acceptable values of the option, DEFAULT is a form that
computes a default value and description is a description of the
option.
CONNECTOR can be a connector class or a connector instance."))
;;; Notification receiver protocol
(defgeneric receive-notification (connector block?)
(:documentation
"Receive and return one notification via CONNECTOR.
If BLOCK? is nil, only return a notification if one is immediately
available, otherwise return nil. If BLOCK? is non-nil, wait for a
notification if none is immediately available.
If something has been received, return two values: the received
notification and a symbol designating the wire-schema of the received
data."))
(defgeneric notification->event (connector notification wire-schema)
(:documentation
"Convert NOTIFICATION with wire-schema WIRE-SCHEMA into an `event'
instance and return the event. If NOTIFICATION cannot be converted
into an event, return nil instead. Signal a `decoding-error' if
something goes wrong."))
;;; Notification sender protocol
(defgeneric send-notification (connector notification)
(:documentation
"Send NOTIFICATION via CONNECTOR."))
(defgeneric event->notification (connector event)
(:documentation
"Convert EVENT into a notification for sending via
CONNECTOR. Return the notification. If EVENT cannot be converted into
a notification, maybe return nil, depending on the error handling
policy. Maybe signal an `encoding-error' if something goes wrong."))
;;; Threaded receiver protocol
(defgeneric start-receiver (connector)
(:documentation
"Ask CONNECTOR to start a receiver thread that runs
`receive-messages' until interrupted."))
(defgeneric stop-receiver (connector)
(:documentation
"Ask CONNECTOR to stop receiving messages."))
(defgeneric receive-messages (connector)
(:documentation
"CONNECTOR receives and processes messages until interrupted."))
;;; Transport metric exposing protocol
(defgeneric connector-expose (connector)
(:documentation
"Return the list of transport metrics exposed by CONNECTOR."))
(defgeneric (setf connector-expose) (new-value connector)
(:documentation
"Install NEW-VALUE as the list of transport metrics exposed by
CONNECTOR."))
(defgeneric connector-expose? (connector metric)
(:documentation
"Return non-nil when CONNECTOR exposes METRIC."))
(defgeneric (setf connector-expose?) (new-value connector metric)
(:documentation
"If NEW-VALUE is non-nil, add METRIC to the list of transport
metrics exposed by CONNECTOR. Otherwise remove METRIC from the
list."))
;;; Transport implementations
(defun make-connector (name direction converters
&rest args &key converter &allow-other-keys)
"Create a connector instance for the direction designated by
DIRECTION of the kind the designated by NAME. Pass ARGS to the
constructed instance.
CONVERTERS is an alist of items of the form
(WIRE-TYPE . CONVERTER)
. If the requested connector does not require a converter,
CONVERTERS can be nil.
An error of type `connector-constructor-failed' is signaled if the
requested connector instance cannot be constructed. If the
construction fails due to the lack of a suitable converter, an
error of the subtype `no-suitable-converter' is signaled."
(with-condition-translation
(((error connector-construction-failed)
:name name
:direction direction
:args args))
(let+ ((wire-type (transport-wire-type name))
(converter (unless (eq wire-type t)
(or converter
(cdr (find wire-type converters
:key #'car
:test #'subtypep)))))
(args (remove-from-plist args :converter))
((&flet make-it (&rest more-args)
(apply #'service-provider:make-provider
'transport (cons name direction)
(append args more-args)))))
(cond
;; The connector does not require a converter.
((eq wire-type t)
(make-it))
;; The connector requires a converter and we found a suitable
;; one.
(converter
(make-it :converter converter))
;; The connector requires a converter, but we did not find a
;; suitable one.
(t
(error 'no-suitable-converter
:name name
:direction direction
:args args
:wire-type wire-type
:candidates converters))))))
(defun make-connectors (specs direction &optional converters)
"Create and return zero or more connector instances for the
direction designated by DIRECTION according to SPECS.
Each element of SPECS has to be of the form
(NAME . ARGS)
where NAME and ARGS have to acceptable for calls to
`make-connector'. For CONVERTERS, see `make-connector'."
;; Check direction here in order to signal a appropriate type error
;; even if SPECS is nil.
(check-type direction direction "one of :IN-PUSH, :IN-PULL, :OUT")
(iter (for (name . args) in specs)
(collect (apply #'make-connector
name direction converters args))))
| 9,996 | Common Lisp | .lisp | 219 | 39.757991 | 80 | 0.716447 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f7757b7f17019c34b7cb0cb01fd9fb5825bd969c2aebc12fd2858fa6b11f7da5 | 25,341 | [
-1
] |
25,342 | types.lisp | open-rsx_rsb-cl/src/transport/types.lisp | ;;;; types.lisp --- Types used in the transport module.
;;;;
;;;; Copyright (C) 2012, 2014, 2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
;;; Notifications
(deftype notification-index ()
`(unsigned-byte 32))
(defstruct (wire-notification
(:constructor make-wire-notification (buffer end))
(:copier nil))
(buffer nil :type nibbles:octet-vector :read-only t)
(end nil :type notification-index :read-only t))
| 523 | Common Lisp | .lisp | 14 | 33.785714 | 63 | 0.675248 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | feae205b1163997ce95c6173ee72b11bbbc04e78debe9dc2cb7bf72e00995073 | 25,342 | [
-1
] |
25,343 | connector-class.lisp | open-rsx_rsb-cl/src/transport/connector-class.lisp | ;;;; connector-class.lisp --- Metaclass for connector classes.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
(defclass connector-class (standard-class)
((transport :accessor connector-%transport
:documentation
"Stores the transport instance to which the transport
class and its instances belong.")
(direction :type direction
:documentation
"Stores the direction of instances of the connector
class.")
(options :type list
:documentation
"Stores options accepted by the connector class. Options
are mapped to initargs."))
(:documentation
"This metaclass can be used as the class of connector classes in
order to provide storage and retrieval (via methods on
`connector-direction', `connector-wire-type', `connector-schemas'
and `connector-options') for connector direction, wire-type,
schemas and options."))
(defmethod shared-initialize :before ((instance connector-class)
(slot-names t)
&key
transport
direction
(options nil options-supplied?))
(when transport
(setf (connector-%transport instance)
(let ((transport (first transport)))
(typecase transport
((or symbol cons)
(service-provider:find-provider 'transport transport))
(t
transport)))))
(when direction
(setf (slot-value instance 'direction) (first direction)))
(when (or options-supplied? (not (slot-boundp instance 'options)))
(setf (slot-value instance 'options) options)))
(defmethod closer-mop:class-direct-default-initargs ((class connector-class))
;; Add initargs for options with &slot specification.
(reduce (lambda+ (default-initargs
(name &ign
&key (default t default-supplied?) &allow-other-keys))
(if default-supplied?
(list* (list name default
(compile nil `(lambda () ,default)))
(remove name default-initargs :key #'first))
default-initargs))
(connector-direct-options class)
:initial-value (call-next-method)))
(defmethod closer-mop:validate-superclass ((class connector-class)
(superclass standard-class))
t)
(defmethod connector-transport ((connector connector-class))
(if (slot-boundp connector 'transport)
(slot-value connector 'transport)
(some #'connector-transport
(closer-mop:class-direct-superclasses connector))))
(defmethod connector-direction ((connector connector-class))
(if (slot-boundp connector 'direction)
(slot-value connector 'direction)
(some #'connector-direction
(closer-mop:class-direct-superclasses connector))))
(defmethod connector-direct-options ((connector connector-class))
(mapcar (curry #'%maybe-expand-option connector)
(slot-value connector 'options)))
(defmethod connector-options ((connector connector-class))
;; Retrieve options from CONNECTOR and its transitive super-classes.
;; Option definitions in subclasses take precedence over definitions
;; in super-classes.
(remove-duplicates
(append (connector-direct-options connector)
(mappend #'connector-options
(closer-mop:class-direct-superclasses connector)))
:key #'first
:from-end t))
;;; Delegations
(macrolet ((define-connector-class-accessor (name &optional to-transport?)
(let ((argument (if to-transport? 'transport 'connector)))
`(progn
,@(when to-transport?
`((defmethod ,name ((,argument connector-class))
(,name (connector-transport ,argument)))))
(defmethod ,name ((,argument standard-object))
;; Default behavior is to retrieve the value from
;; the class of ARGUMENT.
(,name (class-of ,argument)))
(defmethod ,name ((,argument class))
;; Stop if we hit a class which is not a
;; `connector-class'.
(values))))))
(define-connector-class-accessor transport-schemas t)
(define-connector-class-accessor transport-wire-type t)
(define-connector-class-accessor transport-remote? t)
(define-connector-class-accessor connector-transport)
(define-connector-class-accessor connector-direction)
(define-connector-class-accessor connector-options))
;;; Utility functions
(defun+ %maybe-expand-option (class (&whole option name type &rest args))
;; Potentially expand the options description OPTION using
;; information from CLASS.
(let+ (((&flet slot->option (slot)
`(,name
,(closer-mop:slot-definition-type slot)
,@(when-let ((initform (closer-mop:slot-definition-initform slot)))
`(:default ,initform))
,@(when-let ((description (documentation slot t)))
`(:description ,description))))))
(cond
((not (eq type '&slot))
option)
((not args)
(if-let ((slot (find name (closer-mop:class-direct-slots class)
:test #'member
:key #'closer-mop:slot-definition-initargs)))
(slot->option slot)
(error "~@<~S specified for option ~S, but no slot with ~
initarg ~:*~S in class ~S.~@:>"
'&slot name class)))
(t
(let ((slot-name (first args)))
(if-let ((slot (find slot-name (closer-mop:class-direct-slots class)
:key #'closer-mop:slot-definition-name)))
(slot->option slot)
(error "~@<~S with slot name ~S specified for option ~S, ~
but no slot named ~2:*~S~* in class ~S.~@:>"
'&slot slot-name name class)))))))
| 6,285 | Common Lisp | .lisp | 132 | 36.090909 | 81 | 0.596511 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 31e611158871629f45df7b98424fb0c83516165a244b163b2072c19d2268c93f | 25,343 | [
-1
] |
25,344 | conditions.lisp | open-rsx_rsb-cl/src/transport/conditions.lisp | ;;;; conditions.lisp --- Conditions used in the transport module.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
(define-condition connector-construction-failed (rsb-error
chainable-condition)
((name :initarg :name
:type keyword
:reader connector-construction-failed-name
:documentation
"Name of the connector class that should have been
used.")
(direction :initarg :direction
:type keyword
:reader connector-construction-failed-direction
:documentation
"Desired direction of the connector instance that should
have been constructed.")
(args :initarg :args
:type list
:reader connector-construction-failed-args
:documentation
"Arguments for the connector instance that should have
been constructed."))
(:report
(lambda (condition stream)
(format stream "~@<Failed to construct ~A connector for direction ~A~
~@[ with options~@:_~@:_~
~2@T~<~@;~@{~16S~^ ~S~^~@:_~}~:>~
~@:_~@:_~].~/more-conditions:maybe-print-cause/~@:>"
(connector-construction-failed-name condition)
(connector-construction-failed-direction condition)
(connector-construction-failed-args condition)
condition)))
(:documentation
"This error is signaled when the construction of a connector
instance fails."))
;;;
(define-condition connection-closed (condition)
((connection :initarg :connection
:reader connection-closed-connection
:documentation
"Stores the connection which has been closed."))
(:default-initargs
:connection (missing-required-initarg 'connection-closed :connection))
(:report
(lambda (condition stream)
(format stream "~@<The connection ~A is closed.~@:>"
(connection-closed-connection condition))))
(:documentation
"This condition and subclasses are signaled when a connection is
closed."))
(define-condition connection-unexpectedly-closed (communication-error
connection-closed
chainable-condition)
()
(:report
(lambda (condition stream)
(format stream "~@<The connection ~A has been closed ~
unexpectedly.~/more-conditions:maybe-print-cause/~@:>"
(connection-closed-connection condition)
condition)))
(:documentation
"This error is signaled when a connection is closed
unexpectedly. In contrast to the more generic `connection-closed'
condition, this is considered an error."))
;;; Conversion-related errors
;;;
;;; No suitable convert, encoding and decoding errors.
(define-condition no-suitable-converter (connector-construction-failed)
((wire-type :initarg :wire-type
:reader connector-construction-failed-wire-type
:documentation
"Stores the wire-type for which a converter could not
be found.")
(candidates :initarg :candidates
:type list
:reader connector-construction-failed-candidates
:documentation
"Stores an a list of converter candidates of the
form (WIRE-TYPE . CONVERTER)."))
(:report
(lambda (condition stream)
(format stream "~@<Failed to construct ~A connector for direction ~
~A~@[ with options~{~_~2T~16A: ~
~@<~@;~S~>~^,~}~]~_because no converter for ~
wire-type ~S could be found ~:[without any ~
candidates (empty converter list)~;~:*in ~
candidate list ~{~A~^, ~_~}~].~@:>"
(connector-construction-failed-name condition)
(connector-construction-failed-direction condition)
(connector-construction-failed-args condition)
(connector-construction-failed-wire-type condition)
(connector-construction-failed-candidates condition))))
(:documentation
"This error is signaled when the construction of a connector
instance fails because the list of available converters does not
contain a suitable one for the requested connector."))
(define-condition decoding-error (rsb-error
simple-condition
chainable-condition)
((encoded :initarg :encoded
:type octet-vector
:reader decoding-error-encoded
:documentation
"The encoded data, for which the decoding failed."))
(:report
(lambda (condition stream)
(let+ (((&structure-r/o decoding-error- encoded) condition)
(octet-sequence? (and (typep encoded 'sequence)
(every (of-type 'octet) encoded))))
(format stream "~@<The encoded data~
~@:_~@:_~
~<│ ~@;~:[~S~:;~,,,16@:/utilities.binary-dump:print-binary-dump/~]~:>~
~@:_~@:_~
could not be decoded~
~/more-conditions:maybe-print-explanation/~
~:*~/more-conditions:maybe-print-cause/~:>"
(list octet-sequence? encoded) condition))))
(:documentation
"This error is signaled when decoding one or more notifications
into an `event' instance fails."))
(define-condition encoding-error (rsb-error
simple-condition
chainable-condition)
((event :initarg :event
:reader encoding-error-event
:documentation
"The event for which the encoding failed."))
(:report
(lambda (condition stream)
(format stream "~@<The event ~A could not be encoded into an ~
octet-vector~/more-conditions:maybe-print-explanation/~
~:*~/more-conditions:maybe-print-cause/~@:>"
(encoding-error-event condition) condition)))
(:documentation
"This error is signaled when encoding an `event' instance into one
or more notifications fails."))
| 6,513 | Common Lisp | .lisp | 140 | 34.7 | 94 | 0.586424 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | c61a6e64a7c8ef8f63dd91a3b27c3fc34281714132d369f11f9dcf9e2cd87e38 | 25,344 | [
-1
] |
25,345 | variables.lisp | open-rsx_rsb-cl/src/transport/variables.lisp | ;;;; variables.lisp --- Variables used in the transport module.
;;;;
;;;; Copyright (C) 2012, 2013 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
(declaim (special *transport-metrics*))
(defvar *transport-metrics*
'(:rsb.transport.connector
:rsb.transport.wire-schema
:rsb.transport.payload-size
:rsb.transport.notification-size)
"List of names of transport metrics that can be requested.")
| 475 | Common Lisp | .lisp | 13 | 34.076923 | 63 | 0.734205 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | bd5003d1cc38f10759fe9dfb6eb0c90a2707ef8db11b9ddde8e8e0bbdec3e817 | 25,345 | [
-1
] |
25,346 | connector.lisp | open-rsx_rsb-cl/src/transport/connector.lisp | ;;;; connector.lisp --- Superclass for connector classes.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport)
;;; `connector' class
(defclass connector (uri-mixin
error-policy-mixin)
((rsb::uri :reader connector-url))
(:metaclass connector-class)
(:default-initargs
:schema (missing-required-initarg 'connector :schema))
(:documentation
"A connector implements access to the bus by means of a particular
mechanism.
One example is a connector that makes use of the Spread group
communication framework."))
(defmethod shared-initialize :after ((instance connector) (slot-names t)
&key
schema
host
port
&allow-other-keys)
(setf (slot-value instance 'rsb::uri)
(make-instance 'puri:uri
:scheme schema
:host (or host (when port "localhost"))
:port port)))
(defmethod connector-relative-url ((connector connector)
(uri puri:uri))
(puri:merge-uris uri (connector-url connector)))
(defmethod connector-relative-url ((connector connector)
(thing string))
(connector-relative-url connector (make-scope thing)))
(defmethod connector-relative-url ((connector connector)
(thing t))
(connector-relative-url connector (relative-url thing)))
(defmethod print-items:print-items append ((object connector))
`((:direction ,(connector-direction object) "~A")
(:url ,(connector-relative-url object "/") " ~A"
((:after :direction)))))
(defmethod print-object ((object connector) stream)
(cond
(*print-readably*
(call-next-method))
(t
(print-unreadable-object (object stream :identity t)
(print-items:format-print-items
stream (print-items:print-items object))))))
| 2,147 | Common Lisp | .lisp | 50 | 32.38 | 72 | 0.586009 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b4443462354da798f36937b7d3a7481532b341fc6876896bb7a947b7ac747b15 | 25,346 | [
-1
] |
25,347 | transport.lisp | open-rsx_rsb-cl/src/transport/inprocess/transport.lisp | ;;;; transport.lisp --- inprocess transport.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.inprocess)
(eval-when (:compile-toplevel :load-toplevel :execute)
;;; `inprocess-transport' transport class
(defclass inprocess-transport (transport)
((scope-sinks :reader transport-scope-sinks
:initform (rsb.ep:make-sink-scope-trie)
:documentation
"Association of scopes to event sinks interested in
the respective scopes.")
(machine-instance :initarg :machine-instance
:type string
:reader transport-machine-instance
:writer (setf transport-%machine-instance)
:documentation
"Stores the machine instance string that
connectors created by this transport should
use in their URLs.")
(process-id :initarg :process-id
:type non-negative-integer
:reader transport-process-id
:writer (setf transport-%process-id)
:documentation
"Stores the process id that connectors created
by this transport should use in their URLs."))
(:default-initargs
:machine-instance (machine-instance)
:process-id (sb-posix:getpid)))
;;; Register transport
(register-transport
:inprocess
:transport-class 'inprocess-transport
:schemas :inprocess
:wire-type t ; The Lisp process is the medium, so t (any Lisp
; object) should be a reasonable wire-type
:remote? nil
:documentation
"Transport for communication within one process.
RSB participants within one process can exchange events
efficiently without (de)serialization and a lock-free routing data
structure.")
) ; eval-when
;;; Global transport instance
(defun update-machine-instance-and-process-id ()
(let ((transport (service-provider:find-provider 'transport :inprocess)))
(setf (transport-%machine-instance transport) (machine-instance)
(transport-%process-id transport) (sb-posix:getpid))))
#+sbcl (pushnew 'update-machine-instance-and-process-id
sb-ext:*init-hooks*)
#-sbcl (pushnew 'update-machine-instance-and-process-id
uiop:*image-restore-hook*)
| 2,579 | Common Lisp | .lisp | 55 | 36.054545 | 75 | 0.610426 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 14650dda7faa91174595eb5c90519a42fb66c605dc023446962ea121e4ad540c | 25,347 | [
-1
] |
25,348 | connectors.lisp | open-rsx_rsb-cl/src/transport/inprocess/connectors.lisp | ;;;; connectors.lisp --- Connectors of the inprocess transport.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.inprocess)
;;; `connector'
(defclass connector (rsb.transport:connector)
((transport :initarg %transport
:reader connector-transport))
(:metaclass connector-class)
(:transport :inprocess)
(:documentation
"Superclass for connector classes of the inprocess transport."))
(defmethod shared-initialize :around ((instance connector)
(slot-names t)
&rest args &key)
(let ((transport (connector-transport (class-of instance))))
(apply #'call-next-method instance slot-names
'%transport transport
:host (transport-machine-instance transport)
:port (transport-process-id transport)
args)))
;;; `in-connector'
(defclass in-connector (connector)
()
(:metaclass connector-class)
(:documentation
"Superclass for in-direction connector classes of the inprocess
transport."))
(defmethod notify ((connector in-connector)
(scope scope)
(action (eql :attached)))
(let+ (((&structure-r/o transport- scope-sinks)
(connector-transport connector)))
(log:debug "~@<~A is attaching to scope ~A~@:>" connector scope)
(rsb.ep:sink-scope-trie-add scope-sinks scope connector)
(log:debug "~@<Scope trie after adding ~A:~@:_~/rsb.ep::print-trie/~@:>"
connector scope-sinks)))
(defmethod notify ((connector in-connector)
(scope scope)
(action (eql :detached)))
(let+ (((&structure-r/o transport- scope-sinks)
(connector-transport connector)))
(log:debug "~@<~A is detaching from scope ~A~@:>" connector scope)
(rsb.ep:sink-scope-trie-remove scope-sinks scope connector)
(log:debug "~@<Scope trie after removing ~A:~@:_~/rsb.ep::print-trie/~@:>"
connector scope-sinks)))
;;; `in-pull-connector' class
(defclass in-pull-connector (broadcast-processor
error-handling-pull-receiver-mixin
restart-dispatcher-mixin
in-connector)
((queue :type lparallel.queue:queue
:reader connector-queue
:initform (lparallel.queue:make-queue)
:documentation
"Stores events as they arrive via the message bus."))
(:metaclass connector-class)
(:direction :in-pull)
(:documentation
"Instances of this connector class deliver RSB events within a
process."))
(register-connector :inprocess :in-pull 'in-pull-connector)
(defmethod handle ((connector in-pull-connector)
(event event))
;; Put EVENT into the queue maintained by CONNECTOR.
(lparallel.queue:push-queue event (connector-queue connector)))
(defmethod receive-notification ((connector in-pull-connector)
(block? (eql nil)))
;; Extract and return one event from the queue maintained by
;; CONNECTOR, if there are any. If there are no queued events,
;; return nil.
(lparallel.queue:try-pop-queue (connector-queue connector)))
(defmethod receive-notification ((connector in-pull-connector)
(block? t))
;; Extract and return one event from the queue maintained by
;; CONNECTOR, if there are any. If there are no queued events,
;; block.
(lparallel.queue:pop-queue (connector-queue connector)))
(defmethod emit ((connector in-pull-connector) (block? t))
(when-let ((event (receive-notification connector block?)))
(setf (timestamp event :receive) (local-time:now))
(dispatch connector event)
t))
(defmethod print-object ((object in-pull-connector) stream)
(print-unreadable-object (object stream :identity t)
(format stream "~A ~A (~D)"
(connector-direction object)
(connector-relative-url object "/")
(lparallel.queue:queue-count
(connector-queue object)))))
;;; `in-push-connector' class
(defclass in-push-connector (broadcast-processor
error-policy-handler-mixin
restart-handler-mixin
restart-dispatcher-mixin
in-connector)
()
(:metaclass connector-class)
(:direction :in-push)
(:documentation
"Instances of this connector class deliver RSB events within a
process."))
(register-connector :inprocess :in-push 'in-push-connector)
(defmethod handle :before ((connector in-push-connector)
(event event))
(setf (timestamp event :receive) (local-time:now)))
;;; `out-connector' class
(defclass out-connector (error-handling-sender-mixin
restart-handler-mixin
connector)
((scope-sinks :accessor connector-%scope-sinks
:documentation
"Caches the sink trie of the associated transport."))
(:metaclass connector-class)
(:direction :out)
(:documentation
"Instances of this connector class deliver RSB events within a
process."))
(register-connector :inprocess :out 'out-connector)
(defmethod shared-initialize :after
((instance out-connector)
(slot-names t)
&key
((%transport transport) nil transport-supplied?))
(when transport-supplied?
(setf (connector-%scope-sinks instance)
(transport-scope-sinks transport))))
(defmethod handle :before ((connector out-connector)
(event event))
(setf (timestamp event :send) (local-time:now)))
(defmethod handle ((connector out-connector) (event event))
(flet ((do-scope (scope connectors)
(declare (ignore scope))
(handle connectors event)))
(declare (dynamic-extent #'do-scope))
(rsb.ep:scope-trie-map
#'do-scope (event-scope event) (connector-%scope-sinks connector))))
| 6,093 | Common Lisp | .lisp | 139 | 35.510791 | 78 | 0.638327 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 266fd22906ff3e6b3c6160e8a97c1d9f7d8f7256923ecacb017f66ca4d2f1ec1 | 25,348 | [
-1
] |
25,349 | package.lisp | open-rsx_rsb-cl/src/transport/inprocess/package.lisp | ;;;; package.lisp --- Package definition for the transport.inprocess module.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.transport.inprocess
(:use
#:cl
#:alexandria
#:iterate
#:let-plus
#:rsb
#:rsb.event-processing
#:rsb.filter
#:rsb.transport)
(:shadow
#:connector)
(:documentation
"This package contains a transport that delivers RSB events within
a process."))
| 499 | Common Lisp | .lisp | 20 | 21.75 | 76 | 0.692632 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 3d09adebed41531c7327697fbc8cedbb56bfa0e15dc6b7a66ec50d2c818a9188 | 25,349 | [
-1
] |
25,350 | conversion.lisp | open-rsx_rsb-cl/src/transport/socket/conversion.lisp | ;;;; conversion.lisp --- Event <-> notification conversion for socket transport.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; Utility functions
(defun timestamp->unix-microseconds (timestamp)
"Convert the `local-time:timestamp' instance TIMESTAMP into an
integer which counts the number of microseconds since UNIX epoch."
(+ (* 1000000 (local-time:timestamp-to-unix timestamp))
(* 1 (local-time:timestamp-microsecond timestamp))))
(defun unix-microseconds->timestamp (unix-microseconds)
"Convert UNIX-MICROSECONDS to an instance of
`local-time:timestamp'."
(let+ (((&values unix-seconds microseconds)
(floor unix-microseconds 1000000)))
(local-time:unix-to-timestamp
unix-seconds :nsec (* 1000 microseconds))))
(declaim (inline string->bytes bytes->string))
(defun string->bytes (string)
"Converter STRING into an octet-vector."
(declare (notinline string->bytes))
(if (stringp string)
(sb-ext:string-to-octets string :external-format :ascii)
(string->bytes (princ-to-string string))))
(defun bytes->string (bytes)
"Convert BYTES into a string."
(sb-ext:octets-to-string bytes :external-format :ascii))
(defvar *keyword-readtable*
(let ((readtable (copy-readtable nil)))
(setf (readtable-case readtable) :invert)
readtable)
"This readtable is used to print and read keywords.
The goal is to get a natural mapping between Lisp keywords and
corresponding strings for most cases.")
(defun keyword->bytes (keyword)
"Convert the name of KEYWORD into an octet-vector."
(if (find #\: (symbol-name keyword))
(string->bytes (symbol-name keyword))
(let ((*readtable* *keyword-readtable*))
(string->bytes (princ-to-string keyword)))))
(defun bytes->keyword (bytes)
"Converter BYTES into a keyword."
(if (find (char-code #\:) bytes)
(intern (bytes->string bytes) (find-package :keyword))
(let ((*package* (find-package :keyword))
(*readtable* *keyword-readtable*))
(read-from-string (bytes->string bytes)))))
(defun wire-schema->bytes (wire-schema)
"Convert WIRE-SCHEMA to an ASCII representation stored in an
octet-vector."
(keyword->bytes wire-schema))
(defun bytes->wire-schema (bytes)
"Return a keyword representing the wire-schema encoded in bytes."
(when (emptyp bytes)
(error "~@<Empty wire-schema.~:@>"))
(bytes->keyword bytes))
;;; Notification -> Event
(defun notification->event* (converter notification
&key
expose-wire-schema?
expose-payload-size?)
"Convert NOTIFICATION to an `event' instance using CONVERTER for the
payload. Return the decoded event.
The optional parameter DATA can be used to supply encoded data that
should be used instead of the data contained in NOTIFICATION."
(let+ (((&flet event-id->cons (event-id)
(cons (uuid:byte-array-to-uuid (event-id-sender-id event-id))
(event-id-sequence-number event-id))))
((&accessors-r/o
(scope notification-scope)
(event-id notification-event-id)
(method notification-method)
(wire-schema notification-wire-schema)
(payload notification-data)
(meta-data notification-meta-data)
(causes notification-causes)) notification)
((&accessors-r/o
(sender-id event-id-sender-id)
(sequence-number event-id-sequence-number)) event-id)
(wire-schema (bytes->wire-schema wire-schema))
(data (rsb.converter:wire->domain
converter payload wire-schema))
(event (make-instance
'rsb:event
:origin (uuid:byte-array-to-uuid sender-id)
:sequence-number sequence-number
:scope (make-scope (bytes->string scope))
:method (unless (emptyp method)
(bytes->keyword method))
:causes (map 'list #'event-id->cons causes)
:data data
:create-timestamp? nil))
((&flet set-timestamp (key value)
(unless (zerop value)
(setf (timestamp event key)
(unix-microseconds->timestamp value))))))
;; "User infos" and timestamps
(when meta-data
;; "User infos"
(iter (for user-info in-vector (event-meta-data-user-infos meta-data))
(setf (meta-data event (bytes->keyword
(user-info-key user-info)))
(bytes->string (user-info-value user-info))))
;; Set framework timestamps :create, :send, :receive and
;; :deliver, if present.
(set-timestamp :create (event-meta-data-create-time meta-data))
(set-timestamp :send (event-meta-data-send-time meta-data))
(set-timestamp :receive (event-meta-data-receive-time meta-data))
(set-timestamp :deliver (event-meta-data-deliver-time meta-data))
;; Set "user timestamps"
(iter (for user-time in-vector (event-meta-data-user-times meta-data))
(set-timestamp (bytes->keyword (user-time-key user-time))
(user-time-timestamp user-time))))
;; When requested, store transport metrics as meta-data items.
(when expose-wire-schema?
(setf (rsb:meta-data event :rsb.transport.wire-schema)
wire-schema))
(when expose-payload-size?
(setf (rsb:meta-data event :rsb.transport.payload-size)
(length payload)))
event))
;;; Event -> Notification
(defun event->notification* (converter event)
"Convert EVENT into one or more notifications.
More than one notification is required when data contained in event
does not fit into one notification."
;; Put EVENT into one or more notifications.
(let+ (((&accessors-r/o (origin event-origin)
(sequence-number event-sequence-number)
(scope event-scope)
(method event-method)
(data event-data)
(meta-data rsb:event-meta-data)
(timestamps event-timestamps)
(causes event-causes)) event)
((&values wire-data wire-schema)
(rsb.converter:domain->wire converter data)))
(make-notification sequence-number origin scope method
wire-schema wire-data
meta-data timestamps causes)))
(defun make-notification (sequence-number origin scope method
wire-schema data
meta-data timestamps causes)
"Make and return a `rsb.protocol:notification' instance with
SEQUENCE-NUMBER, SCOPE, METHOD, WIRE-SCHEMA, DATA and optionally
META-DATA, TIMESTAMPS and CAUSES."
(let* ((event-id (make-instance
'rsb.protocol:event-id
:sender-id (uuid:uuid-to-byte-array origin)
:sequence-number sequence-number))
(meta-data1 (make-instance 'rsb.protocol:event-meta-data))
(notification (make-instance
'rsb.protocol:notification
:event-id event-id
:scope (string->bytes (scope-string scope))
:wire-schema (wire-schema->bytes wire-schema)
:data data
:meta-data meta-data1)))
;; Add META-DATA.
(iter (for (key value) on meta-data :by #'cddr)
(vector-push-extend
(make-instance 'user-info
:key (keyword->bytes key)
:value (string->bytes value))
(event-meta-data-user-infos meta-data1)))
;; Add framework timestamps in TIMESTAMPS.
(macrolet
((set-timestamp (which accessor)
`(when-let ((value (getf timestamps ,which)))
(setf (,accessor meta-data1)
(timestamp->unix-microseconds value)))))
(set-timestamp :create event-meta-data-create-time)
(set-timestamp :send event-meta-data-send-time)
(set-timestamp :receive event-meta-data-receive-time)
(set-timestamp :deliver event-meta-data-deliver-time))
;; Add "user timestamps" in TIMESTAMPS.
(iter (for (key value) on timestamps :by #'cddr)
;; Framework timestamps are stored in dedicated fields of
;; the notification.
(unless (member key *framework-timestamps* :test #'eq)
(vector-push-extend
(make-instance 'user-time
:key (keyword->bytes key)
:timestamp (timestamp->unix-microseconds value))
(event-meta-data-user-times meta-data1))))
;; Store the method of the event in the new notification if the
;; event has one.
(when method
(setf (notification-method notification) (keyword->bytes method)))
;; Add CAUSES.
(iter (for (origin-id . sequence-number) in causes)
(vector-push-extend
(make-instance 'rsb.protocol:event-id
:sender-id (uuid:uuid-to-byte-array
origin-id)
:sequence-number sequence-number)
(notification-causes notification)))
;; Return the complete notification instance.
notification))
| 9,852 | Common Lisp | .lisp | 201 | 37.99005 | 80 | 0.594409 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | d4e592649054ecc3695fecd1a4bd0ad367b8bee232290bd6b4ebaa1d620f9dbc | 25,350 | [
-1
] |
25,351 | connectors.lisp | open-rsx_rsb-cl/src/transport/socket/connectors.lisp | ;;;; connectors.lisp --- Superclasses for socket-based connectors.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; `connector'
(defclass connector (rsb.transport:connector
conversion-mixin)
((bus :accessor connector-bus
:documentation
"Stores the bus object representing the
socked-based bus to which the connector
provides access.")
;; Option slots
(server? :type (or boolean (eql :auto))
:reader connector-server?
:initform :auto
:documentation
"Controls whether the connector takes the
server or client role for the bus.")
(if-leftover-connections :type leftover-connections-policy
:reader connector-if-leftover-connections
:initform :wait
:documentation
"Controls whether a serer created for this
connector delays its shutdown until for
all client connections are closed."))
(:metaclass connector-class)
(:options
(:server &slot server?)
(:if-leftover-connections &slot if-leftover-connections))
(:documentation
"Superclass for socked-based connector classes."))
;; TODO(jmoringe, 2011-12-14): temp solution until config system works properly
(defmethod initialize-instance :after
((instance connector)
&key
server?
server
(if-leftover-connections nil if-leftover-connections-supplied?))
(setf (slot-value instance 'server?)
(let ((value (or server? server)))
(etypecase value
((member t nil :auto)
value)
(string
(cond
((string= value "0") nil)
((string= value "1") t)
((string= value "auto") :auto))))))
(when if-leftover-connections-supplied?
(setf (slot-value instance 'if-leftover-connections)
(let ((value if-leftover-connections))
(etypecase value
(leftover-connections-policy
value)
(string
(switch (value :test #'string=)
("close" :close)
("wait" :wait)
(t (error "~@<Invalid value ~S.~@:>" value)))))))))
(defmethod notify ((connector connector)
(scope scope)
(action (eql :attached)))
(let+ (((&structure connector-
transport server? if-leftover-connections bus)
connector)
(role (case server?
((t) :server)
((nil) :client)
(t server?)))
(address (make-connection-address transport connector))
(options (make-connection-options transport connector)))
;; Depending on whether connecting to the socket-based bus as a
;; client or server has been requested, request a suitable bus
;; access provider.
(setf bus (apply #'transport-ensure-bus
transport role connector address
:if-leftover-connections if-leftover-connections
options))
;; Notify the bus access provider of the added connector.
;; ensure-bus-* already attached CONNECTOR.
;; (notify connector bus :attached)
(when (next-method-p)
(call-next-method))))
(defmethod notify ((connector connector)
(scope scope)
(action (eql :detached)))
;; Notify the bus access provider of the removed connector.
(notify connector (connector-bus connector) :detached)
(when (next-method-p)
(call-next-method)))
;;; `in-connector'
(defclass in-connector (connector
restart-notification-receiver-mixin
restart-dispatcher-mixin
timestamping-receiver-mixin
broadcast-processor
expose-transport-metrics-mixin)
((scope :type scope
:accessor connector-scope
:documentation
"Stores the scope to which the connector is attached."))
(:metaclass connector-class)
(:documentation
"Superclass for in-direction socket connectors.
Instances of this class observe a bus (which owns the actual
socket) when attached and queue received events for delivery."))
(defmethod notify ((connector in-connector)
(scope scope)
(action (eql :attached)))
(setf (connector-scope connector) scope)
(call-next-method))
(defmethod notify :after ((connector in-connector)
(bus bus)
(action (eql :attached)))
(notify bus connector (rsb.ep:subscribed (connector-scope connector))))
(defmethod notify :after ((connector in-connector)
(bus bus)
(action (eql :detached)))
(notify bus connector (rsb.ep:unsubscribed (connector-scope connector))))
(defmethod notification->event ((connector in-connector)
(notification notification)
(wire-schema t))
(let+ (((&accessors-r/o (converter connector-converter)) connector)
(expose-wire-schema? (connector-expose?
connector :rsb.transport.wire-schema))
(expose-payload-size? (connector-expose?
connector :rsb.transport.payload-size)))
;; NOTIFICATION has been unpacked into a `notification' instance,
;; now try to convert it, and especially its payload, into an
;; `event' instance and an event payload. There are three possible
;; outcomes:
;; 1. The notification (maybe in conjunction with previously
;; received notifications) forms a complete event
;; a) The payload conversion succeeds
;; In this case, an `event' instance is returned
;; b) The payload conversion fails
;; In this case, an error is signaled
;; 2. The notification does not form a complete event
;; In this case, nil is returned.
(with-condition-translation
(((error decoding-error)
:encoded notification
:format-control "~@<After unpacking, the ~
notification~_~A~_could not be converted ~
into an event.~:@>"
:format-arguments (list (with-output-to-string (stream)
(describe notification stream)))))
(notification->event*
converter notification
:expose-wire-schema? expose-wire-schema?
:expose-payload-size? expose-payload-size?))))
;;; `in-pull-connector'
(defclass in-pull-connector (error-handling-pull-receiver-mixin
in-connector)
((queue :type lparallel.queue:queue
:reader connector-queue
:initform (lparallel.queue:make-queue)
:documentation
"Stores notifications as they arrive via the message bus."))
(:metaclass connector-class)
(:direction :in-pull)
(:documentation
"Superclass in-direction, push-style socket connectors."))
(defmethod handle ((connector in-pull-connector)
(data notification))
;; Put DATA into the queue of CONNECTOR for later retrieval.
(lparallel.queue:push-queue data (connector-queue connector)))
(defmethod receive-notification ((connector in-pull-connector)
(block? (eql nil)))
;; Extract and return one event from the queue maintained by
;; CONNECTOR, if there are any. If there are no queued events,
;; return nil.
(lparallel.queue:try-pop-queue (connector-queue connector)))
(defmethod receive-notification ((connector in-pull-connector)
(block? t))
;; Extract and return one event from the queue maintained by
;; CONNECTOR, if there are any. If there are no queued events,
;; block.
(lparallel.queue:pop-queue (connector-queue connector)))
(defmethod emit ((connector in-pull-connector) (block? t))
;; Maybe block until a notification is received. Try to convert into
;; an event and return the event in case of success. In blocking
;; mode, wait for the next notification.
(iter (let* ((payload (receive-notification connector block?))
(event (when payload
(notification->event
connector payload :undetermined))))
;; Due to non-blocking receive mode and error handling
;; policies, we may not obtain an `event' instance from the
;; notification.
(when event
(dispatch connector event))
(when (or event (not block?))
(return event)))))
(defmethod print-items:print-items append ((object in-pull-connector))
(let ((count (lparallel.queue:queue-count (connector-queue object))))
`((:queue-count ,count " (~D)" ((:after :url))))))
;;; `in-push-connector'
(defclass in-push-connector (error-policy-handler-mixin
restart-handler-mixin
in-connector)
()
(:metaclass connector-class)
(:direction :in-push)
(:documentation
"Superclass for in-direction, push-style socket connectors."))
(defmethod handle ((connector in-push-connector)
(data notification))
;; TODO(jmoringe): condition translation?
(when-let ((event (notification->event connector data :undetermined)))
(dispatch connector event)))
;;; `out-connector'
(defclass out-connector (error-handling-sender-mixin
restart-notification-sender-mixin
timestamping-sender-mixin
connector)
()
(:metaclass connector-class)
(:direction :out)
(:documentation
"Superclass for out-direction socket connectors."))
(defmethod handle ((connector out-connector)
(event event))
(send-notification connector (event->notification connector event)))
(defmethod event->notification ((connector out-connector)
(event event))
;; Delegate conversion to `event->notifications'. The primary
;; purpose of this method is performing the conversion with restarts
;; installed.
(event->notification* connector event))
(defmethod send-notification ((connector out-connector)
(notification notification))
(handle (connector-bus connector) notification))
| 10,937 | Common Lisp | .lisp | 236 | 35.262712 | 79 | 0.59597 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 2c22e39e61c9f2fdb715328db9df245c71bcb9db52e962b08ff09f9704528965 | 25,351 | [
-1
] |
25,352 | package.lisp | open-rsx_rsb-cl/src/transport/socket/package.lisp | ;;;; package.lisp --- Package definition for the transport.socket module.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.transport.socket
(:nicknames #:rsb.tp.sock)
(:shadow
#:connector)
(:use
#:cl
#:alexandria
#:let-plus
#:iterate
#:more-conditions
#:nibbles
#:rsb
#:rsb.event-processing
#:rsb.transport
#:rsb.protocol)
(:shadowing-import-from #:rsb
#:event-id
#:event-meta-data)
;; Conditions
(:export
#:socket-bus-auto-connection-error)
(:documentation
"This package contains a transport implementation that uses
multiple point-to-point socket connections to simulate a bus."))
(cl:in-package #:rsb.transport.socket)
(define-constant +backscatter-warning+
#.(format
nil
"Since currently all events are independently delivered to all ~
processes, regardless of whether the individual processes ~
actually contain participants, this transport cannot work ~
efficiently with participants distributed across many ~
processes.")
:test #'string=)
| 1,159 | Common Lisp | .lisp | 39 | 25.461538 | 73 | 0.700901 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 0b7812c964e8cc16ba7fadebf06e461db69da2ea7f5f7199afc64c1cc347ddcf | 25,352 | [
-1
] |
25,353 | connectors-unix.lisp | open-rsx_rsb-cl/src/transport/socket/connectors-unix.lisp | ;;;; connectors-unix.lisp --- UNIX-domain-socket-based transport.
;;;;
;;;; Copyright (C) 2014, 2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; `unix-connector'
(defclass unix-connector (connector)
(;; Option slots
(name :type string
:reader connector-name
:writer (setf connector-%name)
:documentation
#.(format nil "The name of the UNIX socket in the abstract ~
namespace.~@
~@
The name is not translated into a filesystem path and ~
there is no filesystem object object corresponding to the ~
socket.")))
(:default-initargs
:name (missing-required-initarg 'unix-connector :name))
(:metaclass connector-class)
(:transport :unix-socket)
(:options
(:name &slot name))
(:documentation
"Superclass for UNIX socket connector classes.
Takes of care of obtaining the `:unix-socket' transport object as
well as setting up the UNIX socket-specific name options."))
(defmethod shared-initialize :after ((instance unix-connector)
(slot-names t)
&key
(name nil name-supplied?))
(when name-supplied?
(setf (connector-%name instance) name
(puri:uri-query (slot-value instance 'rsb::uri))
(format nil "?~A" name))))
(defmethod make-connection-address ((transport unix-socket-transport)
(connector unix-connector))
(list :name (connector-name connector)))
(defmethod make-connection-options ((transport unix-socket-transport)
(connector unix-connector))
'())
;;; Direction-specific connector classes
(defclass unix-in-pull-connector (unix-connector
in-pull-connector)
()
(:metaclass connector-class))
(register-connector :unix-socket :in-pull 'unix-in-pull-connector)
(defclass unix-in-push-connector (unix-connector
in-push-connector)
()
(:metaclass connector-class))
(register-connector :unix-socket :in-push 'unix-in-push-connector)
(defclass unix-out-connector (unix-connector
out-connector)
()
(:metaclass connector-class))
(register-connector :unix-socket :out 'unix-out-connector)
| 2,427 | Common Lisp | .lisp | 59 | 32.237288 | 71 | 0.626859 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | fb3ba0038963aad96a980fd00d84aa7435f04088b1bdc046898c9d1ff0cd9f3d | 25,353 | [
-1
] |
25,354 | socket-tcp.lisp | open-rsx_rsb-cl/src/transport/socket/socket-tcp.lisp | ;;;; socket-tcp.lisp --- TCP socket Provider of the socket service.
;;;;
;;;; Copyright (C) 2014, 2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
(defclass tcp-passive-stream-socket (usocket:stream-server-usocket)
((options :initarg :options
:reader socket-%options
:initform '())))
(defmethod usocket:socket-accept ((socket tcp-passive-stream-socket)
&key element-type)
(declare (ignore element-type))
(when-let ((client-socket (call-next-method)))
(let+ (((&plist-r/o (nodelay? :nodelay?)) (socket-%options socket)))
(log:debug "~@<~A is enabling ~S socket option on accepted ~
socket ~A~@:>"
socket :tcp-nodelay client-socket)
;; Set requested TCPNODELAY behavior.
(setf (usocket:socket-option client-socket :tcp-nodelay) nodelay?))
client-socket))
(defun make-tcp-passive-socket
(&key
(host (missing-required-argument :host))
(port (missing-required-argument :port))
(backlog 5)
(reuse-address? nil)
(nodelay? nil))
(let ((socket (usocket:socket-listen host port
:element-type '(unsigned-byte 8)
:backlog backlog
:reuse-address reuse-address?)))
(if nodelay?
(change-class socket 'tcp-passive-stream-socket
:options '(:nodelay? t))
socket)))
(service-provider:register-provider/function
'socket '(:tcp :passive) :function 'make-tcp-passive-socket)
(defun make-tcp-active-socket
(&key
(host (missing-required-argument :host))
(port (missing-required-argument :port))
(nodelay? nil))
(usocket:socket-connect host port
:element-type '(unsigned-byte 8)
:nodelay nodelay?))
(service-provider:register-provider/function
'socket '(:tcp :active) :function 'make-tcp-active-socket)
| 2,101 | Common Lisp | .lisp | 48 | 34.604167 | 73 | 0.59433 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 4d8bd92a35f7117d1357ef6c0650b4fa3f596c4c29d0e330d7f81d2cc64233b7 | 25,354 | [
-1
] |
25,355 | socket-unix.lisp | open-rsx_rsb-cl/src/transport/socket/socket-unix.lisp | ;;;; socket-unix.lisp --- UNIX domain socket provider of the socket service.
;;;;
;;;; Copyright (C) 2014, 2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
(defun %make-local/abstract-socket (name)
(values (make-instance 'sb-bsd-sockets:local-abstract-socket :type :stream)
name))
(defun make-unix-passive-socket
(&key
(name (missing-required-argument :name))
(backlog 5))
(let+ (((&values socket address) (%make-local/abstract-socket name)))
;; Bind to ADDRESS which is a name in the "abstract" namespace.
(sb-bsd-sockets:socket-bind socket address)
;; Start listening.
(sb-bsd-sockets:socket-listen socket backlog)
;; Finally construct and return an usocket wrapper.
(usocket::make-stream-server-socket socket :element-type '(unsigned-byte 8))))
(service-provider:register-provider/function
'socket '(:local/abstract :passive) :function 'make-unix-passive-socket)
(defun make-unix-active-socket
(&key
(name (missing-required-argument :name)))
(let+ (((&values socket address) (%make-local/abstract-socket name))
(stream (usocket:with-mapped-conditions (socket)
(sb-bsd-sockets:socket-connect socket address)
(sb-bsd-sockets:socket-make-stream
socket :input t :output t :buffering :full
:element-type '(unsigned-byte 8)
:serve-events nil))))
;; Finally construct and return an usocket wrapper.
(usocket::make-stream-socket :socket socket :stream stream)))
(service-provider:register-provider/function
'socket '(:local/abstract :active) :function 'make-unix-active-socket)
| 1,737 | Common Lisp | .lisp | 36 | 42.083333 | 82 | 0.685546 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b6c90e1642c84add3a5217a1fb1e7e12aff790e886dd1da502c37ab7441b4dff | 25,355 | [
-1
] |
25,356 | puri-patch.lisp | open-rsx_rsb-cl/src/transport/socket/puri-patch.lisp | (cl:in-package #:puri)
(defun parse-uri (thing &key (class 'uri) &aux escape)
(when (uri-p thing) (return-from parse-uri thing))
(setq escape (escape-p thing))
(multiple-value-bind (scheme host port path query fragment)
(parse-uri-string thing)
(when scheme
(setq scheme
(intern (funcall
(case *current-case-mode*
((:case-insensitive-upper :case-sensitive-upper)
#'string-upcase)
((:case-insensitive-lower :case-sensitive-lower)
#'string-downcase))
(decode-escaped-encoding scheme escape))
(find-package :keyword))))
(when (and scheme (eq :urn scheme))
(return-from parse-uri
(make-instance 'urn :scheme scheme :nid host :nss path)))
(when host (setq host (decode-escaped-encoding host escape)))
(when port
(setq port (read-from-string port))
(cond
((not (numberp port))
(error "port is not a number: ~s." port))
((minusp port)
(error "port is not non-negative integer: ~d." port)))
(when (eql port (case scheme
(:http 80)
(:https 443)
(:ftp 21)
(:telnet 23)))
(setq port nil)))
(when (or (string= "" path)
(and ;; we canonicalize away a reference to just /:
scheme
(member scheme '(:http :https :ftp) :test #'eq)
(string= "/" path)))
(setq path nil))
(when path
(setq path
(decode-escaped-encoding path escape *reserved-path-characters*)))
(when query (setq query (decode-escaped-encoding query escape)))
(when fragment
(setq fragment
(decode-escaped-encoding fragment escape
*reserved-fragment-characters*)))
(if* (eq 'uri class)
then ;; allow the compiler to optimize the make-instance call:
(make-instance 'uri
:scheme scheme
:host host
:port port
:path path
:query query
:fragment fragment
:escaped escape)
else ;; do it the slow way:
(make-instance class
:scheme scheme
:host host
:port port
:path path
:query query
:fragment fragment
:escaped escape))))
| 2,667 | Common Lisp | .lisp | 66 | 25.681818 | 78 | 0.489796 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6313d762386a2a9cb19eb838e08393f1ce25a5bf0be85f203fc4b75fd0a6b244 | 25,356 | [
-1
] |
25,357 | transport-unix.lisp | open-rsx_rsb-cl/src/transport/socket/transport-unix.lisp | ;;;; transport-unix.lisp --- UNIX-domain-socket-based transport.
;;;;
;;;; Copyright (C) 2014, 2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
(defclass unix-socket-transport (socket-transport)
((address-family :allocation :class
:initform :local/abstract))
(:documentation
"The UNIX domain socket transport."))
(register-transport
:unix-socket
:transport-class 'unix-socket-transport
:schemas '(:unix :unix-socket)
:wire-type 'nibbles:octet-vector
:remote? nil
:documentation
#.(format nil "UNIX domain socket-based transport for same-computer ~
communication.~@
~@
One of the communicating processes acts as the server, opening a ~
listening UNIX domain socket. Other processes (running on the same ~
machine) connect to this socket to send and receive events. Within ~
each processes, arbitrary numbers of participants can share the ~
respective socket connection of the process.~@
~@
~A"
+backscatter-warning+))
| 1,099 | Common Lisp | .lisp | 29 | 34.034483 | 72 | 0.70478 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5a132308e50234e800468b9f1bb4cc32c2b94ed183595033067d72856e581098 | 25,357 | [
-1
] |
25,358 | conditions.lisp | open-rsx_rsb-cl/src/transport/socket/conditions.lisp | ;;;; conditions.lisp --- Conditions used in the socket transport.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
(define-condition socket-bus-auto-connection-error (rsb-error
simple-error)
()
(:report
(lambda (condition stream)
(format stream "~@<Failed to connect to socket-based bus as ~
automatically determined client or server~@:>")
(maybe-print-explanation stream condition)))
(:documentation
"This error is signaled when a an attempt to obtain a bus provider
in automatic client vs. server selection mode."))
(define-condition connection-shutdown-requested (condition)
((connection :initarg :connection
:type t
:reader connection-shutdown-requested-connection
:documentation
"Stores the connection the shutdown of which has been
requested."))
(:default-initargs
:connection (missing-required-initarg
'connection-shutdown-requested :connection))
(:documentation
"This condition is signaled when the remote peer requests
termination of the connection."))
(defmethod shutdown-handshake-for ((condition connection-shutdown-requested))
:receive)
| 1,393 | Common Lisp | .lisp | 32 | 35.875 | 77 | 0.670597 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 1de130bc3f9fc51f08aec2e5a6f4a38d00f62146076ceaa94c3cd47b2c232058 | 25,358 | [
-1
] |
25,359 | bus-client.lisp | open-rsx_rsb-cl/src/transport/socket/bus-client.lisp | ;;;; bus-client.lisp --- A bus provider that uses a client socket.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; `bus-client' class
(defclass bus-client (bus)
()
(:documentation
"Instances of this class provide access to a bus by means of a
client socket."))
(defmethod initialize-instance :after ((instance bus-client)
&key
make-socket)
;; Add a single connection to INSTANCE. The returned connection is
;; guaranteed to have completing the handshake and thus receives all
;; events published on the bus afterward.
(setf (bus-connections instance)
(list (make-instance 'bus-connection
:make-socket make-socket
:handshake :receive))))
| 915 | Common Lisp | .lisp | 22 | 33 | 70 | 0.620922 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | adf593e35a336aece19bcb2b1b6a28fcd19981cb7b074518ded019f6584d8004 | 25,359 | [
-1
] |
25,360 | bus-server.lisp | open-rsx_rsb-cl/src/transport/socket/bus-server.lisp | ;;;; bus-server.lisp --- A class that accepts connections from bus clients.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; `bus-server' class
(deftype leftover-connections-policy ()
'(member :close :wait))
(defclass bus-server (bus
threaded-receiver-mixin)
((socket :reader bus-socket
:writer (setf bus-%socket)
:documentation
"Stores the listening socket which accepts client
connections.")
(state :type (member :active :shutdown)
:accessor bus-state
:initform :active
:documentation
"Stores the state of the bus server.
Currently only used during shutdown.")
(state-variable :reader bus-state-variable
:initform (bt:make-condition-variable :name "Bus state"))
(if-leftover-connections :initarg :if-leftover-connections
:type leftover-connections-policy
:reader bus-if-leftover-connections
:initform :wait))
(:documentation
"Provides access to a bus through a listen socket to which bus
clients connect.
Each client connection causes a `bus-connection' instance to be
added to the list of connections. These objects are removed when
the connections are closed."))
(defmethod initialize-instance :after ((instance bus-server)
&key
make-socket)
;; Setup the listening socket.
(setf (bus-%socket instance) (funcall make-socket))
(log:info "~@<~A has opened listen socket~@:>" instance)
(log:info "~@<~A is starting acceptor thread~@:>" instance)
(start-receiver instance))
(defmethod (setf bus-connections) :after ((new-value null)
(bus bus-server))
(with-locked-bus (bus :connections? t)
(bt:condition-notify (bus-state-variable bus))))
(defmethod notify ((bus bus-server)
(subject (eql t))
(action (eql :detached)))
;; Close the listen socket to prevent new client connections and
;; interrupt the accept loop.
(log:info "~@<~A is closing listen socket~@:>" bus)
(let+ (((&structure bus-
connections socket state connections-lock state-variable
if-leftover-connections)
bus))
(unwind-protect
(progn
(setf state :shutdown)
#+sbcl (sb-bsd-sockets:socket-shutdown
(usocket:socket socket) :direction :input)
;; Check whether there are leftover connections. If so warn
;; and, depending on `if-leftover-connections' wait for
;; them to close.
(with-locked-bus (bus :connections? t)
(when connections
(log:warn "~@<When shutting down bus provider ~A, ~
leftover connection~P:~
~@:_~{• ~A~^~@:_~}~@:>"
bus (length connections) connections)
(when (eq if-leftover-connections :wait)
(loop :while connections
:do (bt:condition-wait state-variable connections-lock))
(log:info "~@<All connections closed.~@:>"))))
(usocket:socket-close socket)) ; TODO ignore errors?
;; Wait for the acceptor thread to exit.
(log:info "~@<~A is stopping acceptor thread~@:>" bus)
(unwind-protect
(stop-receiver bus)
;; Close existing connections.
(call-next-method)))))
;;; Accepting clients
(defmethod receive-messages ((bus bus-server))
(let+ (((&structure bus- connections (server-socket socket) state) bus)
((&flet accept ()
;; Try to accept a client. In case of an error, check
;; whether the bus socket has been removed, indicating
;; orderly shutdown..
(handler-bind ((usocket:socket-error
(lambda (condition)
(log:debug "~@<~A encountered a socket ~
error while accepting: ~A~@:>"
bus condition)
(when (eq state :shutdown)
(exit-receiver)))))
(usocket:socket-accept
server-socket :element-type '(unsigned-byte 8))))))
;; Main processing loop. Wait for activity on the server socket.
(log:debug "~@<~A is starting to accept connections~:@>" bus)
(iter (when-let ((client-socket (accept)))
;; Since we create and add the new connection with the bus
;; lock held, all events published on BUS after the
;; handshake of the new connection completes are
;; guaranteed to be delivered to the new connection. Also
;; note that the server role of the handshake, sending 4
;; bytes, usually does not involve blocking.
(with-locked-bus (bus)
(push (make-instance 'bus-connection
:socket client-socket
:handshake :send)
connections))
(log:info "~@<~A accepted bus client ~
~/rsb.transport.socket::print-socket/~@:>"
bus client-socket)))))
;;;
(defmethod print-items:print-items append ((object bus-server))
(let+ (((&structure-r/o bus- socket state) object))
`((:state ,state "~A "
((:before :connection-count)))
(:socket ,socket " ~:/rsb.transport.socket::print-socket/"
((:after :connector-count))))))
| 6,044 | Common Lisp | .lisp | 121 | 35.867769 | 85 | 0.543607 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 3b66d00a37889bb12c014b1930a21117f163d05e830018252354db09db2c4ee5 | 25,360 | [
-1
] |
25,361 | connectors-tcp.lisp | open-rsx_rsb-cl/src/transport/socket/connectors-tcp.lisp | ;;;; connectors-tcp.lisp --- TCP/IP-based socket transport.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; `tcp-connector'
(defclass tcp-connector (connector)
(;; Option slots
(host :initarg :host
:type string
:reader connector-host
:initform *default-host*
:documentation
"The name of the host on which the server is listener in case of clients and the bind address in case of the server.")
(port :type (unsigned-byte 16)
:reader connector-port
:initform *default-port*
:documentation
"The port on which the server is listening in case of clients and the port on which connections should be accepted in case of the server.")
(portfile :initarg :portfile
:type (or null string)
:reader connector-portfile
:initform nil
:documentation
"Optionally stores the name of a file (or \"-\" for standard-output) into which an automatically assigned port number should be written when acting as server on an arbitrary free port (indicated by port number 0).")
(nodelay? :type boolean
:reader connector-nodelay?
:initform t
:documentation
"Controls whether decreased throughput should be traded for reduced latency by the connector. For TCP connections this means the TCP_NODELAY option should be set on the socket implementing the bus connection."))
(:default-initargs
:host (missing-required-initarg 'tcp-connector :host)
:port (missing-required-initarg 'tcp-connector :port))
(:metaclass connector-class)
(:transport :tcp-socket)
(:options
(:host &slot host)
(:port &slot port)
(:portfile &slot)
(:tcpnodelay &slot nodelay?))
(:documentation
"Superclass for TCP socket connector classes.
Takes of care of obtaining the `:tcp-socket' transport object as
well as setting up the TCP socket-specific options host, port,
portfile and nodelay?."))
;; TODO(jmoringe, 2011-12-14): temp solution until config system works properly
(defmethod initialize-instance :after ((instance tcp-connector)
&key
port
portfile
tcpnodelay
nodelay?)
(let ((port (etypecase port
(string
(parse-integer port))
((unsigned-byte 16)
port)))
(nodelay? (let ((value (or tcpnodelay nodelay?)))
(etypecase value
(boolean value)
(string
(cond
((string= value "0") nil)
((string= value "1") t)
(t (error "~@<Invalid value ~S.~@:>"
value)))))))
(server? (connector-server? instance)))
(when (and (not (eq server? t)) portfile)
(incompatible-initargs 'tcp-connector
:portfile portfile
:server? server?))
(setf (slot-value instance 'port) port
(slot-value instance 'nodelay?) nodelay?)))
(defmethod make-connection-address ((transport tcp-socket-transport)
(connector tcp-connector))
(let+ (((&structure-r/o connector- host port) connector))
(list :host host :port port)))
(defmethod make-connection-options ((transport tcp-socket-transport)
(connector tcp-connector))
(list :nodelay? (connector-nodelay? connector)))
(defmethod notify :before ((connector tcp-connector)
(subject bus)
(action (eql :attached)))
(maybe-write-port-file (connector-portfile connector) subject))
;;; Direction-specific connector classes
(defclass tcp-in-pull-connector (tcp-connector
in-pull-connector)
()
(:metaclass connector-class))
(register-connector :tcp-socket :in-pull 'tcp-in-pull-connector)
(defclass tcp-in-push-connector (tcp-connector
in-push-connector)
()
(:metaclass connector-class))
(register-connector :tcp-socket :in-push 'tcp-in-push-connector)
(defclass tcp-out-connector (tcp-connector
out-connector)
()
(:metaclass connector-class))
(register-connector :tcp-socket :out 'tcp-out-connector)
| 4,779 | Common Lisp | .lisp | 101 | 35.009901 | 228 | 0.576148 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5f22c48d4bddcc4c070f5afa901d428ac54f0fc7104abd58a27efd6aba854d4f | 25,361 | [
-1
] |
25,362 | transport-tcp.lisp | open-rsx_rsb-cl/src/transport/socket/transport-tcp.lisp | ;;;; transport-tcp.lisp --- TCP/IP-based socket transport.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
(defvar *default-host* "localhost"
"Default host used by the socket-based transport.")
(defvar *default-port* 55555
"Default port used by the socket-based transport.")
;;; Transport
(defclass tcp-socket-transport (socket-transport)
((address-family :allocation :class
:initform :tcp))
(:documentation
"The TCP/IP socket transport."))
(register-transport
:tcp-socket
:transport-class 'tcp-socket-transport
:schemas '(:socket :tcp-socket)
:wire-type 'nibbles:octet-vector
:remote? t
:documentation
#.(format nil "TCP-Socket-based transport for small numbers of ~
processes.~@
~@
One of the communicating processes acts as the server, opening a ~
listening TCP socket. Other processes connect to this socket to ~
send and receive events. Within each processes, arbitrary ~
numbers of participants can share the respective socket ~
connection of the process.~@
~@
~A"
+backscatter-warning+))
(defmethod service-provider:make-provider
((service t) (provider tcp-socket-transport) &rest args &key)
;; Normalize supported schemas (:socket and :tcp-socket) to
;; :tcp-socket.
(apply #'call-next-method service provider
(list* :schema :tcp-socket (remove-from-plist args :schema))))
(defmethod check-connection-options ((tansport tcp-socket-transport)
(bus-options list)
(connector-options list))
;; All options except portfile have to match when a connector is
;; added to an existing bus.
(iter (for (key value) on connector-options :by #'cddr)
(when (eq key :portfile)
(next-iteration))
(let ((bus-value (getf bus-options key)))
(unless (equalp bus-value value)
(error "~@<Incompatible values for option ~S: current ~
bus uses value ~S; requested value is ~S.~@:>"
key bus-value value)))))
(defmethod transport-ensure-bus ((transport tcp-socket-transport)
(role (eql :server!))
(connector t)
(address list)
&rest options)
;; Listen on all interfaces.
(apply #'call-next-method transport role connector
(list* :host "0.0.0.0" (remove-from-plist address :host))
options))
| 2,655 | Common Lisp | .lisp | 62 | 34.83871 | 77 | 0.624613 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 410263228e02e6580ef78d0a39d663d79c627ce950428a507207cbd6097cd1f6 | 25,362 | [
-1
] |
25,363 | bus-connection.lisp | open-rsx_rsb-cl/src/transport/socket/bus-connection.lisp | ;;;; bus-connection.lisp --- Connection class used by bus provider.
;;;;
;;;; Copyright (C) 2011-2017 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.socket)
;;; Utility functions
(defun %make-error-policy (connection &optional function)
;; Return a error policy function that calls FUNCTION and closes
;; CONNECTION when invoked.
(named-lambda bus-connection-error-policy (condition)
;; Closing CONNECTION can fail (or at least signal an error) for
;; various reasons. Make sure the installed error policy is
;; still called.
(unwind-protect ; needed because `disconnect' may unwind.
(handler-case
;; `disconnect' returns nil if CONNECTION was already
;; being closed. In that case, we do not have to call
;; FUNCTION (because somebody else did/does) and can
;; abort the receiver thread right away.
(let ((handshake (shutdown-handshake-for condition)))
(log:info "~@<~A is maybe disconnecting ~
~:[without~;~:*with ~A role of~] shutdown ~
handshake and executing error policy ~A ~
due to condition: ~A~@:>"
connection handshake function condition)
(when (not (disconnect connection :handshake handshake))
(setf function nil)))
(error (condition)
(log:warn "~@<When ~A executed error policy, error ~
closing connection: ~A~@:>"
connection condition)))
;; If necessary, execute the original error policy, FUNCTION.
(when function
(funcall function condition)))))
;; Return a suitable send/receive buffer for a given size, creating or
;; enlarging it first, if necessary.
(macrolet
((define-ensure-buffer (name accessor)
`(progn
(declaim (inline ,name))
(defun ,name (connection size)
(or (when-let ((buffer (,accessor connection)))
(locally (declare (type octet-vector buffer))
(when (>= (length buffer) size)
buffer)))
(setf (,accessor connection)
(make-octet-vector size)))))))
(define-ensure-buffer %ensure-receive-buffer connection-%receiver-buffer)
(define-ensure-buffer %ensure-send-buffer connection-%send-buffer))
;;; `bus-connection'
(defclass bus-connection (broadcast-processor
threaded-message-receiver-mixin
restart-notification-receiver-mixin
error-handling-push-receiver-mixin
restart-notification-sender-mixin
error-handling-sender-mixin
print-items:print-items-mixin)
((socket :reader connection-socket
:writer (setf connection-%socket)
:documentation
"Stores the socket through which access to he bus
is implemented.")
(receive-buffer :type (or null octet-vector)
:accessor connection-%receiver-buffer
:initform nil
:documentation
"Static (occasionally enlarged) buffer for
receiving and unpacking serialized
notifications.")
(send-buffer :type (or null octet-vector)
:accessor connection-%send-buffer
:initform nil
:documentation
"Static (occasionally enlarged) buffer for packing
and sending notifications.")
(closing? :type (member nil t :send :receive)
:reader connection-closing?
:accessor connection-%closing?
:initform nil
:documentation
"Indicates indicates whether the connection is
currently closing and, potentially, the role of
the connection within the shutdown handshake.")
(lock :reader connection-lock
:initform (bt:make-lock "Connection lock")
:documentation
"Stores a lock that protects the connection from
concurrent modifications. Currently, this is only
used to prevent parallel attempts to close the
connection."))
(:documentation
"Instances of this class manage connections to/from clients of a
socket-based bus.
A bus connection is a bi-direction stream of notifications which
are sent and received by participants in different
processes. Client processes use `bus-connection' instances to
connect to socket-based buses and server processes providing these
buses maintain one `bus-connection' instance for each connected
client process.
When a process is connected to a socket-based bus as a client, the
process uses a single `bus-connection' instance for all
participants in the process. Similarly, a process that provides a
socket-based bus as a server creates `bus-connection' instances
for remote processes, but shares these among participants in the
process."))
(defmethod initialize-instance :after ((instance bus-connection)
&key
socket
make-socket
handshake)
;; Install socket (opening it, if specified necessary).
(setf (connection-%socket instance)
(cond
(socket)
(make-socket
(funcall make-socket))))
;; If requested, perform handshake in the requested role.
(when handshake
(handshake instance :setup handshake)))
(defmethod shared-initialize :after ((instance bus-connection)
(slot-names t)
&key
(error-policy nil error-policy-supplied?))
;; Install or change (when reinitializing) error policy.
(when error-policy-supplied?
(setf (processor-error-policy instance) error-policy)))
(defmethod (setf processor-error-policy) ((new-value t)
(connection bus-connection))
;; Wrap NEW-VALUE in an error policy that exits the receiver thread
;; after calling NEW-VALUE.
(call-next-method (%make-error-policy connection new-value) connection))
;;; Protocol
(defun handshake (connection phase role)
(let ((stream (usocket:socket-stream (connection-socket connection))))
(log:info "~@<~A is performing ~A role of ~A handshake~@:>"
connection role phase)
;; TODO temp until we implement shutdown protocol
(if (and (eq phase :shutdown) (eq role :send))
(progn
(finish-output stream)
(usocket:socket-shutdown (connection-socket connection) :output))
(ecase role
(:send
(write-ub32/le 0 stream)
(finish-output stream))
(:receive
(unless (zerop (read-ub32/le stream))
(error "~@<Protocol error during ~A role of ~A handshake; ~
expected four 0 bytes.~@:>"
role phase)))))
(log:info "~@<~A performed ~A role of ~A handshake~@:>"
connection role phase)))
;;; Receiving
(defmethod receive-notification ((connection bus-connection)
(block? t))
(let* ((stream (usocket:socket-stream (connection-socket connection)))
(length (handler-case ; TODO temp until we implement shutdown protocol
(read-ub32/le stream)
(end-of-file ()
(log:info "~@<~A received end-of-file; treating ~
as shutdown request~@:>"
connection)
(funcall (processor-error-policy connection)
(make-condition 'connection-shutdown-requested
:connection connection))
(abort)))))
(if (zerop length)
(progn
(log:info "~@<~A received shutdown request~@:>" connection)
(funcall (processor-error-policy connection)
(make-condition 'connection-shutdown-requested
:connection connection))
(abort))
(let* ((buffer (%ensure-receive-buffer connection length))
(received (read-sequence buffer stream :end length)))
(unless (= received length)
(error "~@<Short read (expected: ~D; got ~D)~@:>"
length received))
(values (make-wire-notification buffer length) :undetermined))))) ; TODO ownership of BUFFER
(defmethod receive-notification ((connection bus-connection)
(block? (eql nil)))
;; Check whether reading would block and only continue if not.
(let ((stream (usocket:socket-stream (connection-socket connection))))
(when (or block? (listen stream))
(call-next-method))))
(defmethod notification->event ((connection bus-connection)
(notification wire-notification)
(wire-schema t))
;; Try to unpack NOTIFICATION into a `notification' instance. Signal
;; `decoding-error' if that fails.
(let+ (((&structure-r/o wire-notification- buffer end) notification))
(with-condition-translation
(((error decoding-error)
:encoded (subseq buffer 0 end)
:format-control "~@<The wire-data could not be unpacked as a ~
protocol buffer of kind ~S.~:@>"
:format-arguments (list 'notification)))
(pb:unpack buffer 'notification 0 end))))
;;; Sending
(defmethod send-notification ((connection bus-connection)
(notification wire-notification))
(when (connection-%closing? connection)
(log:info "~@<~A is dropping a message since it is closing~@:>" connection)
(return-from send-notification))
(let+ ((stream (usocket:socket-stream (connection-socket connection)))
((&structure-r/o wire-notification- buffer end) notification))
(write-ub32/le end stream)
(write-sequence buffer stream :end end)
(force-output stream)))
(defmethod event->notification ((connection bus-connection)
(event notification))
;; Pack EVENT into an octet-vector.
(with-condition-translation
(((error encoding-error)
:event event
:format-control "~@<The event ~S could not be packed using ~
protocol buffer serialization.~@:>"
:format-arguments (list event)))
(let* ((length (pb:packed-size event))
(buffer (%ensure-send-buffer connection length)))
(declare (type notification-index length))
(pb:pack event buffer)
(make-wire-notification buffer length))))
(defmethod handle ((sink bus-connection) (data notification))
(bt:with-lock-held ((connection-lock sink))
(send-notification sink (event->notification sink data))))
;;; Shutdown
(defmethod disconnect ((connection bus-connection)
&key
abort
handshake)
(check-type handshake (member nil :send :receive))
(let+ (((&structure connection- lock (closing? %closing?) socket) connection))
;; Ensure that CONNECTION is not already closing or being closed.
(bt:with-lock-held (lock)
(when closing?
;; If `disconnect' is called with `handshake' :send, it waits
;; for being called with `handshake' :receive from another
;; thread.
(when (and (eq closing? :send) (eq handshake :receive))
(setf closing? handshake))
(return-from disconnect nil))
(setf closing? (or handshake t)))
;; If this really is the initial attempt to disconnect CONNECTION,
;; perform a shutdown handshake, if requested, stop the receiver
;; thread and close the socket. Note that this will be skipped in
;; case of an error-induced shutdown (`handshake' is nil in that
;; case).
(when (and (not abort) handshake)
;; Perform "send" part of shutdown handshake. This either
;; completes the shutdown sequence (if the remote peer initiated
;; it) or initiates it.
(handshake connection :shutdown :send)
;; Wait for the shutdown sequence to complete. This can be the
;; case immediately if we initiated it.
(iter (bt:with-lock-held (lock)
(until (eq closing? :receive)))
(repeat 5000)
(sleep .001))
(unless (eq closing? :receive)
(warn "~@<Did not receive acknowledgment of shutdown ~
handshake.~@:>")))
;; After the shutdown protocol has hopefully been completed, close
;; the socket and wait for the receiver thread to exit.
(unwind-protect
(ignore-errors
(log:info "~@<~A is closing socket~@:>" connection)
(usocket:socket-close socket))
;; If this is called from the receiver thread itself, it will
;; just abort and unwind at this point.
(log:info "~@<~A is stopping receiver thread~@:>" connection)
(stop-receiver connection))
;; Return t to indicate that we actually closed the connection.
t))
;;;
(defmethod print-items:print-items append ((object bus-connection))
(let+ (((&structure-r/o connection- socket closing?) object))
`((:closing? ,closing? "~:[open~;closing: ~:*~S~]")
(:socket ,socket " ~/rsb.transport.socket::print-socket/"
((:after :closing?))))))
| 13,947 | Common Lisp | .lisp | 281 | 37.740214 | 102 | 0.597081 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5282724fbb5fe7902fd33f0ad3cd9e9319a2291caa85573aaa831068a2bbeda1 | 25,363 | [
-1
] |
25,364 | transport.lisp | open-rsx_rsb-cl/src/transport/spread/transport.lisp | ;;;; transport.lisp --- Spread transport.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `spread-transport' transport class
(defclass spread-transport (transport)
((buses :reader %buses
:initform (make-hash-table :test #'equalp)
:documentation
"Maps Spread connection options to `bus' instances.")
(lock :reader %lock
:initform (bt:make-recursive-lock "Connections lock")
:documentation
"Protects the bus map."))
(:documentation
"Stores bus instances."))
;;; Transport registration
(register-transport
:spread
:transport-class 'spread-transport
:schemas :spread
:wire-type 'nibbles:octet-vector
:remote? t
:documentation
"A transport using the Spread group communication framework.
This transport maps scopes to Spread groups to allow multicast-based
distribution of events to interested processes.")
(defmethod print-items:print-items append ((object spread-transport))
(let ((bus-count (hash-table-count (%buses object))))
`((:bus-count ,bus-count " (B ~D)" ((:after :remote?))))))
(defmethod ensure-access ((transport spread-transport)
(options t)
(connector t))
(let+ (((&accessors-r/o (buses %buses) (lock %lock)) transport)
((&plist-r/o (name :name)
(tcpnodelay :tcpnodelay)
(age-limit :age-limit))
options)
(key (list name tcpnodelay age-limit)))
(log:debug "~@<~A is obtaining a bus for options ~S~@:>" transport key)
(bt:with-lock-held (lock)
(or (when-let ((candidate (gethash key buses)))
(bt:with-recursive-lock-held ((%connectors-lock candidate))
(when (%connectors candidate)
(notify connector candidate :attached)
candidate)))
(let* ((connection (make-instance 'connection :name name))
(bus (make-instance 'bus
:connection connection
:age-limit age-limit)))
(notify connector bus :attached)
(setf (gethash key buses) bus))))))
| 2,328 | Common Lisp | .lisp | 54 | 34.111111 | 75 | 0.599294 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 9df0708d5cd72360d9370fadfa9148ef8ddeb6844b7dc3288372aafbd950f7c1 | 25,364 | [
-1
] |
25,365 | conversion.lisp | open-rsx_rsb-cl/src/transport/spread/conversion.lisp | ;;;; conversion.lisp --- Event <-> notification conversion for Spread transport.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; Utility functions
(defun timestamp->unix-microseconds (timestamp)
"Convert the `local-time:timestamp' instance TIMESTAMP into an
integer which counts the number of microseconds since UNIX epoch."
(+ (* 1000000 (local-time:timestamp-to-unix timestamp))
(* 1 (local-time:timestamp-microsecond timestamp))))
(defun unix-microseconds->timestamp (unix-microseconds)
"Convert UNIX-MICROSECONDS to an instance of
`local-time:timestamp'."
(let+ (((&values unix-seconds microseconds)
(floor unix-microseconds 1000000)))
(local-time:unix-to-timestamp
unix-seconds :nsec (* 1000 microseconds))))
(declaim (inline string->bytes bytes->string))
(defun string->bytes (string)
"Convert STRING into an octet-vector."
(declare (notinline string->bytes))
(if (stringp string)
(sb-ext:string-to-octets string :external-format :ascii)
(string->bytes (princ-to-string string))))
(defun bytes->string (bytes)
"Convert BYTES into a string."
(sb-ext:octets-to-string bytes :external-format :ascii))
(defvar *keyword-readtable*
(let ((readtable (copy-readtable nil)))
(setf (readtable-case readtable) :invert)
readtable)
"This readtable is used to print and read keywords.
The goal is to get a natural mapping between Lisp keywords and
corresponding strings for most cases.")
(defun keyword->bytes (keyword)
"Convert the name of KEYWORD into an octet-vector."
(if (find #\: (symbol-name keyword))
(string->bytes (symbol-name keyword))
(let ((*readtable* *keyword-readtable*))
(string->bytes (princ-to-string keyword)))))
(defun bytes->keyword (bytes)
"Converter BYTES into a keyword."
(if (find (char-code #\:) bytes)
(intern (bytes->string bytes) (find-package :keyword))
(let ((*package* (find-package :keyword))
(*readtable* *keyword-readtable*))
(read-from-string (bytes->string bytes)))))
(defun wire-schema->bytes (wire-schema)
"Convert WIRE-SCHEMA to an ASCII representation stored in an
octet-vector."
(keyword->bytes wire-schema))
(defun bytes->wire-schema (bytes)
"Return a keyword representing the wire-schema encoded in bytes."
(when (emptyp bytes)
(error "~@<Empty wire-schema.~:@>"))
(bytes->keyword bytes))
;;; Notification -> Event
(defun assemble-notification (pool notification)
"Maybe assemble the `fragmented-notification' NOTIFICATION using POLL.
Return assembled `notification' instance or `nil'."
(declare (type fragmented-notification notification))
(if (<= (fragmented-notification-num-data-parts notification) 1)
;; When the event has been transmitted as a single notification,
;; an assembly step is not required.
(let* ((notification (fragmented-notification-notification notification))
(data (notification-data notification)))
(make-incoming-notification notification data))
;; When the event has been fragmented into multiple
;; notifications, try to assemble for each
;; notification. `merge-fragment' returns nil until all
;; fragments have arrived.
(when-let* ((assembly (merge-fragment pool notification))
(first-fragment (aref (assembly-fragments assembly) 0))
(data (assembly-concatenated-data assembly)))
(make-incoming-notification
(fragmented-notification-notification first-fragment)
data))))
(defun one-notification->event (converter notification data
&key
expose-wire-schema?
expose-payload-size?)
"Convert NOTIFICATION to an `event' using CONVERTER for DATA.
Return the decoded event."
(let+ (((&flet event-id->cons (event-id)
(cons (uuid:byte-array-to-uuid (event-id-sender-id event-id))
(event-id-sequence-number event-id))))
((&accessors-r/o
(scope notification-scope)
(event-id notification-event-id)
(method notification-method)
(wire-schema notification-wire-schema)
(meta-data notification-meta-data)
(causes notification-causes))
notification)
((&accessors-r/o
(sender-id event-id-sender-id)
(sequence-number event-id-sequence-number))
event-id)
(wire-schema (bytes->wire-schema wire-schema))
(data* (rsb.converter:wire->domain
converter data wire-schema))
(event (make-instance
'rsb:event
:origin (uuid:byte-array-to-uuid sender-id)
:sequence-number sequence-number
:scope (make-scope (bytes->string scope))
:method (unless (emptyp method)
(bytes->keyword method))
:causes (map 'list #'event-id->cons causes)
:data data*
:create-timestamp? nil))
((&flet set-timestamp (key value)
(unless (zerop value)
(setf (timestamp event key)
(unix-microseconds->timestamp value))))))
;; "User infos" and timestamps
(when meta-data
;; "User infos"
(iter (for user-info in-vector (event-meta-data-user-infos meta-data))
(setf (rsb:meta-data event (bytes->keyword
(user-info-key user-info)))
(bytes->string (user-info-value user-info))))
;; Set framework timestamps :create, :send, :receive and
;; :deliver, if present.
(set-timestamp :create (event-meta-data-create-time meta-data))
(set-timestamp :send (event-meta-data-send-time meta-data))
(set-timestamp :receive (event-meta-data-receive-time meta-data))
(set-timestamp :deliver (event-meta-data-deliver-time meta-data))
;; Set "user timestamps"
(iter (for user-time in-vector (event-meta-data-user-times meta-data))
(set-timestamp (bytes->keyword (user-time-key user-time))
(user-time-timestamp user-time))))
;; When requested, store transport metrics as meta-data items.
(when expose-wire-schema?
(setf (rsb:meta-data event :rsb.transport.wire-schema) wire-schema))
(when expose-payload-size?
(setf (rsb:meta-data event :rsb.transport.payload-size) (length data)))
event))
;;; Event -> Notification
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun make-notification (sequence-number origin
&optional
scope method wire-schema
meta-data timestamps causes)
"Make and return a `rsb.protocol:notification' instance with SEQUENCE-NUMBER,
ORIGIN and optionally SCOPE, METHOD, WIRE-SCHEMA, META-DATA and
CAUSES."
(let+ ((full? scope)
(event-id (make-instance 'event-id
:sender-id (uuid:uuid-to-byte-array origin)
:sequence-number sequence-number))
((&flet make-meta-data ()
(let ((result (make-instance 'event-meta-data)))
;; Add META-DATA.
(iter (for (key value) on meta-data :by #'cddr)
(vector-push-extend
(make-instance 'user-info
:key (keyword->bytes key)
:value (string->bytes value))
(event-meta-data-user-infos result)))
;; Add framework timestamps in TIMESTAMPS.
(macrolet
((set-timestamp (which accessor)
`(when-let ((value (getf timestamps ,which)))
(setf (,accessor result)
(timestamp->unix-microseconds value)))))
(set-timestamp :create event-meta-data-create-time)
(set-timestamp :send event-meta-data-send-time)
(set-timestamp :receive event-meta-data-receive-time)
(set-timestamp :deliver event-meta-data-deliver-time))
;; Add "user timestamps" in TIMESTAMPS.
(iter (for (key value) on timestamps :by #'cddr)
;; Framework timestamps are stored in dedicated fields of
;; the notification.
(unless (member key *framework-timestamps* :test #'eq)
(vector-push-extend
(make-instance 'user-time
:key (keyword->bytes key)
:timestamp (timestamp->unix-microseconds value))
(event-meta-data-user-times result))))
result)))
(notification (if full?
(make-instance 'notification
:event-id event-id
:scope (string->bytes (scope-string scope))
:wire-schema (wire-schema->bytes wire-schema)
:meta-data (make-meta-data))
(make-instance 'notification :event-id event-id))))
(when full?
;; Store the method of the event in the new notification if the
;; event has one.
(when method
(setf (notification-method notification) (keyword->bytes method)))
;; Add CAUSES.
(iter (for (origin-id . sequence-number) in causes)
(vector-push-extend
(make-instance 'event-id
:sender-id (uuid:uuid-to-byte-array
origin-id)
:sequence-number sequence-number)
(notification-causes notification))))
notification)))
(declaim (type message-length-limit *max-other-fragment-overhead*
*max-payload-overhead*))
(eval-when (:compile-toplevel :load-toplevel :execute)
(let* ((max-fragments 16383)
(notification (make-notification 0 (uuid:make-null-uuid)))
(fragment (make-instance 'fragmented-notification
:notification notification
:num-data-parts max-fragments
:data-part max-fragments))
(no-payload-overhead (pb:packed-size fragment))
(fragment-overhead (progn
(setf (notification-data notification)
(nibbles:make-octet-vector
network.spread:+maximum-message-data-length+))
(- (pb:packed-size fragment)
network.spread:+maximum-message-data-length+))))
(defparameter *max-other-fragment-overhead*
fragment-overhead
"Maximum overhead in octets for non-first fragments.")
(defparameter *max-payload-overhead*
(- fragment-overhead no-payload-overhead)
"Maximum overhead in octets added by the payload.")))
(declaim (ftype (function (notification simple-octet-vector message-length-limit)
(values function &optional))
split-notification))
(defun split-notification (notification wire-data max-fragment-size)
(let ((event-id (notification-event-id notification))
(data-size (length wire-data))
(offset 0)
(i 0)
(num-parts 0)
(other-fragment-payload-size (- max-fragment-size
*max-other-fragment-overhead*)))
(declare (type array-index offset i num-parts))
(flet ((make-fragment ()
(unless (or (zerop i) (< i num-parts))
(return-from make-fragment))
(let* ((notification (if (zerop i)
notification
(make-instance 'notification
:event-id event-id)))
(fragment (make-instance 'fragmented-notification
:notification notification
:num-data-parts num-parts
:data-part i))
(payload-size (if (zerop i)
(- max-fragment-size
(the message-length-limit
(pb:packed-size fragment))
*max-payload-overhead*)
other-fragment-payload-size))
(payload-size (min payload-size (- data-size offset))))
(when (minusp payload-size)
(error 'insufficient-room
:available max-fragment-size
:required (+ (the message-length-limit
(pb:packed-size fragment))
*max-payload-overhead*)))
;; After constructing the initial fragment, calculate
;; the required number of fragments.
(when (zerop i)
(setf num-parts
(1+ (ceiling (- data-size payload-size)
other-fragment-payload-size))
(fragmented-notification-num-data-parts fragment)
num-parts))
;; Stores slice of WIRE-DATA as payload for the fragment.
(setf (notification-data notification)
(subseq wire-data offset (+ offset payload-size)))
(incf offset payload-size)
(incf i)
(values fragment (1- i) num-parts))))
#'make-fragment)))
| 14,569 | Common Lisp | .lisp | 277 | 37.462094 | 93 | 0.545933 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f204d47ec92cd6f5887d1c5b4de3aeb883efe97b67fbdbeb00556e2a4262c44a | 25,365 | [
-1
] |
25,366 | package.lisp | open-rsx_rsb-cl/src/transport/spread/package.lisp | ;;;; package.lisp --- Package definition for transport.spread module.
;;;;
;;;; Copyright (C) 2011-2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.transport.spread
(:nicknames #:rsb.tp.spread)
(:shadowing-import-from #:rsb.protocol
#:event-id
#:event-meta-data)
(:shadow
#:connector)
(:use
#:cl
#:alexandria
#:iterate
#:let-plus
#:more-conditions
#:nibbles
#:rsb
#:rsb.event-processing
#:rsb.transport
#:rsb.protocol)
;; Conditions
(:export
#:assembly-problem
#:assembly-problem-assembly
#:fragment-problem
#:assembly-problem-fragment
#:invalid-fragment-id
#:duplicate-fragment
#:fragmentation-problem
#:insufficient-room
#:fragmentation-problem-required
#:fragmentation-problem-available)
;; Connection protocol
(:export
#:connection-name
#:connection-daemon-name
#:connection-groups
#:ref-group
#:unref-group
#:receive-message
#:send-message)
(:documentation
"This package contains a transport implementation based on the
Spread group communication system."))
(cl:in-package #:rsb.transport.spread)
(eval-when (:compile-toplevel :load-toplevel :execute)
(pushnew :rsb.transport.spread.num-fragments *transport-metrics*))
| 1,316 | Common Lisp | .lisp | 50 | 22.62 | 69 | 0.714744 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 8f2469b1ff2133ea96670f47dd0f608cd6863e29a464cd6bc4984bb73bb8a5ca | 25,366 | [
-1
] |
25,367 | protocol.lisp | open-rsx_rsb-cl/src/transport/spread/protocol.lisp | ;;;; protocol.lisp --- Protocol used by the spread transport implementation.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; Spread connection protocol
(defgeneric connection-name (connection)
(:documentation
"Return local name of CONNECTION."))
(defgeneric connection-daemon-name (connection)
(:documentation
"Return name of the daemon to which CONNECTION is connected."))
(defgeneric connection-groups (connection)
(:documentation
"Return list of names of Spread groups in which CONNECTION is a
member."))
(defgeneric ref-group (connection group &key waitable?)
(:documentation
"Increase the reference count of GROUP, causing CONNECTION to join
the Spread group named GROUP in case of a 0 -> 1 transition of the
reference count.
Return three values: 1) new number of references to GROUP 2) new
number of referenced groups in CONNECTION 3) optionally a
promise (see below).
If WAITABLE? is true and actual joining occurs (as described
above), return as the third value an `lparallel:promise' instance
that can be forced to wait for the completion of the join
operation.
Note that `receive-message' has to be called (in blocking or
non-blocking mode) before or while forcing the promise since
otherwise Spread events for CONNECTION are not processed."))
(defgeneric unref-group (connection group &key waitable?)
(:documentation
"Decrease the reference count of GROUP, causing CONNECTION to leave
the Spread group named GROUP in case of a 1 -> 0 transition of the
reference count.
Return two values: 1) number of remaining references to GROUP 2)
number of remaining referenced groups in CONNECTION. 3) optionally
a promise (see below).
If WAITABLE? is true and actual leaving occurs (as described
above), return as the third value an `lparallel:promise' instance
that can be forced to wait for the completion of the leave
operation.
Note that `receive-message' has to be called (in blocking or
non-blocking mode) before or while forcing the promise since
otherwise Spread events for CONNECTION are not processed."))
(defgeneric receive-message (connection block?)
(:documentation
"Receive and return a message from CONNECTION.
BLOCK? controls whether the call should block until a message has
been received."))
(defgeneric send-message (connection destination payload)
(:documentation
"Send the PAYLOAD to DESTINATION via CONNECTION in a Spread
message."))
;;; Assembly protocol
(defgeneric add-fragment! (assembly fragment)
(:documentation
"Integrate the notification FRAGMENT into the partial assembly
ASSEMBLY.
Warning conditions are signaled if FRAGMENT cannot be integrated
for some reason. The (possibly) modified ASSEMBLY is returned."))
;;; Partial assembly storage protocol
(defgeneric assembly-pool-count (pool)
(:documentation
"Return the number of `assembly' instances in POOL."))
(defgeneric ensure-assembly (pool id size)
(:documentation
"Find or create an assembly with SIZE total fragments for the event
identified by ID."))
(defgeneric merge-fragment (pool notification)
(:documentation
"Merge NOTIFICATION into the appropriate assembly within POOL.
If NOTIFICATION completes the assembly, return a notification
instance built from the complete assembly. Otherwise, return
nil."))
;;; Transport protocol
(defgeneric ensure-access (transport options connector)
(:documentation
"Ensure access for CONNECTOR to the bus described by OPTIONS using TRANSPORT.
Return an existing or newly created bus object the configuration
of which matches OPTIONS. In any case, CONNECTOR is already
attached to the returned bus.
CONNECTOR may share a Spread connection with other connectors. A
new Spread connection is only established if a connection
compatible with OPTIONS is not yet present in TRANSPORT."))
| 4,069 | Common Lisp | .lisp | 87 | 42.873563 | 80 | 0.766818 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 567a1703ce756f4f5686ac76c1c3583f0d22afd4c249eb2e869c9012d6dde24f | 25,367 | [
-1
] |
25,368 | in-pull-connector.lisp | open-rsx_rsb-cl/src/transport/spread/in-pull-connector.lisp | ;;;; in-pull-connector.lisp --- An in-direction, pull-based connector for spread.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
(defclass in-pull-connector (in-connector
error-handling-pull-receiver-mixin)
((queue :type lparallel.queue:queue
:reader queue
:initform (lparallel.queue:make-queue)
:documentation
"Stores notifications as they arrive via the message bus."))
(:metaclass connector-class)
(:direction :in-pull)
(:documentation
"Pull-style event receiving for the Spread transport."))
(register-connector :spread :in-pull 'in-pull-connector)
(defmethod handle ((connector in-pull-connector)
(data bus-notification))
;; Put DATA into the queue of CONNECTOR for later retrieval.
(lparallel.queue:push-queue data (queue connector)))
(defmethod receive-notification ((connector in-pull-connector)
(block? (eql nil)))
;; Extract and return one event from the queue maintained by
;; CONNECTOR, if there are any. If there are no queued events,
;; return nil.
(lparallel.queue:try-pop-queue (queue connector)))
(defmethod receive-notification ((connector in-pull-connector)
(block? t))
;; Extract and return one event from the queue maintained by
;; CONNECTOR, if there are any. If there are no queued events,
;; block.
(lparallel.queue:pop-queue (queue connector)))
(defmethod emit ((source in-pull-connector) (block? t))
;; Maybe block until a notification is received. Try to convert into
;; an event and return the event in case of success. In blocking
;; mode, wait for the next notification.
(iter (let* ((notification (receive-notification source block?))
(event (when notification
(notification->event
source notification :undetermined))))
;; Due to fragmentation of large events into multiple
;; notifications, non-blocking receive mode and error
;; handling policies, we may not obtain an `event' instance
;; from the notification.
(when event
(dispatch source event))
(when (or event (not block?))
(return event)))))
| 2,402 | Common Lisp | .lisp | 50 | 40.08 | 81 | 0.655864 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | be1e9077371c7e6a446a2d6323f28ea5affce1ffb8691e3fac8cc670517bf3de | 25,368 | [
-1
] |
25,369 | in-connector.lisp | open-rsx_rsb-cl/src/transport/spread/in-connector.lisp | ;;;; in-connector.lisp --- Superclass for in-direction connector classes.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `in-connector' class
(defclass in-connector (connector
timestamping-receiver-mixin
restart-notification-receiver-mixin
expose-transport-metrics-mixin)
()
(:metaclass connector-class)
(:documentation
"This class is intended to be used as a superclass of in-direction
connector classes for Spread."))
(defmethod notify ((recipient in-connector)
(subject scope)
(action (eql :attached)))
(call-next-method)
(notify (bus recipient) recipient (subscribed subject)))
(defmethod notify ((recipient in-connector)
(subject scope)
(action (eql :detached)))
(notify (bus recipient) recipient (unsubscribed subject))
(call-next-method))
(defmethod notification->event ((connector in-connector)
(notification bus-notification)
(wire-schema t))
(let+ (((&structure-r/o connector- converter) connector)
((&structure-r/o bus-notification- notification wire-data) notification)
(expose-wire-schema? (connector-expose? connector :rsb.transport.wire-schema))
(expose-payload-size? (connector-expose? connector :rsb.transport.payload-size)))
;; Convert the `bus-notification' instance NOTIFICATION, and its
;; payload, into an `event' instance.
;; * If the payload conversion succeeds, return the `event'
;; instance.
;; * If the payload conversion fails, signal an appropriate error.
(with-condition-translation
(((error decoding-error)
:encoded notification
:format-control "~@<After assembling and unpacking, the ~
notification~_~A~_could not be converted ~
into an event.~:@>"
:format-arguments `(,(with-output-to-string (stream)
(describe notification stream)))))
(one-notification->event converter notification wire-data
:expose-wire-schema? expose-wire-schema?
:expose-payload-size? expose-payload-size?))))
| 2,445 | Common Lisp | .lisp | 49 | 38.897959 | 90 | 0.61239 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 6f2a4a1b5c3b842dbd9b1e57d3b74fc36f472f8715302fdf5c162956a0fcab8e | 25,369 | [
-1
] |
25,370 | bus-mixins.lisp | open-rsx_rsb-cl/src/transport/spread/bus-mixins.lisp | ;;;; bus-mixins.lisp --- Mixins for bus classes.
;;;;
;;;; Copyright (C) 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `connector-container-mixin'
(defclass connector-container-mixin ()
((connectors :type list
:accessor %connectors
:initform '()
:documentation
"Stores a list of local connectors connected to
the bus.")
(connectors-lock :reader %connectors-lock
:initform (bt:make-recursive-lock "Bus Connectors Lock")
:documentation
"Stores a lock that can be used to protect the
connector list of the bus from concurrent
modification."))
(:documentation
"Manages a set of connectors attached to a bus."))
(defmethod (setf %connectors) :around ((new-value list)
(bus connector-container-mixin))
(let ((old-value (%connectors bus)))
(prog1
(call-next-method)
(cond
((and old-value (not new-value))
(log:info "~@<~A has no more connectors~@:>" bus)
(notify bus :connectors :detached))
((and (not old-value) new-value)
(log:info "~@<~A got its first connector~@:>" bus)
(notify bus :connectors :attached))))))
(defmethod print-items:print-items append ((object connector-container-mixin))
`((:connector-count ,(length (%connectors object)) "(C ~D)")))
(defmethod notify ((recipient rsb.transport:connector)
(subject connector-container-mixin)
(action (eql :attached)))
(log:debug "~@<Connector ~A is attaching to bus provider ~A~@:>"
recipient subject)
(bt:with-recursive-lock-held ((%connectors-lock subject))
(push recipient (%connectors subject))))
(defmethod notify ((recipient rsb.transport:connector)
(subject connector-container-mixin)
(action (eql :detached)))
(log:debug "~@<Connector ~A is detaching from bus provider ~A~@:>"
recipient subject)
(bt:with-recursive-lock-held ((%connectors-lock subject))
(removef (%connectors subject) recipient)))
| 2,321 | Common Lisp | .lisp | 50 | 36.4 | 78 | 0.594523 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b4464b7f6a015e2f460aa6dcb0f2efa70e8e79569acd18587506aca171909a7e | 25,370 | [
-1
] |
25,371 | sender-receiver.lisp | open-rsx_rsb-cl/src/transport/spread/sender-receiver.lisp | ;;;; sender-receiver.lisp --- Protocol-aware connection for the Spread transport.
;;;;
;;;; Copyright (C) 2016-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `connection-user-mixin'
(defclass connection-user-mixin ()
((connection :initarg :connection
:reader connection))
(:default-initargs
:connection (missing-required-initarg 'connection-user-mixin :connection)))
;;; `message-receiver'
(defclass message-receiver (connection-user-mixin
threaded-message-receiver-mixin
restart-notification-receiver-mixin
error-handling-push-receiver-mixin
rsb.ep:broadcast-processor)
((assembly-pool :initarg :assembly-pool
:type assembly-pool
:reader assembly-pool
:writer (setf %assembly-pool)
:documentation
"Stores the `assembly-pool' instances used for
assembling notifications.")
(state :type (member :active :shutdown :abort)
:accessor %state
:initform :active
:documentation
"Stores the current state of the receiver.
Only used during shutdown."))
(:documentation
"Asynchronously receives and assembles notifications."))
(defmethod initialize-instance :after ((instance message-receiver)
&key
assembly-pool
age-limit)
(unless assembly-pool
(setf (%assembly-pool instance)
(if age-limit
(make-instance 'pruning-assembly-pool
:age-limit age-limit)
(make-instance 'assembly-pool)))))
(defmethod notify ((recipient message-receiver)
(subject (eql t))
(action (eql :attached)))
(start-receiver recipient))
(defmethod notify ((recipient message-receiver)
(subject (eql t))
(action (eql :detaching)))
(loop :while (eq (%state recipient) :active)
:do (sb-ext:cas (slot-value recipient 'state) :active :shutdown)))
(defmethod notify ((recipient message-receiver)
(subject (eql t))
(action (eql :detached)))
(stop-receiver recipient)
(detach (assembly-pool recipient)))
(defmethod notify ((recipient message-receiver)
(subject scope)
(action (eql :attached)))
(let+ (((&values ref-count group-count promise)
(ref-group (connection recipient) (scope->group subject)
:waitable? t)))
;; Wait for the Spread group joining operation to complete.
(values (lparallel:force promise)
(and (= ref-count 1) (= group-count 1)))))
(defmethod notify ((recipient message-receiver)
(subject scope)
(action (eql :detached)))
(let+ (((&values &ign group-count promise)
(unref-group (connection recipient) (scope->group subject)
:waitable? t)))
;; Wait for the Spread group leaving operation to complete.
(when (eq (%state recipient) :abort)
(log:warn "~@<Receiver thread aborted, not waiting for ~
confirmation for group leaving operation for ~
~A.~@:>"
subject)
(return-from notify))
(values (lparallel:force promise) (zerop group-count))))
(defmethod receive-messages :around ((connector message-receiver))
(unwind-protect
(call-next-method)
(loop :while (eq (%state connector) :active)
:do (sb-ext:cas (slot-value connector 'state) :active :abort))))
(defmethod receive-notification ((connector message-receiver) (block? t))
;; Delegate receiving a notification to the connection of CONNECTOR.
(receive-message (connection connector) block?))
(defmethod notification->event ((connector message-receiver)
(notification wire-notification)
(wire-schema t))
(let+ (((&accessors-r/o assembly-pool) connector)
((&structure-r/o wire-notification- buffer end) notification))
;; Try to unpack NOTIFICATION into a `fragmented-notification'
;; instance. Signal `decoding-error' if that fails.
;;
;; After unpacking, there are two possible cases:
;; 1. NOTIFICATION (maybe in conjunction with previously received
;; notifications) forms a complete event
;; 2. NOTIFICATION does not form a complete event. In this case,
;; return `nil'.
(with-condition-translation
(((error decoding-error)
:encoded buffer
:format-control "~@<The data could not be unpacked as a ~
protocol buffer of kind ~S.~:@>"
:format-arguments '(fragmented-notification)))
(assemble-notification
assembly-pool (pb:unpack buffer
(make-instance 'fragmented-notification)
0 end)))))
;;; Error handling
(macrolet
((define-apply-error-policy-method (condition)
`(defmethod apply-error-policy ((processor message-receiver)
(condition ,condition))
(if (eq (%state processor) :shutdown)
(progn
(log:debug "~@<~A got ~A in state ~A; exiting receiver~@:>"
processor condition (%state processor))
(exit-receiver))
(call-next-method)))))
(define-apply-error-policy-method connection-unexpectedly-closed)
(define-apply-error-policy-method network.spread:spread-error))
;;; `message-sender'
(defclass message-sender (connection-user-mixin)
()
(:documentation
"Sends serializes, fragments and sends notifications."))
(defmethod handle ((sink message-sender) (data outgoing-notification))
(let ((notifications (event->notification sink data)))
(declare (type function notifications))
(loop :for notification = (funcall notifications)
:while notification
:do (send-notification sink notification))))
(defmethod event->notification ((connector message-sender)
(event outgoing-notification))
(let+ ((max-fragment-size 100000) ; TODO get the proper value
((&structure-r/o outgoing-notification- destination notification wire-data)
event)
(splitter (split-notification notification wire-data max-fragment-size)))
(lambda ()
(let+ (((&values fragment part num-parts) (funcall splitter)))
(when fragment
(let* ((buffer (pb:pack* fragment))
(notification (make-destined-wire-notification
destination buffer (length buffer))))
(declare (type simple-octet-vector buffer))
(values notification part num-parts)))))))
(defmethod send-notification ((connector message-sender)
(notification destined-wire-notification))
;; Send NOTIFICATION using `send-message'. The primary purpose of
;; this method is sending the notifications with restarts installed.
(let+ (((&accessors-r/o connection) connector)
((&structure-r/o destined-wire-notification- destination) notification))
(send-message connection destination notification)))
| 7,596 | Common Lisp | .lisp | 156 | 37.391026 | 84 | 0.604827 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 014d41d510e5ea36c4cfcfe7382ff583615d5dc1edaea9a3dd90e965cc0e6edc | 25,371 | [
-1
] |
25,372 | in-push-connector.lisp | open-rsx_rsb-cl/src/transport/spread/in-push-connector.lisp | ;;;; in-push-connector.lisp --- An in-direction, push-based connector for spread.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `in-push-connector' class
(defclass in-push-connector (in-connector
broadcast-processor
error-policy-mixin)
()
(:metaclass connector-class)
(:direction :in-push)
(:documentation
"Push-style event receiving for the Spread transport."))
(register-connector :spread :in-push 'in-push-connector)
(defmethod handle ((sink in-push-connector) (data bus-notification))
;; Turn the assembled notification in DATA into an `event' instance
;; and dispatch to handlers.
(dispatch sink (notification->event sink data :whatever)))
| 836 | Common Lisp | .lisp | 20 | 36.8 | 81 | 0.692972 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 1aa141fdab94134fca5ca6a0915c3c6a29fad5c096545c832b7534efb318d108 | 25,372 | [
-1
] |
25,373 | conditions.lisp | open-rsx_rsb-cl/src/transport/spread/conditions.lisp | ;;;; conditions.lisp --- Conditions used in the spread transport implementation.
;;;;
;;;; Copyright (C) 2011, 2012, 2013, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; Assembly-related conditions
(define-condition assembly-problem (rsb-problem-condition)
((assembly :initarg :assembly
:reader assembly-problem-assembly
:documentation
"The assembly instance in which the problem occurred."))
(:report
(lambda (condition stream)
(format stream "~@<Something happened in assembly ~A.~@:>"
(assembly-problem-assembly condition))))
(:documentation
"Instance of subclasses of this condition are signaled if a problem
occurs during the assembly of fragments into complete events."))
(define-condition fragment-problem (assembly-problem)
((fragment :initarg :fragment
:reader assembly-problem-fragment
:documentation
"The notification representing the fragment that caused
the problem."))
(:report
(lambda (condition stream)
(let+ (((&structure-r/o assembly-problem- assembly fragment) condition))
(format stream "~@<The fragment ~D of event ~/rsb::print-id/ ~
caused a problem in assembly ~A.~@:>"
(rsb.protocol::fragmented-notification-data-part fragment)
(assembly-id assembly)
assembly))))
(:documentation
"Instance of subclasses of this condition are signaled if a
fragment causes a problem in an assembly."))
(define-condition invalid-fragment-id (fragment-problem
rsb-warning)
()
(:report
(lambda (condition stream)
(let+ (((&structure-r/o assembly-problem- assembly fragment) condition))
(format stream "~@<Received illegal fragment ~D of event ~
~/rsb::print-id/ with ~D parts in assembly ~
~A.~@:>"
(rsb.protocol::fragmented-notification-data-part fragment)
(assembly-id assembly)
(length (assembly-fragments assembly))
assembly))))
(:documentation
"This warning is signaled when an attempt is made to add a fragment
with an invalid part id to an assembly."))
(define-condition duplicate-fragment (fragment-problem
rsb-warning)
()
(:report
(lambda (condition stream)
(let+ (((&structure-r/o assembly-problem- assembly fragment) condition))
(format stream "~@<Received fragment ~D of event ~
~/rsb::print-id/ more than once in assembly ~
~A.~@:>"
(rsb.protocol::fragmented-notification-data-part fragment)
(assembly-id assembly)
assembly))))
(:documentation
"This warning is signaled when an attempt is made to add a fragment
to an assembly that has already been added."))
;;; Fragmentation-related conditions
(define-condition fragmentation-problem (rsb-problem-condition)
()
(:report
(lambda (condition stream)
(declare (ignore condition))
(format stream "~@<A fragmentation operation failed~@:>")))
(:documentation
"Conditions of this class and subclasses are signaled when problems
related to fragmenting events into multiple notifications are
encountered."))
(define-condition insufficient-room (fragmentation-problem
rsb-error)
((required :initarg :required
:type positive-integer
:reader fragmentation-problem-required
:documentation
"")
(available :initarg :available
:type non-negative-integer
:reader fragmentation-problem-available
:documentation
""))
(:report
(lambda (condition stream)
(let+ (((&structure-r/o fragmentation-problem- available required)
condition))
(format stream "~@<Insufficient room (~:D byte~:P) for fragment ~
requiring ~:D byte~:P.~@:>"
available required))))
(:documentation
"This error is signaled when a notification fragment of an event
cannot be created because it would exceed the maximum allowed
fragment size."))
| 4,382 | Common Lisp | .lisp | 101 | 34.257426 | 80 | 0.634129 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f7b116cb5cf5e3ad829e8e87dc3fbe6c0015dd1a82f9a670683d478525f50dd6 | 25,373 | [
-1
] |
25,374 | connection.lisp | open-rsx_rsb-cl/src/transport/spread/connection.lisp | ;;;; connection.lisp --- Spread connections with membership management.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `connection' class
(defclass connection (print-items:print-items-mixin)
((connection :initarg :connection
:type network.spread:connection
:accessor connection-%connection
:documentation
"The underlying Spread connection used by the
connector instance.")
(groups :type hash-table
:reader connection-%groups
:initform (make-hash-table :test #'equal)
:documentation
"A mapping of group names to reference counts.
The connection instance is a member of every group
that has a positive reference count.")
(receive-buffer :type (or null simple-octet-vector)
:accessor connection-%receive-buffer
:initform nil
:documentation
"Stores a buffer for receiving messages.
The buffer is allocated lazily to avoid wasting
memory for send-only connections."))
(:documentation
"A connection to the Spread communication system.
Maintains a list of the Spread multicast groups in which the is a
member."))
(defmethod initialize-instance :before ((instance connection)
&key
connection
name)
(unless (or name connection)
(missing-required-initarg 'connection :either-name-or-connection)))
(defmethod shared-initialize :before ((instance connection)
(slot-names t)
&key
connection
name)
(when (and name connection)
(incompatible-initargs 'connection
:name name
:connection connection)))
(defmethod shared-initialize :after ((instance connection)
(slot-names t)
&key
name)
(when name
(setf (connection-%connection instance)
(network.spread:connect name))))
(defmethod connection-name ((connection connection))
(when (slot-boundp connection 'connection)
(network.spread:connection-name (connection-%connection connection))))
(defmethod connection-daemon-name ((connection connection))
(when (slot-boundp connection 'connection)
(network.spread:connection-daemon-name (connection-%connection connection))))
(defmethod connection-groups ((connection connection))
(hash-table-keys (connection-%groups connection)))
(defmethod detach ((connection connection))
(network.spread:disconnect (connection-%connection connection)))
(let+ (((&flet make-hook-promise (context connection hook group predicate)
(let+ ((hook (hooks:object-hook connection hook))
(promise (lparallel:promise))
((&labels notify-and-remove (message-group members)
(log:debug "~@<~A got ~A notification for ~
group ~S with members ~:S.~@:>"
connection context message-group members)
(when (and (string= message-group group :end2 31)
(funcall predicate members))
(hooks:remove-from-hook hook #'notify-and-remove)
(lparallel:fulfill promise)))))
(hooks:add-to-hook hook #'notify-and-remove)
promise))))
(defmethod ref-group ((connection connection) (group string)
&key (waitable? nil))
(let+ (((&structure-r/o connection- %connection (groups %groups))
connection)
((&flet join ()
(log:info "~@<~A is joining group ~S~@:>" connection group)
(network.spread:join %connection group)
t))
((&flet join/waitable ()
(let ((name (network.spread:connection-name %connection)))
(prog1
(make-hook-promise
"join" %connection 'network.spread:join-hook group
(lambda (members)
(member name members :test #'string=)))
(join)))))
(new-value (incf (gethash group groups 0))))
(values new-value
(hash-table-count groups)
(cond
((/= new-value 1) nil)
(waitable? (join/waitable))
(t (join))))))
(defmethod unref-group :before ((connection connection) (group string)
&key waitable?)
(declare (ignore waitable?))
(unless (gethash group (connection-%groups connection))
(error "~@<~A was asked to unreference unknown group ~S~@:>"
connection group)))
(defmethod unref-group ((connection connection) (group string)
&key (waitable? nil))
(let+ (((&structure-r/o connection- %connection (groups %groups))
connection)
((&flet leave ()
(log:info "~@<~A is leaving group ~S~@:>" connection group)
(remhash group groups)
(network.spread:leave %connection group)
t))
((&flet leave/waitable ()
(let ((name (network.spread:connection-name %connection)))
(prog1
(make-hook-promise
"leave" %connection 'network.spread:leave-hook group
(lambda (members)
(not (member name members :test #'string=))))
(leave)))))
(new-ref-count (decf (gethash group groups 0)))
(maybe-promise (cond
((plusp new-ref-count) nil)
(waitable? (leave/waitable))
(t (leave))))
(new-group-count (hash-table-count groups)))
(values new-ref-count new-group-count maybe-promise))))
(macrolet
((with-spread-condition-translation (&body body)
`(handler-bind
((network.spread:spread-client-error
(lambda (condition)
(when (member (network.spread:spread-error-code condition)
'(:net-error-on-session :connection-closed))
(error 'connection-unexpectedly-closed
:connection connection
:cause condition)))))
,@body)))
(defmethod receive-message ((connection connection) (block? t))
(let+ (((&structure connection- %connection %receive-buffer) connection)
(buffer (or %receive-buffer
(setf %receive-buffer
(make-octet-vector
network.spread:+maximum-message-data-length+)))))
;; Use :when-membership for efficiency: we need join and leave
;; hooks to run with sender and group information, but regular
;; messages should be fast and do not need sender and group
;; information.
(with-spread-condition-translation
(when-let ((length (network.spread:receive-into
%connection buffer
:block? block?
:return-sender? :when-membership
:return-groups? :when-membership)))
(make-wire-notification buffer length)))))
(defmethod send-message ((connection connection)
(destination list)
(payload wire-notification))
(let+ (((&structure-r/o wire-notification- buffer end) payload))
(assert (= (length buffer) end))
(with-spread-condition-translation
(network.spread:send-bytes
(connection-%connection connection) destination buffer)))))
(defmethod print-items:print-items append ((object connection))
(let+ (((&structure-r/o connection- name daemon-name %groups) object))
`((:name ,name "~A")
(:daemon-name ,daemon-name "@~A" ((:after :name)))
(:group-count ,(hash-table-count %groups) " (~D)" ((:after :daemon-name))))))
| 8,666 | Common Lisp | .lisp | 171 | 35.625731 | 83 | 0.539297 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ddb68bc8fb6ab77c8e69eccdb70b352e2a51cc830c792a0491210aa5b47be724 | 25,374 | [
-1
] |
25,375 | notifications.lisp | open-rsx_rsb-cl/src/transport/spread/notifications.lisp | ;;;; notifications.lisp --- Notifications used in the transport.spread module.
;;;;
;;;; Copyright (C) 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; Notification-related types
(deftype message-length-limit ()
`(integer 0 (,network.spread:+maximum-message-data-length+)))
;;; Connection notifications
(defstruct (destined-wire-notification
(:include wire-notification)
(:constructor make-destined-wire-notification
(destination buffer end)))
;; Spread group or groups to which the message is sent.
(destination nil :type list #|of string|# :read-only t))
;;; Bus notifications
(defstruct (bus-notification
(:constructor nil) (:predicate nil) (:copier nil))
;; The incoming or outgoing notification.
(notification nil :type rsb.protocol:notification :read-only t)
;; Complete (i.e. potentially assembled from multiple fragments)
;; wire-data of the payload.
(wire-data nil :type octet-vector :read-only t))
(defstruct (incoming-notification
(:include bus-notification)
(:constructor make-incoming-notification (notification wire-data))
(:predicate nil) (:copier nil)))
(defstruct (outgoing-notification
(:include bus-notification)
(:constructor make-outgoing-notification
(scope destination notification wire-data))
(:predicate nil) (:copier nil))
;; The scope of the event that gave rise to the notification. Used
;; when dispatching to in-process in-connectors.
(scope nil :type scope :read-only t)
;; Spread groups to which the notification should be sent.
(destination nil :type list #|of string|# :read-only t))
| 1,813 | Common Lisp | .lisp | 38 | 42.105263 | 78 | 0.686297 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b826ab82422c29c60af8f81ceefeec8df8d65620b35bba2df6e01505737e3f7f | 25,375 | [
-1
] |
25,376 | out-connector.lisp | open-rsx_rsb-cl/src/transport/spread/out-connector.lisp | ;;;; out-connector.lisp --- Out-direction connector for Spread transport.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
(defclass out-connector (restart-notification-sender-mixin
error-handling-sender-mixin
timestamping-sender-mixin
connector)
((max-fragment-size :initarg :max-fragment-size
:type positive-fixnum
:reader connector-max-fragment-size
:initform 100000
:documentation
#.(format nil "The maximum payload size that ~
may be send in a single notification. The ~
value of this options has to be chosen such ~
that the combined sizes of payload and ~
envelope data of notifications remain below ~
the maximum message size allowed by ~
Spread."))
(scope->groups-cache :reader connector-%scope->groups-cache
:initform (make-scope->groups-cache)))
(:metaclass connector-class)
(:direction :out)
(:options
(:max-fragment-size &slot))
(:documentation
"A connector for sending data over Spread."))
(register-connector :spread :out 'out-connector)
(defmethod notify ((recipient out-connector)
(subject scope)
(action t))
(notify recipient t action))
(defmethod handle ((sink out-connector) (data event))
(handle (bus sink) (event->notification sink data)))
(defmethod event->notification ((connector out-connector) (event event))
(let+ (((&structure-r/o connector- converter (cache %scope->groups-cache))
connector)
((&structure-r/o
event- origin sequence-number scope method timestamps causes data)
event)
(meta-data (rsb:event-meta-data event))
(group-names (scope->groups scope cache))
((&values wire-data wire-schema)
(rsb.converter:domain->wire converter data))
(notification (make-notification
sequence-number origin scope method
wire-schema meta-data timestamps causes)))
(make-outgoing-notification scope group-names notification wire-data)))
| 2,464 | Common Lisp | .lisp | 51 | 35.784314 | 77 | 0.591192 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | afaf0ebf908218cf826684defec70dfbb1f74b6bb90065b78b405d9d64894c9d | 25,376 | [
-1
] |
25,377 | connector.lisp | open-rsx_rsb-cl/src/transport/spread/connector.lisp | ;;;; connector.lisp --- Superclass for spread connectors.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
(defclass connector (rsb.transport:connector
conversion-mixin)
((configuration :accessor connector-%configuration
:documentation
"Stores the parameters that should be used when
establishing the actual Spread connection.")
(bus :initarg :bus
:type (or null bus)
:reader bus
:accessor %bus
:initform nil
:documentation
"Stores the connection used by this connector."))
(:metaclass connector-class)
(:transport :spread)
(:options
(:name string
:description
#.(format nil "The name of the spread daemon. Has to be either of ~
the form PORT@HOSTNAME or just PORT. Mutually exclusive with ~
HOST and PORT."))
(:host string
:description
#.(format nil "The hostname of the spread daemon. Mutually ~
exclusive with NAME."))
(:port (integer 0 65534)
:default network.spread.daemon:*default-port*
:description
#.(format nil "The port number of the spread daemon. Mutually ~
exclusive with NAME."))
(:tcpnodelay boolean
:default t
:description
#.(format nil "Should the TCP_NODELAY option be set on the socket ~
used for Spread communication? Note: currently ignored by Lisp ~
implementation."))
(:age-limit positive-real
:default 10
:description
#.(format nil "The amount of time after which incomplete ~
assemblies are pruned. Supplying this option only makes sense ~
in conjunction with an unreliable communication mode since ~
incomplete assemblies are never pruned in reliable ~
communication modes.")))
(:documentation
"Superclass for Spread in and out connectors."))
(defmethod initialize-instance :before ((instance connector)
&key
bus
name
port)
;; Make sure that at least one of BUS, NAME and PORT is
;; supplied.
(unless (or bus name port)
(missing-required-initarg 'connector :either-bus-or-name-or-port)))
(defmethod shared-initialize :after ((instance connector) (slot-names t)
&key
bus
(name nil name-supplied?)
(host nil host-supplied?)
(port nil port-supplied?)
tcpnodelay
age-limit)
(when (or name-supplied? host-supplied? port-supplied?)
(let+ (((&structure-r/o connector- url) instance)
((&values name host port)
(normalize-daemon-endpoint name host port)))
;; Normalize URL.
(when host
(setf (puri:uri-host url) host))
(setf (puri:uri-port url) port)
(setf (connector-%configuration instance)
(list :bus bus :name name :host host :port port
:tcpnodelay tcpnodelay :age-limit age-limit)))))
;;; (Dis)connecting
(defmethod notify ((recipient connector)
(subject (eql t))
(action (eql :attached)))
(let+ (((&structure-r/o connector- transport (options %configuration))
recipient)
((&plist-r/o (bus :bus)) options))
;; Unless a connection has been supplied, connect to the spread
;; daemon designated by OPTIONS.
(setf (%bus recipient) (or bus
(ensure-access transport options recipient)))))
(defmethod notify ((recipient connector)
(subject (eql t))
(action (eql :detached)))
(let+ (((&accessors (bus %bus)) recipient))
(notify recipient bus :detached)
(setf bus nil)))
(defmethod notify ((recipient connector) (subject scope) (action t))
(notify recipient t action))
| 4,230 | Common Lisp | .lisp | 99 | 31.444444 | 78 | 0.577632 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | ba039ee25c11f92f2a822a8f1befeca30dc713cc2bb0e3f5a5f5d38e642a9fd2 | 25,377 | [
-1
] |
25,378 | bus.lisp | open-rsx_rsb-cl/src/transport/spread/bus.lisp | ;;;; bus.lisp --- Bus implementation for the Spread transport.
;;;;
;;;; Copyright (C) 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.transport.spread)
;;; `bus'
(defclass bus (connector-container-mixin
sink-dispatcher-mixin
print-items:print-items-mixin)
((connection :initarg :connection
:reader connection
:documentation
"Stores a connection to a Spread daemon.")
(receiver :accessor %receiver
:documentation
"Stores a message receiver object.")
(sender :accessor %sender
:documentation
"Stores a message sender object."))
(:default-initargs
:connection (missing-required-initarg 'bus :connection))
(:documentation
"Manages a connection to a remote Spread daemon and local connectors."))
(defmethod initialize-instance :after ((instance bus)
&key
connection
age-limit)
(let+ (((&flet error-policy (condition)
(bt:with-lock-held ((%connectors-lock instance))
(map nil (rcurry #'apply-error-policy condition)
(%connectors instance))))))
(setf (%receiver instance) (make-instance 'message-receiver
:connection connection
:handlers (list instance)
:error-policy #'error-policy
:age-limit age-limit)
(%sender instance) (make-instance 'message-sender
:connection connection))))
;;; State management
(defmethod notify ((recipient bus)
(subject (eql t))
(action (eql :attached)))
(notify (%receiver recipient) subject action))
(defmethod notify ((recipient bus)
(subject (eql t))
(action (eql :detached)))
(notify (%receiver recipient) subject :detaching)
(detach (connection recipient))
(notify (%receiver recipient) subject action))
(defmethod notify ((recipient bus)
(subject t)
(action subscribed))
(call-next-method)
(notify (%receiver recipient) (subscription-scope action) :attached))
(defmethod notify ((recipient bus)
(subject t)
(action unsubscribed))
(notify (%receiver recipient) (subscription-scope action) :detached)
(call-next-method))
(defmethod notify ((recipient bus)
(subject (eql :connectors))
(action t))
(notify recipient t action))
;;; Outgoing notifications
(defmethod handle ((sink bus) (data outgoing-notification))
(let* ((scope (outgoing-notification-scope data))
(scope-and-event (scope-and-event scope data)))
(declare (dynamic-extent scope-and-event))
(dispatch sink scope-and-event))
(handle (%sender sink) data))
;;; Incoming notifications
(defmethod handle ((processor bus) (event incoming-notification))
(let* ((scope (make-scope
(bytes->string
(notification-scope
(incoming-notification-notification event)))))
(scope-and-event (rsb.ep:scope-and-event scope event)))
(declare (dynamic-extent scope-and-event))
(dispatch processor scope-and-event)))
| 3,618 | Common Lisp | .lisp | 80 | 32.875 | 75 | 0.565143 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 7d6851f11ec966a747cd27244ad8012a88a4d4886504e6e98835d5f444afe434 | 25,378 | [
-1
] |
25,379 | package.lisp | open-rsx_rsb-cl/src/model/package.lisp | ;;;; package.lisp --- Package definition for the model module.
;;;;
;;;; Copyright (C) 2015, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.model
(:use
#:cl
#:alexandria
#:let-plus
#:more-conditions)
(:import-from #:rsb
#:scope
#:scope-string)
;; "Info" model protocol and classes
(:export
#:info-most-recent-activity
#:info-most-recent-activity-difference
#:info-clock-offset
#:info-latency
#:participant-info #:remote-participant-info
#:participant-info-kind
#:participant-info-id
#:participant-info-parent-id
#:participant-info-scope
#:participant-info-type
#:participant-info-transports
#:process-info #:remote-process-info
#:process-info-process-id #:process-info-state
#:process-info-program-name #:process-info-transports
#:process-info-commandline-arguments
#:process-info-start-time
#:process-info-executing-user
#:process-info-rsb-version
#:process-info-display-name
#:host-info #:remote-host-info
#:host-info-id #:host-info-state
#:host-info-hostname
#:host-info-machine-type
#:host-info-machine-version
#:host-info-software-type
#:host-info-software-version)
;; Info update protocol
(:export
#:update-using-info)
;; "Node" model protocol and classes
(:export
#:node-info
#:node-parent
#:node-children
#:info-mixin
#:parented-mixin
#:child-container-mixin
#:node
#:participant-node
#:process-node
#:host-node)
(:documentation
"This package contains protocols and classes for modeling RSB
systems. The following model classes are provided:
* \"info\" classes storing properties of different kinds of
entities in a system:
* `participant-info' and `remote-participant-info' which
describe participants in general and participants in remote
processes respectively.
* `process-info' and `remote-process-info' which describe
processes in general and processes on remote hosts
respectively.
* `host-info' and `remote-host-info' which describe hosts in
general and in remote hosts respectively.
* \"node\" classes representing the relations between entities in
a system:
* `node' is the superclass of all \"relation\" classes
* Instances of `participant-node', `process-node' and
`host-node' each contain an associated `participant-info',
`process-info' or `host-info' respectively and represent
relations to other nodes."))
| 2,683 | Common Lisp | .lisp | 77 | 30.103896 | 69 | 0.674401 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 53ce77b6b4a59c87ceafce5e5289577ca91209b3d09a6aebbc4ecf956519b1d6 | 25,379 | [
-1
] |
25,380 | protocol.lisp | open-rsx_rsb-cl/src/model/protocol.lisp | ;;;; protocol.lisp --- Protocol provided by the model module.
;;;;
;;;; Copyright (C) 2014, 2015, 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.model)
;;; Most recent activity protocol
(defgeneric info-most-recent-activity (info)
(:documentation
"Return the time of the most recent activity on INFO as a
`local-time:timestamp'."))
;;; Timing protocol
(defgeneric info-clock-offset (info)
(:documentation
"Return the estimated offset in seconds of the clock used by the
remote object INFO relative to the local clock or nil if
unknown."))
(defgeneric info-latency (info)
(:documentation
"Return the estimated latency in seconds for communicating with the
remote object INFO."))
;;; Participant information protocol
(defgeneric participant-info-kind (info)
(:documentation
"Return the kind of the participant represented by INFO."))
(defgeneric participant-info-id (info)
(:documentation
"Return the unique id of the participant represented by INFO."))
(defgeneric participant-info-parent-id (info)
(:documentation
"Return nil or the id of the participant that is the parent of the
participant represented by INFO."))
(defgeneric participant-info-scope (info)
(:documentation
"Return the scope of the participant represented by INFO."))
(defgeneric participant-info-type (info)
(:documentation
"Return the type of the participant represented by INFO.
Note: subject to change."))
(defgeneric participant-info-transports (info)
(:documentation
"Return a list of `puri:uri' instances describing the transports
through which the participant represented by INFO is connected to
the bus."))
;;; Process information protocol
(defgeneric process-info-process-id (info)
(:documentation
"Return the numeric operating system id of the process represented
by INFO."))
(defgeneric process-info-program-name (info)
(:documentation
"Return the name program of the program executing in the process
represented by INFO.
The returned value is a string which can designate an absolute
path but also other things such as an interpreter and the script
it executes."))
(defgeneric process-info-commandline-arguments (info)
(:documentation
"Return a list of commandline arguments with which the process
represented by INFO has been started.
Unlike POSIX behavior, the first element of returned list is not
the name of the program name."))
(defgeneric process-info-start-time (info)
(:documentation
"Return a `local-time:timestamp' instance corresponding to the
start time of the process represented by INFO."))
(defgeneric process-info-executing-user (info)
(:documentation
"Return the login- or account-name of the user executing the
process represented by INFO."))
(defgeneric process-info-rsb-version (info)
(:documentation
"Return the RSB version used in the process represented by INFO."))
(defgeneric process-info-display-name (info)
(:documentation
"Return nil or the supplied display name of the process represented
by INFO."))
;; Remote process information protocol
(defgeneric process-info-state (info)
(:documentation
"Return a `process-state' value indicating the current (assumed)
state of the process represented by INFO.
See `process-state' type."))
(defgeneric process-info-transports (info)
(:documentation
"Return a list of `puri:uri' instances describing the transports
through which the process represented by INFO has been
contacted."))
;;; Host information protocol
(defgeneric host-info-id (info)
(:documentation
"Return nil or a string uniquely identifying the host represented
by INFO.
If nil, `host-info-hostname' should be used as a fallback unique
id."))
(defgeneric host-info-hostname (info)
(:documentation
"Return the name of the host represented by INFO."))
(defgeneric host-info-machine-type (info)
(:documentation
"Return the type of the machine, usually CPU architecture, of the
host represented by INFO."))
(defgeneric host-info-machine-version (info)
(:documentation
"Return the version of the machine within its type, usually the CPU
identification string, of the host represented by INFO."))
(defgeneric host-info-software-type (info)
(:documentation
"Return the type of the operating system, usually the kernel name,
running on the host represented by INFO."))
(defgeneric host-info-software-version (info)
(:documentation
"Return the version of the operating system within its type,
usually the kernel version string, of the host represented by
INFO."))
;; Remote host information protocol
(defgeneric host-info-state (info)
(:documentation
"Return a `host-state' value indicating the current (assumed) state
of the host represented by INFO.
See `host-state' type."))
;;; Info update protocol
(defgeneric update-using-info (info new-info)
(:documentation
"Destructively update INFO using information from NEW-INFO.
Return modified INFO."))
;;; Node protocol
;;;
;;; Each node has an associated "*-info instance" (e.g. `host-info',
;;; `remote-host-info', `process-info', etc.) associated to
;;; it. Also, nodes form a hierarchy:
;;;
;;; host node ─> process node ─> participant node ─┐
;;; ⌃ │
;;; └──────────┘
(defgeneric node-info (node)
(:documentation
"Return the *-info instance associated to NODE."))
(defgeneric node-parent (node)
(:documentation
"Return the node which is the parent of NODE or nil if there is
none."))
(defgeneric node-children (node)
(:documentation
"Return the list of nodes which are the children of NODE."))
;; Default behavior
(defmethod node-parent ((node t))
nil)
(defmethod node-children ((node t))
'())
;; Local Variables:
;; coding: utf-8
;; End:
| 6,020 | Common Lisp | .lisp | 153 | 35.895425 | 70 | 0.738454 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 41e1fa070c9d5577ffff53d8c21939f143e64701228eb8ab1f8660c260f54116 | 25,380 | [
-1
] |
25,381 | types.lisp | open-rsx_rsb-cl/src/model/types.lisp | ;;;; types.lisp --- Types in used by the model module.
;;;;
;;;; Copyright (C) 2014, 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.model)
(deftype process-state ()
"States of a remote process."
'(member :unknown :running :crashed))
(deftype host-state ()
"States of a remote host."
'(member :unknown :up :down))
| 383 | Common Lisp | .lisp | 12 | 30 | 61 | 0.684783 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 52883a50fd46f7539ad5c3df310eba68e859a1f1854602477198bc4d827079e5 | 25,381 | [
-1
] |
25,382 | builder.lisp | open-rsx_rsb-cl/src/model/builder.lisp | ;;;; builder.lisp --- (un)builder support for model classes.
;;;;
;;;; Copyright (C) 2015, 2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.model.builder
(:use
#:cl
#:alexandria
#:let-plus
#:architecture.builder-protocol
#:rsb.model)
(:shadowing-import-from #:rsb.model
#:node))
(cl:in-package #:rsb.model.builder)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro define-node-methods ((class &key (kind (make-keyword class)))
&rest slots)
(let+ ((conc-name (symbolicate class '#:-))
(slots (mapcar #'ensure-list slots))
((&flet make-node-initargs (builder)
(let+ (((&flet+ maybe-initarg ((name &key (builders '(t))))
(when (or (eq builders t) (member builder builders
:test #'equal))
(let ((accessor (symbolicate conc-name name)))
`(,(make-keyword name) (,accessor node)))))))
`(defmethod node-initargs ((builder ,builder) (node ,class))
(list ,@(mapcan #'maybe-initarg slots)))))))
`(progn
(defmethod node-kind ((builder t) (node ,class))
,kind)
,(make-node-initargs t)
,(make-node-initargs '(eql :reverse))))))
;;; generic node
(defmethod node-kind ((builder t) (node node))
(node-kind builder (node-info node)))
(defmethod node-initargs ((builder t) (node node))
(node-initargs builder (node-info node)))
(defmethod node-relations ((builder t) (node node))
(append (list* '(:children . *) (node-relations builder (node-info node)))
(call-next-method)))
(defmethod node-relation ((builder t)
(relation (eql :children))
(node node))
(node-children node))
(defmethod node-relation ((builder t) (relation t) (node node))
(node-relation builder relation (node-info node)))
;;; `participant-node' and `participant-info'
(define-node-methods (participant-info :kind :participant)
(kind :builders t)
(id :builders t)
scope
type)
(defmethod node-relations ((builder t) (node participant-info))
(list* '(:transports . *) (call-next-method)))
(defmethod node-relation ((builder t)
(relation (eql :transports))
(node participant-info))
(participant-info-transports node))
;;; `process-node' and `[remote-]process-info'
(define-node-methods (process-info :kind :process)
(process-id :builders t)
(program-name :builders t)
start-time
executing-user
rsb-version
(display-name :builders t))
(defmethod node-relations ((builder t) (node process-info))
(list* '(:commandline-arguments . *) (call-next-method)))
(defmethod node-relation ((builder t)
(relation (eql :commandline-arguments))
(node process-info))
(process-info-commandline-arguments node))
(defmethod node-initargs ((builder t) (node remote-process-info))
(list* :state (process-info-state node) (call-next-method)))
(defmethod node-relations ((builder t) (node remote-process-info))
(list* '(:transports . *) (call-next-method)))
(defmethod node-relation ((builder t)
(relation (eql :transports))
(node remote-process-info))
(process-info-transports node))
;;; `host-node' and `[remote-]host-info'
(define-node-methods (host-info :kind :host)
(id :builders t)
(hostname :builders t)
machine-type
machine-version
software-type
software-version)
(defmethod node-initargs ((builder t) (node remote-host-info))
(list* :state (host-info-state node) (call-next-method)))
;;; reverse builder
;;;
;;; Traverses tree from children to parents and only included basic
;;; information in each node.
(defmethod node-relations :around ((builder (eql :reverse))
(node node))
(when-let ((parent (node-parent node)))
'((:parent . 1))))
(defmethod node-relation ((builder (eql :reverse))
(relation (eql :parent))
(node node))
(node-parent node))
| 4,335 | Common Lisp | .lisp | 103 | 34.174757 | 76 | 0.601237 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 438a8ef51dc1711ca09a0d054fecfb4fdc5757468253cbfeef1dbb829c1399ce | 25,382 | [
-1
] |
25,383 | mixins.lisp | open-rsx_rsb-cl/src/model/mixins.lisp | ;;;; mixins.lisp --- Mixin classes used in the model module.
;;;;
;;;; Copyright (C) 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.model)
;;; `most-recent-activity-mixin'
(defclass most-recent-activity-mixin ()
((most-recent-activity :type local-time:timestamp
:accessor info-most-recent-activity
:initform (local-time:now)
:documentation
"Stores the timestamp at which the most
recent activity involving the object
occurred."))
(:documentation
"This mixin stores a timestamp corresponding to the most recent
activity on the object."))
(defun info-most-recent-activity-difference (thing
&optional (time (local-time:now)))
(local-time:timestamp-difference time (info-most-recent-activity thing)))
;;; `timing-info-mixin'
(defclass timing-info-mixin ()
((clock-offset :initarg :clock-offset
:type (or null real)
:accessor info-clock-offset
:initform nil
:documentation
"Stores the estimated difference in seconds between
the clock of the local host and the clock of the
remote host.")
(latency :initarg :latency
:type (or null real)
:accessor info-latency
:initform nil
:documentation
"Stores the mean event transport latency in seconds
between the local host and the remote host."))
(:documentation
"This mixin adds slots for storing an estimated clock offset and an
estimated transport latency."))
;;; `info-mixin'
(defclass info-mixin ()
((info :initarg :info
:reader node-info
:documentation
"Stores the `*-info' instance associated to the node."))
(:default-initargs
:info (missing-required-initarg 'info-mixin :info))
(:documentation
"This class is intended to be mixed into node classes that store an
associated `*-info' instance."))
(defmethod print-items:print-items append ((object info-mixin))
(print-items:print-items (node-info object)))
;;; Tree structure mixins
(defclass parented-mixin ()
((parent :initarg :parent
:type (or null node)
:reader node-parent
:initform nil
:documentation
"Stores nil or the parent `node' instance of this node."))
(:documentation
"This class is intended to be mixed into node classes instances of
which have an associated parent node."))
(defclass child-container-mixin ()
((children :initarg :children
:type list #| of node |#
:accessor node-children
:initform '()
:documentation
"Stores a list of child `node' instances of this node"))
(:documentation
"This class is intended to be mixed into node classes instances of
which have a list of child nodes."))
| 3,155 | Common Lisp | .lisp | 75 | 32.306667 | 79 | 0.60854 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 4836d00180e2be521e7a10d91883d84525333a1a860027cf4ee9b3dc40acccee | 25,383 | [
-1
] |
25,384 | package.lisp | open-rsx_rsb-cl/src/model/inference/package.lisp | ;;;; package.lisp --- Package definition for the model.inference module.
;;;;
;;;; Copyright (C) 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:defpackage #:rsb.model.inference
(:use
#:cl
#:alexandria
#:let-plus
#:more-conditions
#:rsb.model)
(:import-from #:rsb
#:scope
#:scope-string
#:scope=
#:sub-scope?
#:uri->scope-and-options)
(:export
#:communication?
#:participants-communicate-using-kinds?)
(:documentation
"This package contains functions for inferring facts about modeled
systems.
The following inference protocols are available:
* communication? from to [generic function]
Determine whether communication between the objects represented
by model objects FROM and TO is possible."))
| 824 | Common Lisp | .lisp | 28 | 25.571429 | 72 | 0.702668 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | bc28f7aa53f9ff831dc63150c7461939d320089313817f4e7a7419f500187c8f | 25,384 | [
-1
] |
25,385 | util.lisp | open-rsx_rsb-cl/src/model/inference/util.lisp | ;;;; util.lisp --- Utilities used in the model.inference module.
;;;;
;;;; Copyright (C) 2015, 2016 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.model.inference)
;;; Minimal tri-modal logic
;;;
;;; See documentation string of `communication?' for an explanation of
;;; how the three states are used in this module.
(defun check-tri-value (value definitive?)
(when (and value (not definitive?))
(error 'incompatible-arguments
:parameters '(:value :definitive?)
:values (list value definitive?))))
(declaim (inline funcall-and-check))
(defun funcall-and-check (thunk)
(let+ (((&values value definitive?) (funcall thunk)))
(check-tri-value value definitive?)
(values value definitive?)))
(declaim (ftype (function (function function) (values boolean boolean &optional))
%tri-and %tri-or))
(defun %tri-and (left-thunk right-thunk)
(let+ (((&values left-result left-definitive?)
(funcall-and-check left-thunk)))
(if (and (not left-result) left-definitive?)
(values nil t)
(let+ (((&values right-result right-definitive?)
(funcall-and-check right-thunk)))
(if (and (not right-result) right-definitive?)
(values nil t)
(values (and left-result right-result)
(and left-definitive? right-definitive?)))))))
(defun %tri-or (left-thunk right-thunk)
(let+ (((&values left-result left-definitive?)
(funcall-and-check left-thunk)))
(if (and left-result left-definitive?)
(values t t)
(let+ (((&values right-result right-definitive?)
(funcall-and-check right-thunk)))
(if (and right-result right-definitive?)
(values t t)
(values (or left-result right-result)
(and left-definitive? right-definitive?)))))))
(macrolet
((define-operator-macro (macro-name function-name)
`(defmacro ,macro-name (&optional
(left nil left-supplied?)
(right nil right-supplied?)
&rest more)
(cond
(more
`(,',macro-name
(,',function-name (lambda () ,left) (lambda () ,right))
,@more))
(right-supplied?
`(,',function-name (lambda () ,left) (lambda () ,right)))
(left-supplied?
left)
(t
`(values t t))))))
(define-operator-macro tri-and %tri-and)
(define-operator-macro tri-or %tri-or))
(defun tri-reduce (function sequence
&key
(key #'values-list)
(initial-value '(nil t)))
(let ((function (ensure-function function))
(key (ensure-function key)))
(values-list
(reduce (lambda (element accum)
(multiple-value-list
(multiple-value-call function
(lambda () (funcall key element))
(lambda () (values-list accum)))))
sequence :initial-value initial-value :from-end t))))
(declaim (inline tri-some))
(defun tri-some (function sequence)
(tri-reduce #'%tri-or sequence :key function))
| 3,284 | Common Lisp | .lisp | 79 | 32.088608 | 81 | 0.578091 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 91c8811c58ae42d6c06414349d79d8f82b0fac7025b4ebcd4295edc1fba2e3db | 25,385 | [
-1
] |
25,386 | inference.lisp | open-rsx_rsb-cl/src/model/inference/inference.lisp | ;;;; inference.lisp --- Implementation of the model.inference module.
;;;;
;;;; Copyright (C) 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.model.inference)
;;; Scope- and transport-level inference
(defmethod communication? ((from scope) (to scope))
(cond
;; Sender sends on sub-scope of receiver's scope => Receiver
;; definitely receives events.
((sub-scope? from to) (values t t))
;; Sender sends on super-scope of receiver's scope => Receiver may
;; receive events when sender sends on a suitable sub-scope of its
;; scope (which is allowed but may not necessarily happen).
((sub-scope? to from) (values nil nil))
;; None of the above relations hold => Receiver can definitely not
;; receive events sent by sender.
(t (values nil t))))
;; We cannot be certain if one thing is a URI and the other thing is a
;; scope.
(defmethod communication? ((from scope) (to puri:uri))
(tri-and (communication? from (uri->scope-and-options to))
(values nil nil)))
(defmethod communication? ((from puri:uri) (to scope))
(tri-and (communication? (uri->scope-and-options from) to)
(values nil nil)))
(defmethod communication? ((from puri:uri) (to puri:uri))
(let+ (((&values to-scope to-options)
(uri->scope-and-options to))
((&values from-scope from-options)
(uri->scope-and-options from))
;; TODO when we get first-class transports, there will be a
;; generic function in the transport protocol for deciding
;; whether, given a certain transport, two sets of transport
;; options for that transport allow for communication.
((&flet options-plist (options)
(remove '&inherit (rest options))))
((&flet enabled? (options)
(getf (options-plist options) :enabled)))
((&flet+ same-transport? ((&whole left left-transport &rest &ign)
(&whole right right-transport &rest &ign))
(and (eq left-transport right-transport)
(equal (options-plist left)
(options-plist right)))))
((&flet+ common-transport? (left-options right-options)
(map-product (lambda (left right)
(when (same-transport? left right)
(return-from common-transport?
(values t t))))
(remove-if-not #'enabled? left-options)
(remove-if-not #'enabled? right-options))
(values nil t))))
(tri-and (communication? from-scope to-scope)
(common-transport? to-options from-options))))
;;; Participant-level inference
;;;
;;; This level takes into account participant kinds, scopes and
;;; transport configurations but not the question whether child
;;; participants communicate.
(defmethod communication? ((from participant-info) (to participant-info))
(participants-communicate-using-kinds?
from to (participant-info-kind from) (participant-info-kind to)))
(defmethod participants-communicate-using-kinds?
((from participant-info)
(to participant-info)
(from-kind t)
(to-kind t))
(values nil nil))
;; `:%sender' and `:%receiver' are pseudo-participant kinds that allow
;; the definition of this basic method. Methods for real participant
;; kinds can call this method to check scope and transport
;; communication.
(defmethod participants-communicate-using-kinds?
((from participant-info)
(to participant-info)
(from-kind (eql :%sender))
(to-kind (eql :%receiver)))
(let+ (((&structure-r/o
participant-info- (from-scope scope) (from-transports transports))
from)
((&structure-r/o
participant-info- (to-scope scope) (to-transports transports))
to)
((&flet scope+uri->uri (scope uri)
(puri:merge-uris (make-instance 'puri:uri
:path (scope-string scope))
uri)))
(uris '())
((&flet communication?/transports (from-uri to-uri)
(let+ (((&values value definitive?)
(communication? (scope+uri->uri from-scope from-uri)
(scope+uri->uri to-scope to-uri))))
(when (or value (not definitive?))
(push (cons from-uri to-uri) uris))
(values value definitive?)))))
;; TODO special hack until all languages support this
(when (or (not from-transports) (not to-transports))
(return-from participants-communicate-using-kinds?
(communication? from-scope to-scope)))
;; Check for all combinations of transports whether communication
;; is possible.
(multiple-value-call #'values
(cond
;; Optimization for common case of a one transport in each info.
((and (length= 1 from-transports) (length= 1 to-transports))
(communication?/transports
(first from-transports) (first to-transports)))
;; Hopefully uncommon case: check all combinations of transports
(t
(tri-reduce #'%tri-or
(map-product (lambda (from-uri to-uri)
(multiple-value-list
(communication?/transports from-uri to-uri)))
from-transports to-transports)
:initial-value '(nil t))))
uris)))
(defmethod participants-communicate-using-kinds?
((from participant-info)
(to participant-info)
(from-kind (eql :listener))
(to-kind t))
(values nil t))
(defmethod participants-communicate-using-kinds?
((from participant-info)
(to participant-info)
(from-kind t)
(to-kind (eql :informer)))
(values nil t))
(defmethod participants-communicate-using-kinds?
((from participant-info)
(to participant-info)
(from-kind (eql :informer))
(to-kind (eql :listener)))
(participants-communicate-using-kinds? from to :%sender :%receiver))
(macrolet
((define-communicate-using-kinds?-method (from-kind to-kind)
`(defmethod participants-communicate-using-kinds?
((from participant-info)
(to participant-info)
(from-kind (eql ,from-kind))
(to-kind (eql ,to-kind)))
;; Methods need identical scopes in addition to the usual
;; requirements.
(if (scope= (participant-info-scope from)
(participant-info-scope to))
(participants-communicate-using-kinds?
from to :%sender :%receiver)
(values nil t)))))
(define-communicate-using-kinds?-method :local-method :remote-method)
(define-communicate-using-kinds?-method :remote-method :local-method))
;;; Composite-level inference
(defmethod communication? ((from node) (to node))
(let+ ((uris '())
((&flet+ uri-pair= ((left-from . left-to)
(right-from . right-to))
(and (puri:uri= left-from right-from)
(puri:uri= left-to right-to))))
((&flet communication?/push-uris (from to)
(let+ (((&values value definitive? uris*)
(communication? from to)))
(when (or value (not definitive?))
(dolist (uri uris*)
(pushnew uri uris :test #'uri-pair=)))
(values value definitive?)))))
(multiple-value-call #'values
(tri-or (communication?/push-uris (node-info from) (node-info to))
(tri-some (rcurry #'communication?/push-uris to)
(node-children from))
(tri-some (curry #'communication?/push-uris from)
(node-children to)))
uris)))
| 8,024 | Common Lisp | .lisp | 172 | 36.680233 | 82 | 0.595278 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 141e8524a6d84ed567705160560a12b09f791300d71faa135d4d324d92fe0694 | 25,386 | [
-1
] |
25,387 | protocol.lisp | open-rsx_rsb-cl/src/model/inference/protocol.lisp | ;;;; protocol.lisp --- Protocol provided by the model.inference module.
;;;;
;;;; Copyright (C) 2015 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
(cl:in-package #:rsb.model.inference)
;;; Communication inference protocol
;;;
;;; The functions in this protocol return information about the
;;; possibility of communication between RSB objects (hosts,
;;; processes, participants, etc.).
;;;
;;; The returned information represents a static view of the situation
;;; in the following sense: communication between objects is
;;; considered possible when the respective transport configuration,
;;; scopes, filters, etc. allow for communication between the
;;; objects. This does not imply that communication actually happens
;;; or will happen.
;;;
;;; There is the additional notion of possible communication when
;;; certain criteria are met. For example, an informer on scope /foo/
;;; is allowed to publish events on scope /foo/bar/. Whether a
;;; listener on scope /foo/bar/ receives events from that informer
;;; therefore depends on whether the informer actually publishes on
;;; such a sub-scope. This notion is the reason for tri-modal return
;;; values of `communication?' and related functions.
(defgeneric communication? (from to)
(:documentation
"Determine whether communication between FROM and TO is possible.
Return three values, the first two of which indicate a ternary
result (like `cl:subtypep'):
first value | second value | meaning
t | t | communication is definitely possible
nil | t | communication is definitely impossible
nil | nil | cannot determine whether communication
| | is possible
When present, the third value is a list of pairs of the form
(FROM-URI . TO-URI)
where FROM-URI is associated to FROM and TO-URI is associated to
TO and communication between FROM and TO is possible via the
indicated transports.
FROM and TO can describe various aspects of an RSB system such as
URIs, scopes, participants (via `rsb.model:participant-info') or
processes (via `rsb.model:process-info')."))
(defgeneric participants-communicate-using-kinds? (from to from-kind to-kind)
(:documentation
"Determine whether communication between FROM and TO is possible.
Return values are identical to `communication?'.
FROM and TO are `rsb.model:participant-info' instances of kinds
FROM-KIND and TO-KIND respectively.
This function is mainly used as a helper function of
`communication?' when answering questions about participants."))
;; Default behavior
(defmethod communication? ((from t) (to t))
(values nil nil))
| 2,762 | Common Lisp | .lisp | 55 | 46.836364 | 77 | 0.729569 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e96a04f66e7880fcb7cb62625ef86deffc9dff992f45e40d124a1417c4ede4e0 | 25,387 | [
-1
] |
25,388 | rsb-builder.asd | open-rsx_rsb-cl/rsb-builder.asd | ;;;; rsb-builder.asd --- Builder support for RSB objects.
;;;;
;;;; Copyright (C) 2015, 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-builder"
:description "Builder support for RSB objects such as events."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ("alexandria"
"let-plus"
(:version "architecture.builder-protocol" "0.3")
(:version "architecture.builder-protocol.universal-builder" "0.3")
(:version "rsb" #.(version/string)))
:components ((:module "src"
:components ((:file "builder"))))
:in-order-to ((test-op (test-op "rsb-builder/test"))))
(defsystem "rsb-builder/test"
:description "Unit tests for the rsb-builder system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "architecture.builder-protocol/test" "0.3")
(:version "rsb-builder" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "test"
:components ((:file "builder"))))
:perform (test-op (operation component)
(eval (read-from-string "(lift:run-tests :config
(asdf:system-relative-pathname
:rsb-builder/test \"lift-builder.config\"))"))))
| 2,086 | Common Lisp | .asd | 39 | 44.923077 | 96 | 0.562992 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 7c1c38e1068e3940412283b0e1dad06501822edf7228a4f6d6ca986eabec7a4d | 25,388 | [
-1
] |
25,389 | rsb-introspection.asd | open-rsx_rsb-cl/rsb-introspection.asd | ;;;; rsb-introspection.asd --- System definition for introspection for RSB.
;;;;
;;;; Copyright (C) 2013-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-introspection"
:description "Introspection support for RSB."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:defsystem-depends-on ("cl-protobuf")
:depends-on ("utilities.print-items"
(:version "uiop" "3") ; for portable platform information
(:version "rsb" #.(version/string))
(:version "rsb-model" #.(version/string))
(:version "rsb-patterns-request-reply" #.(version/string)))
:components ((:protocol-buffer-descriptor-directory "protocol"
:pathname "data"
:components ((:file "Hello"
:pathname "rsb/protocol/introspection/Hello")
(:file "Bye"
:pathname "rsb/protocol/introspection/Bye")))
(:module "introspection"
:pathname "src/introspection"
:depends-on ("protocol")
:serial t
:components ((:file "package")
;; Platform information interface.
(:file "platform-common")
(:file "platform-sbcl-linux"
:if-feature (:and :sbcl :linux))
(:file "platform-sbcl-darwin"
:if-feature (:and :sbcl :darwin))
(:file "platform-sbcl-win32"
:if-feature (:and :sbcl :win32))
(:file "platform-generic"
:if-feature (:or (:not :sbcl)
(:and (:not :linux)
(:not :darwin)
(:not :win32))))
(:file "conditions")
(:file "protocol")
(:file "variables")
(:file "model")
(:file "conversion")
(:file "mixins")
(:file "local-introspection")
(:file "timing-tracking")
(:file "remote-introspection")
(:file "reloading"
:if-feature :sbcl))))
:in-order-to ((test-op (test-op "rsb-introspection/test"))))
(defsystem "rsb-introspection/test"
:description "Unit tests for the rsb-introspection system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb-introspection" #.(version/string))
(:version "rsb/test" #.(version/string))
(:version "rsb-model/test" #.(version/string)))
:components ((:module "introspection"
:pathname "test/introspection"
:serial t
:components ((:file "package")
(:file "platform")
(:file "model")
(:file "local-introspection")
(:file "timing-tracking")
(:file "remote-introspection")
(:file "reloading"
:if-feature :sbcl))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string "(lift:run-tests :config
(asdf:system-relative-pathname
:rsb-introspection/test \"lift-introspection.config\"))"))))
| 4,710 | Common Lisp | .asd | 83 | 36.927711 | 105 | 0.441477 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 01607f6b22796face4d8cae3d393a6efb5793591bc9aa55b3f3b024d9594ce46 | 25,389 | [
-1
] |
25,390 | rsb-model.asd | open-rsx_rsb-cl/rsb-model.asd | ;;;; rsb-model.asd --- System definition for model for RSB.
;;;;
;;;; Copyright (C) 2015, 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-model"
:description "Modeling of and inference on RSB systems."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ("alexandria"
"let-plus"
"more-conditions"
"utilities.print-items"
(:version "rsb" #.(version/string)))
:components ((:module "model"
:pathname "src/model"
:serial t
:components ((:file "package")
(:file "types")
(:file "protocol")
(:file "mixins")
(:file "classes")))
(:module "model-inference"
:pathname "src/model/inference"
:depends-on ("model")
:serial t
:components ((:file "package")
(:file "protocol")
(:file "util")
(:file "inference"))))
:in-order-to ((test-op (test-op "rsb-model/test"))))
(defsystem "rsb-model/test"
:description "Unit tests for the rsb-model system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb-model" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "model"
:pathname "test/model"
:serial t
:components ((:file "package")
(:file "classes")))
(:module "model-inference"
:pathname "test/model/inference"
:serial t
:components ((:file "package")
(:file "util")
(:file "inference"))))
:perform (test-op (component operation)
(eval (read-from-string "(lift:run-tests :config
(asdf:system-relative-pathname
:rsb-model/test \"lift-model.config\"))"))))
| 2,898 | Common Lisp | .asd | 61 | 33.262295 | 88 | 0.47803 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 1e723114c7e30ce490d0cdac9d62dab9c7513c2f83b7aaa7a7ba4a49d54fd5af | 25,390 | [
-1
] |
25,391 | rsb-model-builder.asd | open-rsx_rsb-cl/rsb-model-builder.asd | ;;;; rsb-model-builder.asd --- Builder support for RSB model objects.
;;;;
;;;; Copyright (C) 2015, 2016, 2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-model-builder"
:description "Builder support for RSB model objects"
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "architecture.builder-protocol" "0.3")
(:version "rsb-model" #.(version/string))
(:version "rsb-introspection" #.(version/string)))
:components ((:module "model"
:pathname "src/model"
:components ((:file "builder")))
(:module "introspection"
:pathname "src/introspection"
:components ((:file "builder"))))
:in-order-to ((test-op (test-op "rsb-model-builder/test"))))
(defsystem "rsb-model-builder/test"
:description "Unit tests for the rsb-model-builder system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "architecture.builder-protocol/test" "0.3")
(:version "rsb-model-builder" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "model"
:pathname "test/model"
:components ((:file "builder")))
(:module "introspection"
:pathname "test/introspection"
:components ((:file "builder"))))
:perform (test-op (operation component)
(eval (read-from-string "(lift:run-tests :config
(asdf:system-relative-pathname
:rsb-model-builder/test \"lift-model-builder.config\"))"))))
| 2,420 | Common Lisp | .asd | 45 | 43.733333 | 104 | 0.558898 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 709784457edbed5e3ab3cc6c6bed021dc5d44d64ae31193e06917effbed8c50e | 25,391 | [
-1
] |
25,392 | rsb-filter-xpath.asd | open-rsx_rsb-cl/rsb-filter-xpath.asd | ;;;; rsb-xpath-filter.asd --- System containing XPath-based filter.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-filter-xpath"
:description "Filter that uses XPath expressions to discriminate events."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ("xpath"
(:version "architecture.builder-protocol.xpath" "0.7")
(:version "rsb" #.(version/string :revision? t))
(:version "rsb-builder" #.(version/string :revision? t)))
:components ((:module "filter"
:pathname "src/filter"
:components ((:file "xpath-filter"))))
:in-order-to ((test-op (test-op "rsb-filter-xpath/test"))))
(defsystem "rsb-filter-xpath/test"
:description "Unit tests for the rsb-transport-spread system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb" #.(version/string))
(:version "rsb-filter-xpath" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "filter"
:pathname "test/filter"
:components ((:file "xpath-filter"))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string
"(lift:run-tests :config (lift::lift-relative-pathname
\"lift-filter-xpath.config\"))"))))
| 2,198 | Common Lisp | .asd | 41 | 44.682927 | 97 | 0.574627 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 0f60e3730b9c2272cd45ff0b81338afcf59186be465c634a8d587dd792275f48 | 25,392 | [
-1
] |
25,393 | rsb-protocol.asd | open-rsx_rsb-cl/rsb-protocol.asd | ;;;; rsb-protocol.asd --- System for loading the native RSB communication protocol.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-protocol"
:description "Google protocol buffer-based communication protocol."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:defsystem-depends-on ("cl-protobuf")
:components ((:protocol-buffer-descriptor-directory "protocol"
:pathname "data"
:serial t
:components ((:file "EventId"
:pathname "rsb/protocol/EventId")
(:file "EventMetaData"
:pathname "rsb/protocol/EventMetaData")
(:file "Notification"
:pathname "rsb/protocol/Notification")
(:file "FragmentedNotification"
:pathname "rsb/protocol/FragmentedNotification")
(:file "EventsByScopeMap"
:pathname "rsb/protocol/collections/EventsByScopeMap")))))
| 1,518 | Common Lisp | .asd | 29 | 39.137931 | 91 | 0.559676 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b6938de50c977f633f4706e46f81f0fea91e3c47e71b794377f6473457d91036 | 25,393 | [
-1
] |
25,394 | rsb-transport-spread.asd | open-rsx_rsb-cl/rsb-transport-spread.asd | ;;;; rsb-transport-spread.asd --- System containing the Spread-based transport.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defparameter *spread-port*
(or (let ((value (uiop:getenv "SPREAD_PORT")))
(when value (read-from-string value)))
5678))
(defsystem "rsb-transport-spread"
:description "RSB transport based on the Spread group communication system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ("nibbles"
"ironclad"
"cl-protobuf"
(:version "network.spread" "0.3")
(:version "rsb" #.(version/string :revision? t))
(:version "rsb-protocol" #.(version/string :revision? t)))
:components ((:module "spread"
:pathname "src/transport/spread"
:serial t
:components ((:file "package")
(:file "notifications")
(:file "conditions")
(:file "protocol")
(:file "util")
(:file "fragmentation")
(:file "conversion")
(:file "transport")
(:file "connection")
(:file "sender-receiver")
(:file "bus-mixins")
(:file "bus")
(:file "connector")
(:file "in-connector")
(:file "in-push-connector")
(:file "in-pull-connector")
(:file "out-connector"))))
:in-order-to ((test-op (test-op "rsb-transport-spread/test"))))
(defsystem "rsb-transport-spread/test"
:description "Unit tests for the rsb-transport-spread system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb" #.(version/string))
(:version "rsb-transport-spread" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "spread"
:pathname "test/transport/spread"
:serial t
:components ((:file "package")
(:file "util")
(:file "fragmentation")
(:file "connection")
(:file "sender-receiver")
(:file "connectors"))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string
"(network.spread.daemon:with-daemon (:port rsb-system::*spread-port*)
(lift:run-tests :config (lift::lift-relative-pathname
\"lift-transport-spread.config\")))"))))
| 3,771 | Common Lisp | .asd | 71 | 36.957746 | 93 | 0.469676 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 440e4c31d4fc2d6b76e1259e07227d802dee96bde47c360acd7b975d6bca3832 | 25,394 | [
-1
] |
25,395 | rsb-converter-protocol-buffer.asd | open-rsx_rsb-cl/rsb-converter-protocol-buffer.asd | ;;;; rsb-converter-protocol-buffer.asd --- System containing converter for protocol buffer payloads.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-converter-protocol-buffer"
:description "Converter for Google protocol buffer payloads."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "rsb" #.(version/string :revision? t))
"cl-protobuf")
:components ((:module "converter"
:pathname "src/converter"
:components ((:file "protocol-buffers")))))
| 935 | Common Lisp | .asd | 20 | 41.9 | 100 | 0.665934 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | e7d758673cc648edcb291db32f7a4134eb73bc9aaa61c184aebb35b4906b44c4 | 25,395 | [
-1
] |
25,396 | rsb-filter-regex.asd | open-rsx_rsb-cl/rsb-filter-regex.asd | ;;;; rsb-filter-regex.asd --- System containing regex-based filter.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-filter-regex"
:description "Regular expression filter for events with text payloads."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ("cl-ppcre"
(:version "rsb" #.(version/string :revision? t)))
:components ((:module "filter"
:pathname "src/filter"
:components ((:file "regex-filter"))))
:in-order-to ((test-op (test-op "rsb-filter-regex/test"))))
(defsystem "rsb-filter-regex/test"
:description "Unit tests for the rsb-filter-regex system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb" #.(version/string))
(:version "rsb-filter-regex" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "filter"
:pathname "test/filter"
:components ((:file "regex-filter"))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string
"(lift:run-tests :config (lift::lift-relative-pathname
\"lift-filter-regex.config\"))"))))
| 1,995 | Common Lisp | .asd | 39 | 42.641026 | 85 | 0.590839 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 65fa707987add77fb561492b7c4f17afc5002fdf763852cdb7d6168464edf9c2 | 25,396 | [
-1
] |
25,397 | rsb-transport-socket.asd | open-rsx_rsb-cl/rsb-transport-socket.asd | ;;;; rsb-transport-socket.asd --- System containing the socket transport.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-transport-socket"
:description "Socket-based transport for RSB."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "usocket" "0.6.4") ; for `socket-shutdown'
"cl-protobuf"
(:version "rsb" #.(version/string :revision? t))
(:version "rsb-protocol" #.(version/string :revision? t)))
:components ((:module "socket"
:pathname "src/transport/socket"
:serial t
:components ((:file "puri-patch")
(:file "package")
(:file "protocol")
(:file "conditions")
(:file "util")
(:file "conversion")
(:file "transport")
(:file "bus-connection")
(:file "bus")
(:file "bus-client")
(:file "bus-server")
(:file "connectors")
(:file "socket-tcp")
(:file "transport-tcp")
(:file "connectors-tcp")
(:file "socket-unix"
:if-feature (:and :sbcl :linux))
(:file "transport-unix"
:if-feature (:and :sbcl :linux))
(:file "connectors-unix"
:if-feature (:and :sbcl :linux)))))
:in-order-to ((test-op (test-op "rsb-transport-socket/test"))))
(defsystem "rsb-transport-socket/test"
:description "Unit Tests for the rsb-transport-socket system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb-transport-socket" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "socket"
:pathname "test/transport/socket"
:serial t
:components ((:file "package")
(:file "bus")
(:file "transport-tcp")
(:file "connectors-tcp")
(:file "transport-unix"
:if-feature (:and :sbcl :linux))
(:file "connectors-unix"
:if-feature (:and :sbcl :linux)))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string
"(lift:run-tests :config (lift::lift-relative-pathname
\"lift-transport-socket.config\"))"))))
| 3,826 | Common Lisp | .asd | 69 | 36.681159 | 89 | 0.440846 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | a3f8dd8e0eb48d60e785e5fdcb6ac51ca2669473f5f5a5f0aa15d644e0dd8dec | 25,397 | [
-1
] |
25,398 | rsb-clon.asd | open-rsx_rsb-cl/rsb-clon.asd | ;;;; rsb-clon.asd --- System for interoperation with clon.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-clon"
:description "Generate clon option descriptions based on
introspection of RSB configuration options."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "rsb" #.(version/string :revision? t))
"net.didierverna.clon")
:components ((:file "clon"
:pathname "src/clon")))
| 863 | Common Lisp | .asd | 20 | 38.35 | 65 | 0.657518 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 060cff5dcbd7d4028d38fe7e6e4ab81811a109dc31c8010fa1b980a14f449618 | 25,398 | [
-1
] |
25,399 | rsb-transport-inprocess.asd | open-rsx_rsb-cl/rsb-transport-inprocess.asd | ;;;; rsb-transport-inprocess.asd --- System containing the inprocess transport.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-transport-inprocess"
:description "Simple and efficient in-process transport."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "rsb" #.(version/string :revision? t)))
:components ((:module "inprocess"
:pathname "src/transport/inprocess"
:serial t
:components ((:file "package")
(:file "transport")
(:file "connectors"))))
:in-order-to ((test-op (test-op "rsb-transport-inprocess/test"))))
(defsystem "rsb-transport-inprocess/test"
:description "Unit Tests for the rsb-transport-inprocess system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb-transport-inprocess" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "inprocess"
:pathname "test/transport/inprocess"
:serial t
:components ((:file "package")
(:file "connectors"))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string
"(lift:run-tests :config (lift::lift-relative-pathname
\"lift-transport-inprocess.config\"))"))))
| 2,210 | Common Lisp | .asd | 42 | 42.47619 | 92 | 0.573748 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b67d857cb8ca17bdbbe3d259d3bebad764735ca224f835b25b080fc3e822bbba | 25,399 | [
-1
] |
25,400 | rsb-patterns-request-reply.asd | open-rsx_rsb-cl/rsb-patterns-request-reply.asd | ;;;; rsb-patterns-request-reply.asd --- System definition for rsb-patterns-request-reply system.
;;;;
;;;; Copyright (C) 2011-2018 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>
#.(unless (find-package '#:rsb-system)
(load (merge-pathnames "rsb.asd" *load-truename*))
(values))
(cl:in-package #:rsb-system)
(defsystem "rsb-patterns-request-reply"
:description "Request-Reply communication pattern for RSB."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ("alexandria"
"iterate"
(:version "let-plus" "0.2")
"more-conditions"
(:version "utilities.print-items" "0.1")
(:version "bordeaux-threads" "0.8.4")
"closer-mop"
(:version "rsb" #.(version/string)))
:components ((:module "patterns-request-reply"
:pathname "src/patterns/request-reply"
:serial t
:components ((:file "package")
(:file "types")
(:file "variables")
(:file "conditions")
(:file "protocol")
(:file "future")
(:file "server")
(:file "local-server")
(:file "remote-server")
(:file "macros"))))
:in-order-to ((test-op (test-op "rsb-patterns-request-reply/test"))))
(defsystem "rsb-patterns-request-reply/test"
:description "Unit tests for the rsb-patterns-request-reply system."
:license "LGPLv3" ; see COPYING file for details.
:author "Jan Moringen <[email protected]>"
:maintainer "Jan Moringen <[email protected]>"
:version #.(version/string)
:depends-on ((:version "lift" "1.7.1")
(:version "rsb-patterns-request-reply" #.(version/string))
(:version "rsb-transport-inprocess" #.(version/string))
(:version "rsb/test" #.(version/string)))
:components ((:module "patterns-request-reply"
:pathname "test/patterns/request-reply"
:serial t
:components ((:file "package")
(:file "future")
(:file "server")
(:file "local-server")
(:file "remote-server")
(:file "macros")
(:file "integration"))))
:perform (test-op (operation component)
(eval (read-from-string "(log:config :warn)")) ; less noise
(eval (read-from-string "(lift:run-tests :config
(asdf:system-relative-pathname
:rsb-patterns-request-reply/test \"lift-patterns-request-reply.config\"))"))))
| 3,377 | Common Lisp | .asd | 62 | 39.048387 | 122 | 0.486946 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 92d31732e5e985864d4f125ebc2c3691ca5358310efa5a8c357c547e1394531b | 25,400 | [
-1
] |
25,401 | sbcl.cmake.in | open-rsx_rsb-cl/sbcl.cmake.in | set(ENV{CC} "@CMAKE_C_COMPILER@")
set(ENV{SBCL_HOME} "@SBCL_HOME@")
set(ENV{CL_SOURCE_REGISTRY} "@CL_SOURCE_REGISTRY@")
set(ENV{ASDF_OUTPUT_TRANSLATIONS} "@ASDF_OUTPUT_TRANSLATIONS@")
execute_process(COMMAND "@SBCL_EXECUTABLE@"
--noinform
@LISP_RUNTIME_OPTIONS@
--disable-debugger
--no-sysinit --no-userinit
@LISP_INIT@
--eval "(setf *terminal-io*
(make-two-way-stream
(make-synonym-stream (quote *standard-input*))
(make-synonym-stream (quote *standard-output*))))"
@DO@
WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@"
@REDIRECTIONS@
RESULT_VARIABLE RESULT)
if(NOT ${RESULT} EQUAL 0)
message(FATAL_ERROR "Failed to execute Lisp process @NAME@")
endif()
| 1,147 | Common Lisp | .cl | 21 | 32.714286 | 100 | 0.426667 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | cc596f796c0d11c9390916a393d22a884fcee343d7cda52719c4490e52c32051 | 25,401 | [
-1
] |
25,409 | CPackInclude.cmake | open-rsx_rsb-cl/cpack/CPackInclude.cmake | if(NOT CPACK_GENERATOR)
set(CPACK_GENERATOR "TGZ")
endif()
set(CPACK_CONFIG_FILE "" CACHE FILEPATH "Path to a CMake lists syntax file providing settings for CPack.")
set(CPACK_PACKAGE_REVISION "" CACHE STRING "A suffix string which can be appended to package versions to account for e. g. multiple rebuilds without changes to the upstream project of the package.")
if(CPACK_CONFIG_FILE)
include(${CPACK_CONFIG_FILE})
endif()
message(STATUS "Using CPack package generator: ${CPACK_GENERATOR}")
include(CPack)
| 520 | Common Lisp | .cl | 10 | 49.8 | 198 | 0.778656 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 060c45fefd4769e0581ec34384274c8d73b39f46166457e660b636dea586276c | 25,409 | [
-1
] |
25,412 | lift-filter-xpath.config | open-rsx_rsb-cl/lift-filter-xpath.config | ;;; Configuration for LIFT tests
;; Settings
(:print-length 100)
(:print-level 50)
(:print-test-case-names t)
;; Suites to run
(rsb.filter.test::xpath-filter-root)
;; Report properties
(:report-property :title "rsb-filter-xpath | Test Results")
(:report-property :relative-to rsb-filter-xpath-test)
(:report-property :full-pathname "test-report-filter-xpath.html/")
(:report-property :format :html)
(:report-property :if-exists :supersede)
(:report-property :style-sheet "test-style.css")
(:build-report)
(:report-property :full-pathname "test-results-filter-xpath.xml")
(:report-property :format :junit)
(:report-property :if-exists :supersede)
(:build-report)
(:report-property :format :describe)
(:report-property :full-pathname *standard-output*)
(:build-report)
| 823 | Common Lisp | .l | 22 | 36.136364 | 66 | 0.715723 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | dfaae21127fb7f3a4c647b32ccec00d75736e387359bc672fee8a2af8b35ff5f | 25,412 | [
-1
] |
25,413 | lift-patterns-request-reply.config | open-rsx_rsb-cl/lift-patterns-request-reply.config | ;;; Configuration for LIFT tests
;; Settings
(:print-length 100)
(:print-level 50)
(:print-test-case-names t)
;; Suites to run
(rsb.patterns.request-reply.test:patterns-request-reply-root)
;; Report properties
(:report-property :title "rsb-patterns-request-reply | Test Results")
(:report-property :relative-to rsb-patterns-request-reply-test)
(:report-property :full-pathname "test-report-patterns-request-reply.html/")
(:report-property :format :html)
(:report-property :if-exists :supersede)
(:report-property :style-sheet "test-style-patterns-request-reply.css")
(:build-report)
(:report-property :full-pathname "test-results-patterns-request-reply.xml")
(:report-property :format :junit)
(:report-property :if-exists :supersede)
(:build-report)
(:report-property :format :describe)
(:report-property :full-pathname *standard-output*)
(:build-report)
| 911 | Common Lisp | .l | 22 | 40.136364 | 76 | 0.733862 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 4169436f4f6527232fc9e76eb4ca013a34f65c0e14b9a65be91f1b8307b831cb | 25,413 | [
-1
] |
25,416 | lift-model.config | open-rsx_rsb-cl/lift-model.config | ;;; Configuration for LIFT tests
;; Settings
(:print-length 100)
(:print-level 50)
(:print-test-case-names t)
;; Suites to run
(rsb.model.test:rsb-model-root)
;; Report properties
(:report-property :title "rsb-model | Test Results")
(:report-property :relative-to rsb-model-test)
(:report-property :full-pathname "test-report-model.html/")
(:report-property :format :html)
(:report-property :if-exists :supersede)
(:report-property :style-sheet "test-style-model.css")
(:build-report)
(:report-property :full-pathname "test-results-model.xml")
(:report-property :format :junit)
(:report-property :if-exists :supersede)
(:build-report)
(:report-property :format :describe)
(:report-property :full-pathname *standard-output*)
(:build-report)
| 796 | Common Lisp | .l | 22 | 34.909091 | 59 | 0.710938 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 84653a5ac8facc6065fca447ac3abce55d2d2d0bd70b8d8fdddab2ee6e99ab1e | 25,416 | [
-1
] |
25,420 | lift-model-builder.config | open-rsx_rsb-cl/lift-model-builder.config | ;;; Configuration for LIFT tests
;; Settings
(:print-length 100)
(:print-level 50)
(:print-test-case-names t)
;; Suites to run
(rsb.model.builder.test:rsb-model-builder-root)
;; Report properties
(:report-property :title "rsb-model-builder | Test Results")
(:report-property :relative-to rsb-model-builder-test)
(:report-property :full-pathname "test-report-model-builder.html/")
(:report-property :format :html)
(:report-property :if-exists :supersede)
(:report-property :style-sheet "test-style-model-builder.css")
(:build-report)
(:report-property :full-pathname "test-results-model-builder.xml")
(:report-property :format :junit)
(:report-property :if-exists :supersede)
(:build-report)
(:report-property :format :describe)
(:report-property :full-pathname *standard-output*)
(:build-report)
| 852 | Common Lisp | .l | 22 | 37.454545 | 67 | 0.722087 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | f1ae0ec345303ed0366ebbf13920be15b07b86820ad2f0c9253e993bbdd96536 | 25,420 | [
-1
] |
25,421 | lift-filter-regex.config | open-rsx_rsb-cl/lift-filter-regex.config | ;;; Configuration for LIFT tests
;; Settings
(:print-length 100)
(:print-level 50)
(:print-test-case-names t)
;; Suites to run
(rsb.filter.test::regex-filter-root)
;; Report properties
(:report-property :title "rsb-filter-regex | Test Results")
(:report-property :relative-to rsb-filter-regex-test)
(:report-property :full-pathname "test-report-filter-regex.html/")
(:report-property :format :html)
(:report-property :if-exists :supersede)
(:report-property :style-sheet "test-style.css")
(:build-report)
(:report-property :full-pathname "test-results-filter-regex.xml")
(:report-property :format :junit)
(:report-property :if-exists :supersede)
(:build-report)
(:report-property :format :describe)
(:report-property :full-pathname *standard-output*)
(:build-report)
| 823 | Common Lisp | .l | 22 | 36.136364 | 66 | 0.715723 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 3e2395321783779b927dece4a2c0b2057dab5113db88e8812f4c9fc844453255 | 25,421 | [
-1
] |
25,424 | .travis.yml | open-rsx_rsb-cl/.travis.yml | language: lisp
dist: xenial
env: PREFIX="$(pwd)/sbcl"
SBCL_HOME="$(pwd)/sbcl/lib/sbcl"
SBCL="$(pwd)/sbcl/bin/sbcl"
SBCL_OPTIONS="--noinform --no-userinit"
install:
- curl -L "${SBCL_DOWNLOAD_URL}" | tar -xj
- ( cd sbcl-* && INSTALL_ROOT="${PREFIX}" sh install.sh )
- curl -o cl "${CL_LAUNCH_DOWNLOAD_URL}"
- chmod +x cl
- curl -o quicklisp.lisp "${QUICKLISP_DOWNLOAD_URL}"
- ./cl -L quicklisp.lisp '(quicklisp-quickstart:install)'
script:
- (
cd "${HOME}/quicklisp/local-projects"
&& git clone https://github.com/scymtym/cl-protobuf
&& git clone https://github.com/scymtym/network.spread
)
- ./cl
-S '(:source-registry (:directory "'$(pwd)'") :ignore-inherited-configuration)'
-Q
-s cl-protobuf
-s rsb-builder/test -s rsb-filter-regex/test
-s rsb-filter-xpath/test -s rsb-introspection/test
-s rsb-model-builder/test -s rsb-model/test
-s rsb-patterns-request-reply/test
-s rsb-transport-inprocess/test
-s rsb-transport-socket/test -s rsb/test
'(or (mapc (function asdf:test-system)
(list :rsb-builder/test :rsb-filter-regex/test
:rsb-filter-xpath/test :rsb-introspection/test
:rsb-model-builder/test :rsb-model/test
:rsb-patterns-request-reply/test
:rsb-transport-inprocess/test
:rsb-transport-socket/test :rsb/test))
(uiop:quit -1))'
| 1,500 | Common Lisp | .l | 37 | 32.378378 | 85 | 0.607265 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b7c55acf35e858df874d0dc477b52eb61d876f5709919f91eb5da76bf57605e9 | 25,424 | [
-1
] |
25,425 | lift-builder.config | open-rsx_rsb-cl/lift-builder.config | ;;; Configuration for LIFT tests
;; Settings
(:print-length 100)
(:print-level 50)
(:print-test-case-names t)
;; Suites to run
(rsb.builder.test:rsb-builder-root)
;; Report properties
(:report-property :title "rsb-builder | Test Results")
(:report-property :relative-to rsb-builder-test)
(:report-property :full-pathname "test-report-builder.html/")
(:report-property :format :html)
(:report-property :if-exists :supersede)
(:report-property :style-sheet "test-style-builder.css")
(:build-report)
(:report-property :full-pathname "test-results-builder.xml")
(:report-property :format :junit)
(:report-property :if-exists :supersede)
(:build-report)
(:report-property :format :describe)
(:report-property :full-pathname *standard-output*)
(:build-report)
| 810 | Common Lisp | .l | 22 | 35.545455 | 61 | 0.716113 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 5aa5c02da47cb9704875cab0ba6cfe23e841e62f095f9d34609c22e249fab809 | 25,425 | [
-1
] |
25,428 | Hello.proto | open-rsx_rsb-cl/data/rsb/protocol/introspection/Hello.proto | /* ============================================================
*
* This file is part of the RSB project.
*
* Copyright (C) 2014 The RSB developers.
*
* This file may be licensed under the terms of the
* GNU Lesser General Public License Version 3 (the ``LGPL''),
* or (at your option) any later version.
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the LGPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the LGPL along with this
* program. If not, go to http://www.gnu.org/licenses/lgpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The development of this software was supported by:
* CoR-Lab, Research Institute for Cognition and Robotics
* Bielefeld University
*
* ============================================================ */
syntax = "proto2";
package rsb.protocol.introspection;
import "rsb/protocol/operatingsystem/Process.proto";
import "rsb/protocol/operatingsystem/Host.proto";
option java_outer_classname = "HelloType";
/**
* Basic introspection information for one RSB participant.
*
* May describe a newly created or an already existing participant.
*
* @author Jan Moringen <[email protected]>
*/
message Hello {
// Participant Information
/**
* Kind of the participant as lowercase string.
*
* Examples: "informer", "listener", "reader", etc.
*/
required string kind = 1;
/**
* ID (a RFC 4122 UUID) of the participant as byte array.
*
* For this encoding, the encoded UUID is 16 bytes long.
*/
// @constraint(len(value) = 16)
required bytes id = 2;
/**
* If present, ID (a RFC 4122 UUID) of the composite participant
* containing the participant as a byte array.
*
* If not present, the participant is not contained in a composite
* participant (it may still be a composite participant and itself
* contain other participants, though)
*
* For this encoding, the encoded UUID is 16 bytes long.
*/
// @constraint(len(value) = 16)
optional bytes parent = 3;
/**
* Scope on which the participant listens, publishes or otherwise
* operates.
*
* @todo proper representation
*/
required string scope = 4;
/**
* Type of data produced or consumed by the participant.
*
* Programming language data-type within the containing program
* for now. For visual inspection only - Do not process.
*
* @todo Preliminary: will change to a proper representation
*/
optional string type = 5;
/**
* A list of strings describing transports of the participant.
*
* @todo Preliminary: will change.
*/
repeated string transport = 6;
// Process Information
/**
* Information about the process containing the participant.
*/
required .rsb.protocol.operatingsystem.Process process = 7;
// Host Information
/**
* Host on which the containing process executes.
*/
required .rsb.protocol.operatingsystem.Host host = 8;
}
| 3,498 | Common Lisp | .l | 97 | 31.804124 | 70 | 0.619681 | open-rsx/rsb-cl | 1 | 0 | 5 | LGPL-3.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | feb8c00cb9d1bb5e4ff9d11e163898a4aed78bf401eb0637b787631fe3c025d2 | 25,428 | [
-1
] |
25,675 | utilities.lsp | arturocaissut_hofstadter-sequences/utilities.lsp | ;;; Various utilities
;; Plotting
(defun plot (fn min max step)
"A quick and dirty way to plot functions"
(loop for i from min to max by step do
(loop repeat (funcall fn i) do (format t "*"))
(format t "~%")))
(defun fixedplot (fn)
"An even dirtier way to plot functions (fixed min/max values, fixed step)"
(plot fn 0 20 1)) | 336 | Common Lisp | .l | 10 | 31.5 | 75 | 0.693498 | arturocaissut/hofstadter-sequences | 1 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | 451a1496bd20320b7d1ca7ac00d5cb4b38585243c32543aee9c825234bc09a03 | 25,675 | [
-1
] |
25,676 | hofstadter-sequences.lsp | arturocaissut_hofstadter-sequences/hofstadter-sequences.lsp | ;;; The Hofstadter Sequences (plus utilities)
;; TODO Write assert where needed
(defun hofstadter-g (n)
"Hofstadter G sequence"
(if (< n 1)
0
(- n (hofstadter-g (hofstadter-g (- n 1))))))
(defun hofstadter-h (n)
"Hofstadter H sequence"
(if (< n 1)
0
(- n (hofstadter-h (hofstadter-h (hofstadter-h (- n 1)))))))
(defun hofstadter-u (n)
"Hofstadter U sequence (The sequence formerly known as Q sequence)"
(if (< n 3)
1
(+ (hofstadter-u (- n (hofstadter-u (- n 1)))) (hofstadter-u (- n (hofstadter-u (- n 2)))))))
;; TODO Write a macro to define the two sequences in one time
(defun hofstadter-f (n)
"Hofstadter Female sequence"
(if (< n 1)
1
(- n (hofstadter-m (hofstadter-f (- n 1))))))
(defun hofstadter-m (n)
"Hofstadter Male sequence"
(if (< n 1)
0
(- n (hofstadter-f (hofstadter-m (- n 1))))))
(defun hofstadter-conway (n)
"Hofstadter-Conway $10000 sequence"
(if (< n 3)
1
(+ (hofstadter-conway (hofstadter-conway (- n 1))) (hofstadter-conway (- n (hofstadter-conway (- n 1)))))))
;; TODO Make the next two functions macros
(defun hofstadter-q (n &optional (r 1) (s 4 #|2|#))
"A macro to generate Hofstadter-Q sequences (given r and s parameters). The default case reverts to the Hofstadter U sequence (the original Q sequence)."
;; Put a bunch of asserts here
(if (<= 1 n s)
1
(+ (hofstadter-q (- n (hofstadter-q (- n r) r s)) r s) (hofstadter-q (- n (hofstadter-q (- n s) r s)) r s))))
;; NOTE: The generalized formula needs to be checked, sources unclear. Default values are good, however it's not usable for i,j values different than 0,1
(defun hofstadter-pinn (n &optional (i 0) (j 1 #|0|#))
"A macro to generate Hofstadter-Pinn sequences (given i and j parameters). The default case reverts to the Hofstadter U sequence (the original Q sequence)."
;; Put a bunch of asserts here
(if (< n 3)
1
(+ (hofstadter-pinn #|(- n i |#(hofstadter-pinn (- n 1) i j)#|)|# i j) (hofstadter-pinn (- n (hofstadter-pinn (- n 2) i j) j) i j))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Test functions
(defmacro test (seq &optional (n 15))
"A (somehow silly) macro to test the sequences"
`(loop for i from 0 to ,n do (format t "~a ~d: ~d~%" ',seq i (,seq i))))
;; TODO Convert into a macro-writing macro
(defun test-sequence (seq &optional (n 15))
(format t "~a, first ~d values: " (cadr seq) n )
(loop for i from 1 to n do (format t "~a "(funcall seq i)))
(format t "~%"))
;; TODO Make this a macro and/or optimize it
(defun test-all (&optional (n 15))
(format t "Testing Hofstadter sequences")
(format t "~%")
(test-sequence #'hofstadter-g n)
(format t "~%")
(test-sequence #'hofstadter-h n)
(format t "~%")
(test-sequence #'hofstadter-u n)
(format t "~%")
(test-sequence #'hofstadter-q n)
(format t "~%")
(test-sequence #'hofstadter-f n)
(format t "~%")
(test-sequence #'hofstadter-m n)
(format t "~%")
(test-sequence #'hofstadter-conway n)
(format t "~%")
(test-sequence #'hofstadter-pinn n)
(format t "~%"))
| 3,042 | Common Lisp | .l | 77 | 37.142857 | 157 | 0.640312 | arturocaissut/hofstadter-sequences | 1 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | b06c6ac85c2819ea0c4f7969e0671da406d795902e07071759560bb11be9782f | 25,676 | [
-1
] |
25,693 | package.lisp | foss-santanu_simut/package.lisp | ;;;; package.lisp
(in-package #:cl-user)
(defpackage #:simut
(:use #:cl)
(:export #:*global-test-suite*
#:*global-test-results*
#:create-fixture
#:create-unit-test
#:run-test
#:run-suite
#:run-all))
(defpackage #:test-simut
(:use #:cl #:simut)
(:shadowing-import-from #:simut)) | 354 | Common Lisp | .lisp | 14 | 18.857143 | 35 | 0.547337 | foss-santanu/simut | 1 | 0 | 0 | GPL-2.0 | 9/19/2024, 11:28:28 AM (Europe/Amsterdam) | a2bef05dd01b4b9ee2753cdecf9dab1e3a6d14766c6cbbb792ca5caadb8f101c | 25,693 | [
-1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.