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
37,332
orders-of-magnitude.lisp
open-rsx_rsb-tools-cl/src/formatting/orders-of-magnitude.lisp
;;;; orders-of-magnitude.lisp --- Determining and printing orders of magnitude. ;;;; ;;;; Copyright (C) 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) (define-constant +orders-of-magnitude+ (mapcar (lambda+ ((exponent long short)) (list (expt 10 exponent) long short)) `((-15 "~@[ ~*~]femto~@[~A~P~]" "~@[ ~*~]f~@[~A~]") (-12 "~@[ ~*~]pico~@[~A~P~]" "~@[ ~*~]p~@[~A~]") ( -9 "~@[ ~*~]nano~@[~A~P~]" "~@[ ~*~]n~@[~A~]") ( -6 "~@[ ~*~]micro~@[~A~P~]" "~@[ ~*~]µ~@[~A~]") ( -3 "~@[ ~*~]milli~@[~A~P~]" "~@[ ~*~]m~@[~A~]") ( 0 "~@[ ~*~]~@[~A~P~]" "~@[ ~*~] ~@[~A~]") ( 3 "~@[ ~*~]kilo~@[~A~P~]" "~@[ ~*~]K~@[~A~]") ( 6 "~@[ ~*~]mega~@[~A~P~]" "~@[ ~*~]M~@[~A~]") ( 9 "~@[ ~*~]giga~@[~A~P~]" "~@[ ~*~]G~@[~A~]") ( 12 "~@[ ~*~]tera~@[~A~P~]" "~@[ ~*~]T~@[~A~]") ( 15 "~@[ ~*~]exo~@[~A~P~]" "~@[ ~*~]E~@[~A~]"))) :test #'equal) (define-constant +non-negative-orders-of-magnitude+ (subseq +orders-of-magnitude+ 5) :test #'equal) (define-constant +duration-orders-of-magnitude+ `(,@(subseq +orders-of-magnitude+ 0 6) (60 "~@[ ~*~]~*minute~P" "~* m~2*") (,(* 60 60) "~@[ ~*~]~*hour~P" "~* h~2*") (,(* 24 60 60) "~@[ ~*~]~*day~P" "~* d~2*") ;; Months are uncommon for this ;; (,(* 30 24 60 60) "~@[ ~*~]~*month~P" "~@[ ~*~]M ~2*") (,(* 365 24 60 60) "~@[ ~*~]~*year~P" "~* y~2*")) :test #'equal) (defun human-readable-value-and-suffix (value table) ;; Test dividing VALUE by successively larger factors in TABLE until ;; the result is in the desirable range or TABLE runs out. (iter (with value = (rationalize value)) (with zero? = (zerop value)) (for ((factor1 long short) (factor2)) :on table) (for (values quotient remainder) = (round value factor1)) ;; If the quotient is in the desirable range, stop the ;; search and return. (cond ;; Special-case the value 0. ((and zero? (= 1 factor1)) (return (values t 0 short long))) ;; QUOTIENT is in the desirable range [0, 9] => return. ((and (not zero?) (<= 0 quotient 9)) (return (values (zerop remainder) (/ value factor1) short long))) ;; If QUOTIENT is in the desirable range ;; ]9, <smallest value that would result in >= 1 w.r.t. FACTOR2>[ ;; => return. If not, check the other reasons for ;; returning and maybe return. ((or (not factor2) ; this is the last available factor (and (not zero?) (zerop quotient)) ; VALUE is too small for available factors (< 9 quotient (/ factor2 factor1))) ; < 1 for w.r.t next factor (return (values t quotient short long)))))) (defun print-human-readable-value (stream value &key (orders-of-magnitude +orders-of-magnitude+) signum? space? unit long?) (if (realp value) (let+ (((&values integer? value1 short-format long-format) (human-readable-value-and-suffix (abs value) orders-of-magnitude)) (signum (when signum? (signum value)))) (format stream "~[~;-~; ~;+~]~:[~,1F~;~3D~]~?" (if signum (+ (floor signum) 2) 0) integer? value1 (if long? long-format short-format) (list space? unit value1))) (let ((width (+ (if signum? 1 0) 3 1 (length unit)))) (format stream "~V@A" width value)))) (macrolet ((define-print-function (suffix &key table unit) (let ((name (symbolicate 'print-human-readable- suffix))) `(defun ,name (stream value &optional colon? at?) (let (,@(when unit `((unit (if at? ,@unit))))) (print-human-readable-value stream value ,@(when table `(:orders-of-magnitude ,table)) ,@(when unit `(:unit unit)) :signum? colon? :space? at? :long? at?)))))) (define-print-function order-of-magnitude) (define-print-function count :table +non-negative-orders-of-magnitude+) (define-print-function size :table +non-negative-orders-of-magnitude+ :unit ("Byte" "B")) (define-print-function duration :table +duration-orders-of-magnitude+ :unit ("second" "s")))
4,562
Common Lisp
.lisp
90
40.822222
92
0.499104
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4af4ad41107052bb52ede2b41c865ca6a757935a3014b327142124fedd991cee
37,332
[ -1 ]
37,333
variables.lisp
open-rsx_rsb-tools-cl/src/formatting/variables.lisp
;;;; variables.lisp --- Variables used in the formatting module. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) (defvar *output-unicode?* #-win32 t #+win32 nil "Controls whether the full Unicode range of characters (as opposed to ASCII) can be used in textual output.")
390
Common Lisp
.lisp
9
41.555556
68
0.720317
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f2a61bba903009171b6dd69e0fac3469f130398ad836c9627e360d3e99ed0aff
37,333
[ -1 ]
37,334
columns.lisp
open-rsx_rsb-tools-cl/src/formatting/columns.lisp
;;;; columns.lisp --- Some column classes. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) ;;; `basic-column' (defclass basic-column () ((name :initarg :name :type string :accessor column-name :documentation "Stores the name of the column.")) (:default-initargs :name (missing-required-initarg 'basic-column :name)) (:documentation "Superclass for column classes.")) (defmethod format-header ((column basic-column) (stream t)) (format stream "~@(~A~)" (column-name column))) ;;; Simple columns (macrolet ((define-simple-column ((name width &key (event-class 'event) (print-name (string name)) (access '())) &body doc-and-body) (let+ (((&optional width (alignment :right) priority) (ensure-list width)) (class-name (symbolicate "COLUMN-" name)) ((&values body nil doc) (parse-body doc-and-body :documentation t))) `(progn (defclass ,class-name (,@(when width '(width-specification-mixin width-mixin)) basic-column) () (:default-initargs :name ,print-name ,@(when width `(:widths ',width :alignment ,alignment)) ,@(when priority `(:priority ,priority))) ,@(when doc `((:documentation ,doc)))) (service-provider:register-provider/class 'column ,name :class ',class-name) ,@(mapcar (lambda (part) `(defmethod rsb.ep:access? ((column ,class-name) (part (eql ',part)) (mode (eql :read))) t)) access) ,@(unless width `((defmethod column-width ((column ,class-name)) 0))) (defmethod format-event ((event ,event-class) (column ,class-name) (stream t) &key) ,@body))))) ;; Output control (define-simple-column (:same-line nil :event-class t) "Put carriage at beginning of the current line, causing the current content to be overridden by subsequent output." (format stream "~C" #\Return)) (define-simple-column (:newline nil :event-class t) "Start a new line of output." (terpri stream)) (define-simple-column (:flush nil :event-class t) "Flush buffers of the output stream." (force-output stream)) ;; Event-independent (define-simple-column (:now ((15 32) :right 1.5) :event-class t) "Emit the current time in either full or compact format." (print-timestamp stream (local-time:now) (< (column-width column) 32))) (define-simple-column (:text 32 :event-class t) "Emit a given text. The name of the column is also the emitted text." (format stream "~A" (column-name column))) ;; Event properties (define-simple-column (:origin ((8 36) :left 1.5) :access (:origin)) "Emit an abbreviated representation of the id of the participant at which the event originated." (if (>= (column-width column) 36) (format stream "~:[ORIGIN? ~;~:*~:/rsb::print-id/~]" (event-origin event)) (format stream "~:[ORIGIN? ~;~:*~/rsb::print-id/~]" (event-origin event)))) (define-simple-column (:sequence-number 8 :print-name "Sequence Number" :access (:sequence-number)) "Emit the sequence number of the event." (format stream "~8,'0X" (event-sequence-number event))) (define-simple-column (:method (10 :left) :access (:method)) "Emit the method of the event. If the event does not have an id, the string \"<nomethod>\" is emitted instead." (format stream "~:[<nomethod>~;~:*~:@(~10A~)~]" (event-method event))) (define-simple-column (:id ((8 36) :left 1) :access (:id)) "Emit an abbreviated representation of the id of the event." (if (>= (column-width column) 36) (format stream "~:[EVENTID? ~;~:*~:/rsb::print-id/~]" (event-id event)) (format stream "~:[EVENTID? ~;~:*~/rsb::print-id/~]" (event-id event)))) (define-simple-column (:scope ((:range 8) :left) :access (:scope)) "Emit the scope of the event." (format stream "~A" (scope-string (event-scope event)))) (define-simple-column (:wire-schema ((:range 8) :left) :access (:meta-data)) "Emit wire-schema of the event, if possible." (format stream "~:[WIRE-SCHEMA?~;~:*~A~]" (meta-data event :rsb.transport.wire-schema))) (define-simple-column (:data ((:range 8) :left) :access (:data)) "Emit a representation of the data contained in the event." (let ((*print-length* (column-width column))) (format stream "~/rsb::print-event-data/" (event-data event)))) (define-simple-column (:data-size 5 :print-name "Data Size" :access (:data :meta-data)) "Emit an indication of the size of the data contained in the event, if the size can be determined." (print-human-readable-size stream (event-size event :n/a))) (define-simple-column (:notification-size 5 :print-name "Notification Size" :access (:meta-data)) "Emit an indication of the size of the notification in which the event has been transmitted, if the size can be determined." (print-human-readable-size stream (or (meta-data event :rsb.transport.notification-size) :n/a))) ;; Request/Reply stuff (define-simple-column (:call ((:range 26) :left) :access (:method :data)) "Emit a method call description. Should only be applied to events that actually are method calls." (let ((*print-length* most-positive-fixnum)) (format stream "~/rsb.formatting::format-method/(~/rsb::print-event-data/)" event (event-data event)))) (define-simple-column (:call-id ((8 36) :left 1) :access (:causes)) "Emit the request id of a reply event. Should only be applied to events that actually are replies to method calls." (let ((call-id (when-let ((cause (first (event-causes event)))) (event-id->uuid cause)))) (if (>= (column-width column) 36) (format stream "~:[CALLID? ~;~:*~:/rsb::print-id/~]" call-id) (format stream "~:[CALLID? ~;~:*~/rsb::print-id/~]" call-id)))) (define-simple-column (:result ((:range 26) :left) :access (:method :data)) "Emit a method reply description. Should only be applied to events that actually are replies to method calls." (let ((*print-length* most-positive-fixnum)) (format stream "> ~/rsb.formatting::format-method/ ~ ~:[=>~;ERROR:~] ~/rsb::print-event-data/" event (error-event? event) (event-data event))))) ;;; Constant column (defclass column-constant (width-specification-mixin width-mixin basic-column) ((value :initarg :value :accessor column-value :documentation "Stores the constant value emitted by the column.") (formatter :initarg :formatter :type function :accessor column-formatter :initform #'princ :documentation "Stores a function that is called to print the value of the column onto a destination stream.")) (:default-initargs :value (missing-required-initarg 'column-constant :value)) (:documentation "Instances of this column class emit a print a specified constant value.")) (service-provider:register-provider/class 'column :constant :class 'column-constant) (defmethod column< ((left column-constant) (right column-constant)) (value< (column-value left) (column-value right))) (defmethod format-event ((event t) (column column-constant) (stream t) &key) (funcall (column-formatter column) (column-value column) stream)) ;;; Timestamp and meta-data columns (macrolet ((define-meta-data-column ((name &key (width 32))) (let ((class-name (intern (string name)))) `(progn (defclass ,class-name (width-specification-mixin width-mixin basic-column) ((key :initarg :key :type symbol :reader column-key :documentation "Stores the key of the meta-data item that should be extracted from events.")) (:default-initargs :name "" :key (missing-required-initarg ',class-name :key) :widths ,width :alignment :left) (:documentation ,(format nil "Emit the ~(~A~) of the event designated by ~ the value of the :key initarg." name))) (service-provider:register-provider/class 'column ,name :class ',class-name) (defmethod shared-initialize :after ((instance ,class-name) (slot-names t) &key name) (setf (column-name instance) (format nil "~@(~@[~A~]~A~)" name (column-key instance)))) (defmethod rsb.ep:access? ((processor ,class-name) (part (eql ,name)) (mode (eql :read))) t))))) (define-meta-data-column (:timestamp :width '(15 32))) (define-meta-data-column (:meta-data))) (defmethod format-event ((event event) (column timestamp) (stream t) &key) (print-timestamp stream (timestamp event (column-key column)) (< (column-width column) 32))) (defmethod format-event ((event event) (column meta-data) (stream t) &key) (format stream "~:[N/A~;~:*~A~]" (meta-data event (column-key column)))) ;;; Count column (defclass column-count (width-specification-mixin width-mixin basic-column) ((count :initarg :count :type non-negative-integer :accessor column-count :initform 0 :documentation "Stores the number of performed output operations.")) (:default-initargs :width 8 :name "Count") (:documentation "Count the number of output operations and emit that number.")) (service-provider:register-provider/class 'column :count :class 'column-count) (defmethod format-event ((event t) (column column-count) (stream t) &key) (format stream "~:D" (incf (column-count column)))) ;;; Some useful column and style specifications ;;; ;;; For use in `columns-mixin' and subclasses such as ;;; `style-compact/*' `style-statistics/*' and `style-monitor/*'. (defvar *human-readable-count-format* "~/rsb.formatting:print-human-readable-count/") (defvar *human-readable-size-format* "~/rsb.formatting:print-human-readable-size/") (defvar *human-readable-duration-moments-format* "~:/rsb.formatting:print-human-readable-duration/ ~ ± ~/rsb.formatting:print-human-readable-duration/") (defvar *human-readable-size-moments-format* "~/rsb.formatting:print-human-readable-size/ ~ ± ~/rsb.formatting:print-human-readable-size/") (defvar *generic-histogram-format* "~:[~ N/A~ ~;~:*~ ~{~{~A: ~/rsb.formatting:print-human-readable-count/~}~^, ~}~ ~]") (defvar *origin-histogram-format* "~:[~ N/A~ ~;~:*~ ~{~{~/rsb::print-id/: ~/rsb.formatting:print-human-readable-count/~}~^, ~}~ ~]") (defvar *basic-columns* `(;; Event Properties (:now . (:now :priority 1.5)) (:receive . (:timestamp :key :receive :priority 1.5)) (:wire-schema . (:wire-schema :priority 2.4)) ;; Quantities (:rate . (:quantity :quantity (:rate :format ,*human-readable-count-format*) :widths 4)) (:throughput . (:quantity :quantity (:throughput :format ,*human-readable-size-format*) :widths 5)) (:latency . (:quantity :quantity (:expected :name "Latency" :target (:latency :from :send :to :receive :format ,*human-readable-duration-moments-format*) :expected (:type (or (eql :n/a) (real (0) 0.010)))) :widths 14 :priority 2.2)) (:origin/40 . (:quantity :quantity (:origin :format ,*origin-histogram-format*) :widths (:range 40) :alignment :left)) (:scope/40 . (:quantity :quantity (:scope :format ,*generic-histogram-format*) :widths (:range 40) :alignment :left)) (:method/20 . (:quantity :quantity (:method :format ,*generic-histogram-format*) :widths (:range 20) :priority 1.8 :alignment :left)) (:type/40 . (:quantity :quantity (:type :format ,*generic-histogram-format*) :widths (:range 40) :alignment :left)) (:size . (:quantity :quantity (:size :format ,*human-readable-size-moments-format*) :widths 13))) "Contains an alist of column specification entries of the form (NAME . SPEC) where NAME names the column specification SPEC. See `columns-mixin' for information regarding the processing of SPEC.") (defun expand-column-spec (spec &optional (templates *basic-columns*)) (let+ (((&flet find-template (name) (cdr (assoc name templates))))) (typecase spec (keyword (or (find-template spec) spec)) (cons (let+ (((name &rest args) spec)) (if-let ((template (find-template name))) `(,(first template) ,@args ,@(rest template)) spec))) (t spec))))
15,987
Common Lisp
.lisp
348
31.956897
94
0.513732
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3b3d9cb30372175e532944a8f704f4e63503a9f2ba73ba41a80d34be364ec51c
37,334
[ -1 ]
37,335
style-mixins.lisp
open-rsx_rsb-tools-cl/src/formatting/style-mixins.lisp
;;;; style-mixins.lisp --- Mixin classes for formatting style classes. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) ;;; `counting-mixin' (defclass counting-mixin () ((count :initarg :count :type non-negative-integer :accessor style-count :initform 0 :documentation "Stores the number of output cycles already performed by the formatter.")) (:documentation "This class is intended to be mixed into formatter classes that need keep track of the number of performed output cycles.")) (defmethod format-event :after ((event t) (style counting-mixin) (stream t) &key) (incf (style-count style))) ;;; `activity-tracking-mixin' (defclass activity-tracking-mixin () ((last-activity :initarg :last-activity :type (or null local-time:timestamp) :accessor style-last-activity :initform nil :documentation "Unless nil, time of most recent activity on the style object.")) (:documentation "Allows storing the time of the most recent activity on the style object.")) (defmethod format-event :around ((event t) (style activity-tracking-mixin) (stream t) &key) (unless (eq event :trigger) (setf (style-last-activity style) (local-time:now))) (call-next-method)) ;;; `delegating-mixin' (defclass delegating-mixin () ((sub-styles :initarg :sub-styles :type list :accessor style-sub-styles :initform '() :documentation "Stores predicates and corresponding sub-styles as an alist of items of the form (PREDICATE . SUB-STYLE).")) (:documentation "This class is intended to be used in formatting classes that delegate to sub-styles based on dispatch predicates.")) (defmethod rsb.ep:access? ((processor delegating-mixin) (part t) (mode t)) (some (compose (rcurry #'rsb.ep:access? part mode) #'cdr) (style-sub-styles processor))) (defmethod sub-style-for ((style delegating-mixin) (event t)) "Return a list of sub-styles of STYLE whose predicates succeed on EVENT." (map 'list #'cdr (remove-if (complement (rcurry #'funcall event)) (style-sub-styles style) :key #'car))) (defmethod delegate ((event t) (style delegating-mixin) (stream t)) (let+ (((&labels apply-style (style-or-styles) (typecase style-or-styles (sequence (map nil #'apply-style style-or-styles)) (t (format-event event style-or-styles stream)))))) (map nil #'apply-style (sub-style-for style event)))) (defmethod format-event ((event t) (style delegating-mixin) (stream t) &key) "Delegate formatting of EVENT on STREAM to appropriate sub-styles of STYLE." (delegate event style stream)) (defmethod print-object ((object delegating-mixin) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "(~D)" (length (style-sub-styles object))))) ;;; `sub-style-grouping-mixin' (defclass sub-style-grouping-mixin (delegating-mixin) ((key :initarg :key :type function :accessor style-key :initform #'identity :documentation "Stores a function that is called on events to derive key objects which identify the sub-style that should be used for the respective events.") (test :initarg :test :type function :accessor style-test :initform #'eql :documentation "Stores a function which is used to compare keys when searching for the sub-style that should be used for a particular events.")) (:documentation "This mixin class add to `delegating-mixin' the ability to dynamically create sub-styles and dispatch to these based on properties of events. Creation of and dispatching to sub-styles is based on the usual key/test mechanism for extracting a key from events and testing it against previously extracted key. A new sub-style is created and added whenever the key extracted from an event does not match the key of any previously created sub-styles.")) (defmethod sub-style-for ((style sub-style-grouping-mixin) (event t)) ;; If there is a sub-style suitable for handling EVENT, dispatch to ;; it. Otherwise create a new sub-style and then dispatch to it. (or (call-next-method) (let ((key (funcall (style-key style) event))) (when-let ((sub-style (make-sub-style-entry style key))) (push sub-style (style-sub-styles style)) (call-next-method))))) (defmethod format-event :around ((event t) (style sub-style-grouping-mixin) (stream t) &key) (if (eq event :trigger) (call-next-method) (delegate event style stream))) ;;; `sub-style-sorting-mixin' (defclass sub-style-sorting-mixin (delegating-mixin) ((sort-predicate :initarg :sort-predicate :type function :accessor style-sort-predicate :documentation "Stores the predicate according to which sub-styles should be sorted when retrieved as a sorted list.") (sort-key :initarg :sort-key :type function :accessor style-sort-key :documentation "Stores the key reader that should be used when sorting sub-styles.")) (:default-initargs :sort-predicate (missing-required-initarg 'sub-style-sorting-mixin :sort-predicate) :sort-key (missing-required-initarg 'sub-style-sorting-mixin :sort-key)) (:documentation "This mixin adds to delegating formatting style classes the ability to retrieve sub-styles sorted according to a predicate.")) (defmethod style-sub-styles/sorted ((style sub-style-sorting-mixin) &key (predicate (style-sort-predicate style)) (key (style-sort-key style))) (sort (map 'list #'cdr (style-sub-styles style)) predicate :key key)) ;;; `sub-style-pruning-mixin' (defclass sub-style-pruning-mixin () ((prune-predicate :initarg :prune-predicate :type (or null function) :accessor style-prune-predicate :initform nil :documentation "Stores a function that is called with a sub-style as its sole argument to determine whether the sub-style should be removed from the list of sub-styles.")) (:documentation "This mixin class adds pruning of dynamically created sub-styles based on a prune predicate.")) (defmethod prune-sub-styles ((style sub-style-pruning-mixin)) (let+ (((&structure style- sub-styles prune-predicate) style)) (when prune-predicate (setf sub-styles (remove-if prune-predicate sub-styles :key #'cdr))))) (defmethod format-event :before ((event (eql :trigger)) (style sub-style-pruning-mixin) (stream t) &key) (prune-sub-styles style)) ;;; `activity-based-sub-style-pruning-mixin' (defclass activity-based-sub-style-pruning-mixin (sub-style-pruning-mixin) () (:documentation "Specialization of `sub-style-pruning-mixin' which constructs a prune predicate that compares activity times queried via `style-last-activity' against a given threshold.")) (defmethod shared-initialize :after ((instance activity-based-sub-style-pruning-mixin) (slot-names t) &key (prune-after 240 prune-after-supplied?) (prune-predicate (when prune-after (prune-after prune-after)) prune-predicate-supplied?)) (when (and prune-after-supplied? prune-predicate-supplied?) (incompatible-initargs 'activity-based-sub-style-pruning-mixin :prune-after prune-after :prune-predicate prune-predicate)) (setf (style-prune-predicate instance) prune-predicate)) ;; Utility functions (defun prune-after (inactive-time) "Return a pruning predicate which marks sub-styles for pruning when the have been inactive for INACTIVE-TIME seconds." (lambda (sub-style) (if-let ((activity (style-last-activity sub-style))) (> (local-time:timestamp-difference (local-time:now) activity) inactive-time) t))) ;;; `timestamp-mixin' (defclass timestamp-mixin () ((timestamp :type function :accessor style-timestamp :writer (setf style-%timestamp) :documentation "Stores a function which extracts and returns a specific timestamp from a given event.")) (:default-initargs :timestamp :send) (:documentation "This mixins stores a function which extracts a given timestamp from events. It is intended to be mixed into style classes which extract a configurable timestamp from processed events.")) (defmethod shared-initialize :after ((instance timestamp-mixin) (slot-names t) &key (timestamp nil timestamp-supplied?)) (when timestamp-supplied? (setf (style-timestamp instance) timestamp))) (defmethod (setf style-timestamp) ((new-value symbol) (style timestamp-mixin)) (setf (style-%timestamp style) (lambda (event) (timestamp->unix/nsecs (timestamp event new-value)))) new-value) ;;; `temporal-bounds-mixin' (defclass temporal-bounds-mixin () ((lower-bound :initarg :lower-bound :type time-spec :accessor lower-bound :initform '(- :now 20) :documentation "Stores a specification of the lower bound of the temporal interval of interest. See type `time-spec'.") (upper-bound :initarg :upper-bound :type time-spec :accessor upper-bound :initform :now :documentation "Stores a specification of the upper bound of the temporal interval of interest. See type `time-spec'.")) (:documentation "This mixin adds lower and upper temporal bounds which can be provided in the form of abstract specifications. Realizations of these specifications can be retrieved for concrete points in time.")) (defmethod shared-initialize :after ((instance temporal-bounds-mixin) (slot-names t) &key) (check-bounds-spec (bounds instance))) (defmethod bounds ((thing temporal-bounds-mixin)) (list (lower-bound thing) (upper-bound thing))) (defmethod (setf bounds) :before ((new-value list) (thing temporal-bounds-mixin)) (check-bounds-spec new-value)) (defmethod (setf bounds) ((new-value list) (thing temporal-bounds-mixin)) (setf (lower-bound thing) (first new-value) (upper-bound thing) (second new-value))) (defmethod bounds/expanded ((thing temporal-bounds-mixin) &optional now) (%expand-bounds-spec (bounds thing) now)) (defmethod range/expanded ((thing temporal-bounds-mixin)) (let+ (((lower upper) (bounds/expanded thing 0))) (- upper lower))) ;; Utility functions (defun check-bounds (thing) (unless (typep thing 'bounds) (error 'type-error :datum thing :expected-type 'bounds))) (defun check-bounds-spec (thing) (unless (and (typep thing 'bounds-spec) (let+ (((lower upper) (%expand-bounds-spec thing 0)) (min (min lower upper)) (lower (- lower min)) (upper (- upper min))) (typep (list lower upper) 'bounds))) (error 'type-error :datum thing :expected-type 'bounds-spec))) (defun %expand-now (now) (let ((raw (etypecase now (null (local-time:now)) (function (funcall now)) (local-time:timestamp now) (integer now)))) (etypecase raw (local-time:timestamp (timestamp->unix/nsecs raw)) (integer raw)))) (defun %expand-bounds-spec (spec &optional now) "Translate SPEC into two absolute timestamps of type `timestamp/unix/nsec' and return a list of the two. If the translation requires the current time, NOW is called without arguments to retrieve it." (let+ (((lower upper) spec) now* ((&flet now () (or now* (setf now* (%expand-now now)))))) (values (list (%expand-time-spec lower #'now) (%expand-time-spec upper #'now)) now*))) (defun %expand-time-spec (spec now) "Translate SPEC into an absolute timestamp of type `timestamp/unix/nsec' and return the timestamp. If the translation requires the current time, NOW is called without arguments to retrieve it." (etypecase spec ((eql :now) (%expand-now now)) ((cons (member + - * /)) (apply (first spec) (mapcar (rcurry #'%expand-time-spec now) (rest spec)))) (real (floor spec 1/1000000000)))) ;;; `payload-style-mixin' (defclass payload-style-mixin () ((payload-style :reader style-payload-style :writer (setf style-%payload-style) :documentation "Stores a style instance which should be used to format payloads.")) (:documentation "This class is intended to be mixed into style classes that process event payloads.")) (defmethod shared-initialize :after ((instance payload-style-mixin) (slot-names t) &key payload-style) (when payload-style (setf (style-%payload-style instance) (ensure-style payload-style)))) (defmethod rsb.ep:access? ((processor payload-style-mixin) (part (eql :data)) (mode (eql :read))) (when (style-payload-style processor) t)) (defmethod format-event ((event event) (style payload-style-mixin) (stream t) &key) (format-payload (event-data event) (style-payload-style style) stream)) ;;; `output-forcing-mixin' (defclass output-forcing-mixin () () (:documentation "This class is intended to be mixed into style classes that have to force output on the target stream after formatting an event.")) (defmethod format-event :after ((event t) (style output-forcing-mixin) (stream stream) &key) (force-output stream))
16,055
Common Lisp
.lisp
366
32.898907
78
0.587098
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b825bbae9f2f325c5697dd7f333b82800a796b5558f82a1c3e51ec4db38f5706
37,335
[ -1 ]
37,336
event-style-programmable.lisp
open-rsx_rsb-tools-cl/src/formatting/event-style-programmable.lisp
;;;; event-style-progammable.lisp --- A programmable formatting style. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) ;;; Compilation protocol (defgeneric compile-code (style code bindings) (:documentation "Compile CODE using BINDINGS for use with STYLE and return the resulting compiled function.")) ;;; Utility functions (defmacro with-interpol-syntax (() &body body) "Execute BODY with interpol syntax enabled." `(unwind-protect (progn (interpol:enable-interpol-syntax) ,@body) (interpol:disable-interpol-syntax))) (defvar *style-programmable-default-bindings* `((count %count) (sequence-number (event-sequence-number %event)) (id (princ-to-string (event-id %event))) (scope (scope-string (event-scope %event))) (origin (event-origin %event)) (method (event-method %event)) (data (event-data %event)) ,@(iter (for timestamp in '(create send receive deliver)) (collect `(,timestamp (timestamp %event ,(make-keyword timestamp)))) (collect `(,(symbolicate timestamp "-UNIX") (timestamp->unix (timestamp %event ,(make-keyword timestamp))))) (collect `(,(symbolicate timestamp "-UNIX/NSEC") (timestamp->unix/nsec (timestamp %event ,(make-keyword timestamp)))))) (causes/event-id (event-causes %event)) (causes/uuid (map 'list #'event-id->uuid (event-causes %event))) (skip-event (throw 'skip-event nil))) "A list of default bindings available in instances of `style-programmable' and subclasses. Entries are like `cl:let' bindings, that is (VARIABLE FORM) where FORM is evaluated to produce the value of VARIABLE.") (defvar *style-programmable-default-binding-access-info* '((:scope . (event scope)) (:origin . (event origin id)) (:sequence-number . (event sequence-number id)) (:method . (event method)) (:data . (event data)) (:timestamp . (event create create-unix create-unix/nsec send send-unix send-unix/nsec receive receive-unix receive-unix/nsec deliver deliver-unix deliver-unix/nsec)) (:meta-data . (event)) (:cause . (event causes/event-id causes/uuid)))) (defclass style-programmable () ((bindings :initarg :bindings :type list :accessor style-bindings :accessor style-%bindings :initform *style-programmable-default-bindings* :documentation "Stores the bindings available in the output format specification.") (lambda :type function :accessor style-%lambda :documentation "Stores the compiled output formatting function for the style instance.") (code :type list :accessor style-code :accessor style-%code :documentation "Stores the code producing the output of the style instance.") (used-bindings :accessor style-%used-bindings :initform '() :documentation "Stores a list of names of bindings used in the code.")) (:default-initargs :code (missing-required-initarg 'style-programmable :code)) (:documentation "This formatting style produces its output by executing a supplied code. The supplied code can rely on `stream' to be bound to a character output stream which it should use for producing the output. By default, the following bindings are available: ")) (defmethod shared-initialize :after ((instance style-programmable) (slot-names t) &key (bindings nil bindings-supplied?) (code nil code-supplied?)) (when bindings-supplied? (check-type bindings list "a list of items of the form (SYMBOL FORM)")) (when code-supplied? (setf (style-code instance) code))) (flet ((recompile (style code bindings) (setf (values (style-%lambda style) (style-%used-bindings style)) (compile-code style code bindings)))) (defmethod (setf style-code) :before ((new-value t) (style style-programmable)) (recompile style new-value (style-%bindings style)) new-value) (defmethod (setf style-bindings) :before ((new-value list) (style style-programmable)) (recompile style (style-%code style) new-value) new-value)) (defmethod rsb.ep:access? ((processor style-programmable) (part t) (mode (eql :read))) (when-let ((bindings (cdr (assoc part *style-programmable-default-binding-access-info*)))) (log:debug "~@<Checking ~S access to ~S against bindings ~S~@:>" mode part bindings) (when-let ((used (intersection bindings (style-%used-bindings processor)))) (log:info "~@<Used binding~P ~{~S~^, ~} require ~S access to ~S~@:>" (length used) used mode part) t))) (define-condition binding-use (condition) ((name :initarg :name :reader binding-use-name))) (defmethod compile-code ((style style-programmable) (code t) (bindings list)) (log:info "~@<~A compiles code ~S~@:>" style code) ;; Try to compile CODE collecting and subsequently muffling all ;; errors and warnings since we do not want to leak these to the ;; caller. (let+ ((used-bindings '()) (conditions '()) ((&flet+ instrument-binding ((name value)) `(,name (note-binding-use ,name ,value)))) ((&flet wrap-code (code) `(lambda () (let ((%count -1)) (lambda (%event stream) (declare (ignorable %event stream)) (incf %count) (flet ((timestamp->unix (timestamp) (local-time:timestamp-to-unix timestamp)) (timestamp->unix/nsec (timestamp) (+ (* (expt 10 9) (local-time:timestamp-to-unix timestamp)) (local-time:nsec-of timestamp)))) (declare (ignorable #'timestamp->unix #'timestamp->unix/nsec)) (macrolet ((note-binding-use (name value) (signal 'binding-use :name name) value)) (symbol-macrolet (,@(mapcar #'instrument-binding (list* '(event %event) bindings))) (catch 'skip-event ,@code))))))))) ((&values function nil failed?) (block compile (handler-bind ((binding-use (lambda (condition) (let ((name (binding-use-name condition))) (log:debug "~@<Saw use of binding ~S~@:>" name) (pushnew name used-bindings)))) ((or style-warning #+sbcl sb-ext:compiler-note) (lambda (condition) (log:warn "~@<Compiler said: ~A~@:>" condition) (muffle-warning))) ((or error warning) (lambda (condition) (push condition conditions) (if (find-restart 'muffle-warning) (muffle-warning condition) (return-from compile (values nil nil t)))))) (funcall (with-compilation-unit (:override t) (compile nil (wrap-code code)))))))) (when (or failed? conditions) (format-code-error code "~@<Failed to compile.~@[ Compiler said: ~ ~:{~&+_~@<~@;~A~:>~}~]~@:>" (mapcar #'list conditions))) (log:info "~@<Used bindings: ~:[none~;~:*~{~S~^, ~}~]~@:>" used-bindings) (values function used-bindings))) (defmethod format-event ((event event) (style style-programmable) (stream stream) &key) (let+ (((&structure-r/o style- bindings code) style)) (handler-bind (((and error (not stream-error)) (lambda (condition) (format-code-error code "~@<Failed to format event ~A using ~ specified bindings ~_~{~2T~{~24A -> ~ ~A~_~}~}and code ~_~2T~S~_: ~A~@:>" event bindings code condition)))) (funcall (style-%lambda style) event stream)))) (defmethod print-object ((object style-programmable) stream) (print-unreadable-object (object stream :type t :identity t) (if (slot-boundp object 'code) (let+ (((&structure-r/o style- code bindings) object) (*print-length* (or *print-length* 3))) (format stream "~:[<no code>~;~:*~A~] " code) (%print-bindings bindings stream)) (format stream "<not initialized>")))) ;;; Script-based style (defclass style-programmable/script (style-programmable) ((code :reader style-script)) (:default-initargs :code nil :script (missing-required-initarg 'style-programmable/script :script)) (:documentation "This formatting style produces its output by executing a supplied script which can take the forms of a pathname, designating a file, a stream, a string or any other Lisp object. The code can rely on `stream' to be bound to a character output stream which it should use for producing the output. By default, the following bindings are available: ")) (service-provider:register-provider/class 'style :programmable/script :class 'style-programmable/script) (defmethod shared-initialize :after ((instance style-programmable/script) (slot-names t) &key code (script nil script-supplied?)) (when code (error "~@<The initarg ~S cannot be supplied; ~S has to be used.~@:>" :code :script)) (when script-supplied? (setf (style-script instance) script))) (defmethod (setf style-script) ((new-value list) (style style-programmable/script)) (setf (style-code style) new-value)) (defmethod (setf style-script) ((new-value stream) (style style-programmable/script)) (setf (style-script style) (with-condition-translation (((error format-code-read-error) :code new-value)) (let ((*package* #.*package*)) (iter (for token in-stream new-value) (collect token))))) new-value) (defmethod (setf style-script) ((new-value string) (style style-programmable/script)) (with-input-from-string (stream new-value) (setf (style-script style) stream)) new-value) (defmethod (setf style-script) ((new-value pathname) (style style-programmable/script)) (with-condition-translation ((((and error (not format-code-error)) format-code-read-error) :code new-value)) (with-input-from-file (stream new-value) (setf (style-script style) stream))) new-value) ;;; Template-based style (defclass style-programmable/template (style-programmable) ((template :type string :reader style-template :writer (setf style-%template) :documentation "Stores the template which is used for producing the output of the style.")) (:default-initargs :code nil :template (missing-required-initarg 'style-programmable/template :template)) (:documentation "This formatting style produces its output by applying a template specification to individual events. In the template specification, event properties can be accessed using a syntax of the form ${PROPERTY} or @{PROPERTY} for \"direct\" expansion and \"spliced\" expansion respectively. In addition, interpolations like named unicode characters etc. as described in http://weitz.de/cl-interpol/ are supported. By default, the following PROPERTY names are available: ")) (service-provider:register-provider/class 'style :programmable/template :class 'style-programmable/template) (defmethod shared-initialize :after ((instance style-programmable/template) (slot-names t) &key code (template nil template-supplied?)) (when code (error "~@<The initarg ~S cannot be supplied; ~S has to be used.~@:>" :code :template)) (when template-supplied? (setf (style-template instance) template))) (defmethod (setf style-template) :before ((new-value string) (style style-programmable/template)) (let ((form (with-condition-translation (((error format-code-read-error) :code new-value)) (let ((*package* #.*package*)) (with-interpol-syntax () (read-from-string (format nil "#?\"~A\"" new-value))))))) (setf (style-code style) `((princ ,form stream))))) (defmethod (setf style-template) ((new-value string) (style style-programmable/template)) (setf (style-%template style) new-value)) (defmethod (setf style-template) ((new-value stream) (style style-programmable/template)) (setf (style-template style) (read-stream-content-into-string new-value)) new-value) (defmethod (setf style-template) ((new-value pathname) (style style-programmable/template)) (setf (style-template style) (with-condition-translation (((error format-code-read-error) :code new-value)) (read-file-into-string new-value))) new-value) (defmethod format-event ((event event) (style style-programmable/template) (stream stream) &key) (handler-bind (((and error (not stream-error)) (lambda (condition) (error "~@<Failed to format event ~A using specified ~ bindings ~_~{~2T~{~16A -> ~A~_~}~}and template ~ ~_~2T~S~_: ~A~@:>" event (style-bindings style) (style-template style) condition)))) (funcall (style-%lambda style) event stream))) (defmethod print-object ((object style-programmable/template) stream) (if (slot-boundp object 'template) (print-unreadable-object (object stream :type t :identity t) (let+ (((&structure-r/o style- template bindings) object) (length (length template))) (format stream "\"~A~:[~;…~]\" " (subseq template 0 (min 8 length)) (> length 8)) (%print-bindings bindings stream))) (call-next-method))) ;;; Utility functions (defun %print-bindings (bindings stream) (format stream "(~D~:[~;*~])" (length bindings) (eq bindings *style-programmable-default-bindings*))) (iter (for class in '(style-programmable style-programmable/script style-programmable/template)) (setf (documentation class 'type) (format nil "~A~{+ ~(~A~)~^~%~}" (documentation class 'type) (mapcar #'first *style-programmable-default-bindings*)))) ;; Local Variables: ;; coding: utf-8 ;; End:
16,629
Common Lisp
.lisp
356
34.233146
92
0.553987
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6a88c209ec5d748b55fe36aa81a2e7dfe679b7a35a1b75d64fafa31562fca60b
37,336
[ -1 ]
37,337
event-style-multiple-files.lisp
open-rsx_rsb-tools-cl/src/formatting/event-style-multiple-files.lisp
;;;; event-style-multiple-files.lisp --- Write to one file per event. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) ;;; `style-multiple-files' (defclass style-multiple-files () ((filename-style :initarg :filename-style :reader style-filename-style :writer (setf style-%filename-style) :documentation "Stores an event formatting style for producing output file names. `format-event' is called with the event, this style and a `string-stream'. The style then prints the desired output file name to the stream.") (event-style :initarg :event-style :reader style-event-style :writer (setf style-%event-style) :documentation "Stores and event formatting style for producing the content of output file. `format-event' is called with the event, this style and a stream connected to the output file for the event.")) (:default-initargs :event-style (missing-required-initarg 'style-multiple-files :event-style)) (:documentation "Write style output to a new file for each event. The filename style is applied to events to determine the name of the file into which the respective event should be written. The event style is applied to events to produce the content of these files.")) (service-provider:register-provider/class 'style :multiple-files :class 'style-multiple-files) (defmethod shared-initialize :before ((instance style-multiple-files) (slot-names t) &key (filename-template nil filename-template-supplied?) (filename-style nil filename-style-supplied?)) (cond ((not (or filename-template-supplied? filename-style-supplied?)) (missing-required-initarg 'style-multiple-files :filename-style-xor-filename-template)) ((and filename-template-supplied? filename-style-supplied?) (incompatible-initargs 'style-multiple-files :filename-template filename-template :filename-style filename-style)))) (defmethod shared-initialize :after ((instance style-multiple-files) (slot-names t) &key filename-template filename-style event-style) (cond (filename-template (setf (style-%filename-style instance) (ensure-style `(:programmable/template :template ,filename-template)))) (filename-style (setf (style-%filename-style instance) (ensure-style filename-style)))) (when event-style (setf (style-%event-style instance) (ensure-style event-style)))) (defmethod rsb.ep:access? ((processor style-multiple-files) (part t) (mode t)) (let+ (((&structure-r/o style- filename-style event-style) processor)) (or (rsb.ep:access? filename-style part mode) (rsb.ep:access? event-style part mode)))) (defmethod format-event ((event t) (style style-multiple-files) (target t) &rest args &key) (let+ (((&structure-r/o style- filename-style event-style) style) ((pathname &rest open-args &key (element-type :default)) (ensure-list (with-output-to-string (stream) (format-event event filename-style stream))))) (with-open-stream (stream (apply #'open pathname :direction :output :element-type element-type (remove-from-plist open-args :element-type))) (apply #'format-event event event-style stream args)))) ;;; `style-raw-files' (defclass style-raw-files (style-multiple-files) () (:default-initargs :filename-template "${count}.bin" :event-style '(:payload :separator nil :payload-style :payload-generic/raw)) (:documentation "Write raw payload data to a new file for each event.")) (service-provider:register-provider/class 'style :raw-files :class 'style-raw-files)
4,670
Common Lisp
.lisp
99
34.383838
76
0.579017
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4c55143c85f6f1ea407eb2db5f2a380670a54c9ebb79c24feb66152bd6e2497f
37,337
[ -1 ]
37,338
event-style-meta-data.lisp
open-rsx_rsb-tools-cl/src/formatting/event-style-meta-data.lisp
;;;; event-style-meta-data.lisp --- Meta-data-only formatting style class. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) ;;; `meta-data-mixin' (defclass meta-data-mixin () ((routing-info? :initarg :routing-info? :type boolean :accessor style-routing-info? :initform t :documentation "Should routing information like destination scope, origin id and method be printed?") (timestamps? :initarg :timestamps? :type boolean :accessor style-timestamps? :initform t :documentation "Should event timestamps be printed?") (user-items? :initarg :user-items? :type boolean :accessor style-user-items? :initform t :documentation "Should the dictionary of client-supplied key-value pairs be printed?") (causes? :initarg :causes? :type boolean :accessor style-causes? :initform t :documentation "Should the causes of the event be printed?")) (:documentation "This class is intended to be mixed into event formatting style classes that print meta-data of events.")) (macrolet ((define-access?-method (part &body body) `(defmethod rsb.ep:access? ((processor meta-data-mixin) (part (eql ,part)) (mode (eql :read))) ,@body))) (define-access?-method :scope (style-routing-info? processor)) (define-access?-method :id (style-routing-info? processor)) (define-access?-method :sequence-number (style-routing-info? processor)) (define-access?-method :origin (style-routing-info? processor)) (define-access?-method :method (style-routing-info? processor)) (define-access?-method :timestamp (style-timestamps? processor)) (define-access?-method :meta-data (style-user-items? processor)) (define-access?-method :causes (style-causes? processor))) (defmethod format-event ((event event) (style meta-data-mixin) (stream t) &key) (let+ (((&structure-r/o style- routing-info? timestamps? user-items? causes?) style) (produced-output? nil)) (when (not (or routing-info? timestamps? user-items? causes?)) (return-from format-event)) (pprint-logical-block (stream (list event)) ;; Envelope information. (when routing-info? (let+ (((&structure-r/o event- scope id sequence-number origin method) event)) (format stream "Event~ ~@:_~2@T~@<~ Scope ~A~@:_~ Id ~:[<none>~;~:*~A~]~@:_~ Sequence number ~:[<none>~;~:*~:D~]~@:_~ Origin ~:[<none>~;~:*~A~]~@:_~ Method ~:[<none>~;~:*~A~]~ ~:>" (scope-string scope) id sequence-number origin method)) (setf produced-output? t)) ;; Framework and user timestamps. (when timestamps? (let+ (((&flet difference (earlier later) (when (and earlier later) (local-time:timestamp-difference later earlier)))) ((&flet lookup (key) (cons key (timestamp event key)))) ((&flet maybe-timestamp< (left right) (when (and left right) (local-time:timestamp< left right)))) (framework-cells (mapcar #'lookup *framework-timestamps*)) (other-keys (set-difference (timestamp-keys event) *framework-timestamps*)) (other-cells (sort (mapcar #'lookup other-keys) #'local-time:timestamp< :key #'cdr)) (sorted (merge 'list framework-cells other-cells #'maybe-timestamp< :key #'cdr)) (names (mapcar (compose #'timestamp-name #'car) sorted)) (width (length (extremum names #'> :key #'length))) (values (mapcar #'cdr sorted)) (differences (mapcar #'difference (list* nil values) values))) (format stream "~:[~;~@:_~]Timestamps~ ~@:_~2@T~@<~ ~{~{~ ~VA ~:[~ ~*<none>~ ~:;~ ~:*~A~@[ (~:/rsb.formatting::print-human-readable-duration/)~]~ ~]~ ~}~^~@:_~}~ ~:>" produced-output? (mapcar #'list (circular-list width) names values differences))) (setf produced-output? t)) ;; Meta-data. (when user-items? (when-let ((meta-data (remove-from-plist (meta-data-plist event) :rsb.transport.payload-size :rsb.transport.wire-schema))) (format stream "~:[~;~@:_~]Meta-Data~ ~@:_~2@T~@<~ ~{~A ~S~^~@:_~}~ ~:>" produced-output? meta-data) (setf produced-output? t))) ;; Causes (when causes? (when-let ((causes (event-causes event))) (format stream "~:[~;~@:_~]Causes~ ~@:_~2@T~@<~ ~{~A~^~@:_~}~ ~:>" produced-output? (map 'list #'event-id->uuid (event-causes event)))))))) ;;; `style-meta-data' (defclass style-meta-data (meta-data-mixin separator-mixin max-lines-mixin output-forcing-mixin) () (:default-initargs :separator `(#\Newline (:rule ,(if *output-unicode?* #\─ #\-)) #\Newline)) (:documentation "Format the meta-data of each event on multiple lines, but do not format event payloads.")) (service-provider:register-provider/class 'style :meta-data :class 'style-meta-data)
6,794
Common Lisp
.lisp
144
31.270833
95
0.466687
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4228b79342bc02ac2f04114c334b5976d109cde0d79309cac1d4f274755c6b9f
37,338
[ -1 ]
37,339
event-style-columns.lisp
open-rsx_rsb-tools-cl/src/formatting/event-style-columns.lisp
;;;; event-style-columns.lisp --- Generic column-based formatting class. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) (defclass style-columns (header-printing-mixin columns-mixin) () (:documentation "This formatting style prints configurable properties of received events in a column-oriented fashion. Event properties and the associated columns in which the properties should be printed have to be specified using the :columns initarg. If no columns are specified, no output is produced.")) (service-provider:register-provider/class 'style :columns :class 'style-columns) (defmethod format-event :before ((event t) (style style-columns) (stream t) &key (width (or *print-right-margin* 80))) (let+ (((&structure-r/o style- dynamic-width-columns separator-width) style) ((&values widths cached?) (style-compute-column-widths style dynamic-width-columns width :separator-width separator-width))) (unless cached? (style-assign-column-widths style dynamic-width-columns widths))))
1,291
Common Lisp
.lisp
26
40.5
78
0.655829
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6ef1fdbaf7e0dafd9d8afc81c0294dee5713119f68f5230c0e26930bb3d1f3ee
37,339
[ -1 ]
37,340
payload-collection.lisp
open-rsx_rsb-tools-cl/src/formatting/payload-collection.lisp
;;;; payload-collections.lisp --- Format event collections. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) (defvar *by-scope-formatting-converter* (append (ensure-list (rsb:default-converter 'octet-vector)) '(:fundamental-null)) "The converter that should be applied to inner payloads in event collection payloads.") (defvar *by-scope-formatting-event-style* (make-style :detailed :separator nil) "The formatting style used for sub-events contained in collections of events.") (defmethod format-payload ((data rsb.protocol:notification) (style payload-style-generic/pretty) (stream stream) &key) ;; TODO(jmoringe, 2012-02-05): there should be a dedicated serialization (handler-case (let ((event (rsb.transport.socket::notification->event* *by-scope-formatting-converter* data :expose-wire-schema? t))) (pprint-logical-block (stream (list event)) (format-event event *by-scope-formatting-event-style* stream))) (error (condition) (format stream "~@<| ~@;~ Failed to decode notification~ ~@:_~@:_~ ~2@T~<~A~:>~ ~@:_~@:_~ ~A~ ~:>" (list (with-output-to-string (stream) (describe data stream))) condition)))) (defmethod format-payload ((data rsb.protocol.collections:events-by-scope-map/scope-set) (style payload-style-generic/pretty) (stream stream) &key) (let+ (((&accessors-r/o (scope rsb.protocol.collections:events-by-scope-map/scope-set-scope) (notifications rsb.protocol.collections:events-by-scope-map/scope-set-notifications)) data)) (format stream "Scope ~S~@:_~2@T" (sb-ext:octets-to-string scope)) (pprint-logical-block (stream (coerce notifications 'list)) (iter (for notification in-sequence notifications) (unless (first-iteration-p) (pprint-newline :mandatory stream)) (format-payload notification style stream))))) (defmethod format-payload ((data rsb.protocol.collections:events-by-scope-map) (style payload-style-generic/pretty) (stream stream) &key) (let ((sets (rsb.protocol.collections:events-by-scope-map-sets data))) (format stream "Events by Scope (~D Scope~:P)~@:_~2@T" (length sets)) (pprint-logical-block (stream (coerce sets 'list)) (iter (for set in-sequence sets) (unless (first-iteration-p) (pprint-newline :mandatory stream)) (format-payload set style stream)))))
3,037
Common Lisp
.lisp
64
35.40625
96
0.577688
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e519c74661e4b3333e7d776b3bf3da3d7470c8d964dbf871183641d32e25aefc
37,340
[ -1 ]
37,341
event-style-timeline.lisp
open-rsx_rsb-tools-cl/src/formatting/event-style-timeline.lisp
;;;; event-style-timeline.lisp --- Event indicators on a simple timeline. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) ;;; Class `basic-timeline-style' (defclass basic-timeline-style (sorted-monitor-style temporal-bounds-mixin timestamp-mixin) () (:default-initargs :print-interval .5 :upper-bound '(+ :now 1)) (:documentation "This class is intended to be used as a superclass for timeline formatting style classes.")) (defmethod make-sub-style-entry :around ((style basic-timeline-style) (value t)) ;; Propagate temporal bounds and timestamp to sub-style. (let+ (((&whole entry &ign . sub-style) (call-next-method))) (setf (bounds sub-style) (bounds style) (style-timestamp sub-style) (style-timestamp style)) entry)) (macrolet ((define-delegating-method (name) `(flet ((applicable? (new-value thing) (compute-applicable-methods (fdefinition '(setf ,name)) (list new-value thing)))) (defmethod (setf ,name) ((new-value t) ; TODO define elsewhere? (style columns-mixin)) (iter (for column in-sequence (style-columns style)) (when (applicable? new-value column) (setf (,name column) new-value)))) (defmethod (setf ,name) :after ((new-value t) (style basic-timeline-style)) (iter (for (_ . sub-style) in-sequence (style-sub-styles style)) (when (applicable? new-value sub-style) (setf (,name sub-style) new-value))))))) (define-delegating-method lower-bound) (define-delegating-method upper-bound) (define-delegating-method bounds) (define-delegating-method style-timestamp)) ;;; Some concrete timeline styles (macrolet ((define-timeline-style ((kind &rest initargs &key &allow-other-keys) &body doc-and-column-specs) (let+ ((spec (format-symbol :keyword "~A/~A" :timeline kind)) (class-name (format-symbol *package* "~A/~A" :style-timeline kind)) ((&values column-specs nil documentation) (parse-body doc-and-column-specs :documentation t)) (columns column-specs)) `(progn (defclass ,class-name (basic-timeline-style) () (:default-initargs :default-columns (list ,@columns) ,@initargs) ,@(when documentation `((:documentation ,documentation)))) (service-provider:register-provider/class 'style ,spec :class ',class-name))))) (define-timeline-style (scope :key #'event-scope :test #'scope=) "This formatting style indicates the points in time at which events occur as dots on a timeline. Separate \"lanes\" which share a common timeline are dynamically allocated as events occur. Events are grouped by scope." (lambda (value) (list :constant :name "Scope" :value value :formatter (lambda (value stream) (write-string (scope-string value) stream)) :widths '(:range 24) :priority 2 :alignment :left)) (list :timeline)) (define-timeline-style (origin :key #'event-origin :test #'uuid:uuid=) "This formatting style indicates the points in time at which events occur as dots on a timeline. Separate \"lanes\" which share a common timeline are dynamically allocated as events occur. Events are grouped by origin." (lambda (value) (list :constant :name "Origin" :value value :widths '(:range 8) :priority 2 :alignment :left)) (list :timeline)))
4,247
Common Lisp
.lisp
95
32.8
76
0.562107
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
72d078bb6a637cc9065476073300b982ae38e415ed5aad834cacbaa2021c5b6e
37,341
[ -1 ]
37,342
payload-audio-wav.lisp
open-rsx_rsb-tools-cl/src/formatting/payload-audio-wav.lisp
;;;; payload-wav.lisp --- Format event data as WAV files. ;;;; ;;;; Copyright (C) 2012, 2013, 2014 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting) (defclass style-audio-stream/wav (style-audio-stream/raw) () (:documentation "This style produces an audio stream in WAV format from event payloads containing audio data.")) (service-provider:register-provider/class 'style :audio-stream/wav :class 'style-audio-stream/wav) (defmethod write-header ((descriptor list) (style style-audio-stream/wav) (target t)) (let+ (((channels sample-rate sample-format) descriptor) (width (ecase sample-format ((:sample-s8 :sample-u8) 1) ((:sample-s16 :sample-u16) 2) ((:sample-s24 :sample-u24) 3))) (byte-rate (* channels sample-rate width)) ;; The non-constant fields have the following meanings: ;; 0 (offset 4 size 4) Size ;; 2 (offset 22 size 2) Number of Channels ;; 3 (offset 24 size 4) Sample Rate ;; 4 (offset 28 size 4) Byte Rate ;; 5 (offset 32 size 2) Block Alignment ;; 6 (offset 34 size 2) Bits per Sample ;; 7 (offset 40 size 4) Sub Chunk Size (wave-header-template (vector #x52 #x49 #x46 #x46 0 0 0 0 #x57 #x41 #x56 #x45 #x66 #x6d #x74 #x20 #x10 #x00 #x00 #x00 #x01 #x00 2 2 3 3 3 3 4 4 4 4 5 5 6 6 #x64 #x61 #x74 #x61 7 7 7 7)) ;; Assumed maximum possible size (fake-size #x7fffffff)) (macrolet ((set-field (start size value) (once-only (value) `(iter (for (the fixnum i) :below ,size) (setf (aref wave-header-template (+ ,start i)) (ldb (byte 8 (* i 8)) ,value)))))) ;; Regarding "Size" and "Sub chunk size": We use ;; ;; Size: FAKE-SIZE ;; Sub chunk size: (- FAKE-SIZE 44) ;; ;; where FAKE-SIZE is the assumed maximum size (#0x7fffffff), ;; since we cannot know the file size in advance. This seems to ;; make most software do the right thing. (set-field 4 4 fake-size) ;; Size (set-field 22 2 channels) ;; Number of channels (set-field 24 4 sample-rate) ;; Sample rate (set-field 28 4 byte-rate) ;; Byte rate (set-field 32 2 (* channels width)) ;; Block alignment (set-field 34 2 (* width 8)) ;; Bits per sample (set-field 40 4 (- fake-size 44))) ;; Sub chunk size (write-sequence wave-header-template target))) (defmethod (setf descriptor-for-target) :after ((new-value list) (style style-audio-stream/wav) (target t)) ;; Write WAV header, since we have not done that yet if a descriptor ;; for TARGET is installed. (write-header new-value style target))
3,164
Common Lisp
.lisp
65
38.476923
82
0.546072
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
588b50768af329fae90d1e50772d4177e2d949cc32c557b0a68397a3518268a0
37,342
[ -1 ]
37,343
styles.lisp
open-rsx_rsb-tools-cl/src/formatting/introspection/styles.lisp
;;;; styles.lisp --- Printing and other processing of introspection information. ;;;; ;;;; Copyright (C) 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting.introspection) ;;; Service (service-provider:define-service style (:documentation "Providers of this service implement printing and other processing of introspection information")) ;;; `database-mixin' (defclass database-mixin () ((database :initarg :database :accessor style-database)) (:documentation "This class is intended to be mixed into style classes that have to know the introspection database object.")) ;;; `events-mixin' (defclass events-mixin () ((connections :accessor style-connections :initform '())) (:documentation "This class is intended to be mixed into style classes that process introspection database events. It relieves style classes from the burden of managing handlers for hooks of individual introspection database objects as these are created and destroyed.")) (defmethod detach ((participant events-mixin)) ;; Remove all remaining handlers from the respective hooks. (iter (for (subject handler) in (style-connections participant)) (hooks:remove-from-hook (database-change-hook subject) handler))) (defmethod rsb.ep:handle ((sink events-mixin) (data list)) ;; Register and unregister handlers as database objects are added ;; and removed. Delegate actual processing of events to methods on ;; `format-event'. (let+ (((&structure style- connections) sink) ((&flet register (subject function) (let* ((hook (database-change-hook subject)) (connection (list subject (curry function subject)))) (push connection connections) (hooks:add-to-hook hook (second connection))))) ((&flet unregister (subject) (when-let* ((hook (database-change-hook subject)) (connection (find subject connections :key #'first))) (hooks:remove-from-hook hook (second connection)) (removef connections connection)))) ((&labels process-event (object event subject) (rsb.formatting:format-event (list (local-time:now) object event subject) sink t))) ((&labels on-process-change (object subject event) (process-event object event subject))) ((&labels on-host-change (object subject event) (process-event object event subject) (case event (:process-added (register subject #'on-process-change)) (:process-removed (unregister subject))))) ((&labels on-database-change (object subject event) (process-event object event subject) (case event (:host-added (register subject #'on-host-change)) (:host-removed (unregister subject)))))) (apply #'on-database-change :introspection data))) ;;; `object-tree-printing-mixin' (defclass object-tree-printing-mixin () ((max-depth :initarg :max-depth :type (or null positive-integer) :reader style-max-depth :initform 2 :documentation "When not null, a positive integer indicating the maximum depth up to which the tree of introspection objects should be printed. Nodes below that depth should not be printed.") (stateful? :initarg :stateful? :reader style-stateful? :initform t :documentation "When true, print object properties such as current state or latency that only make sense when describing a live system.")) (:documentation "This class is intended to be mixed into style classes which print trees of introspection objects.")) (defun print-object-tree (database stream &key max-depth stateful?) (let+ (((&flet filter (target entry what &key depth) (declare (ignore target entry what)) (cond ((or (not max-depth) (not depth) (< depth max-depth)) '(:first :content :children)) ((or (not max-depth) (not depth) (<= depth max-depth)) '(:first :content)))))) (print-entry stream database t :filter #'filter :stateful? stateful?))) ;;; `delay-mixin' (defclass delay-mixin () ((delay :initarg :delay :type (or null positive-real) :reader style-delay :documentation "Amount of time in seconds to wait before printing a snapshot of the introspection database.")) (:default-initargs :delay 1.0) (:documentation "This class is intended to be mixed into introspection formatting style classes that produce their output after a certain delay.")) ;; Receiving the database => wait for the configured delay in order to ;; collect introspection information, then perform the style-specific ;; operations. (defmethod (setf style-database) :after ((new-value t) (style delay-mixin)) (when-let ((delay (style-delay style))) (sleep delay))) ;;; `style-monitor/events' (defclass style-monitor/events (database-mixin events-mixin) ((stream :type stream :accessor style-%stream :documentation "Stores the stream to which events should be formatted.")) (:documentation "Print relevant introspection events on the output stream. Does not print clock-offset- and latency-change events.")) (service-provider:register-provider/class 'style :monitor/events :class 'style-monitor/events) ;; Dummy event => return true to indicate that the program should ;; continue. (defmethod rsb.formatting:format-event ((event t) (style style-monitor/events) (target t) &key &allow-other-keys) (setf (style-%stream style) target) t) (defmethod rsb.formatting:format-event ((event list) (style style-monitor/events) (target t) &key &allow-other-keys) (let+ (((&accessors-r/o (stream style-%stream)) style) ((timestamp object event subject) event) ((&flet print-items (thing) (typecase thing (symbol `((:name ,(string-downcase thing)))) (standard-object (print-items:print-items thing)) (t `((:value ,(princ-to-string thing)))))))) (unless (member event '(:clock-offset-changed :latency-changed)) (format stream "~A ~ ~32@<~/print-items:format-print-items/~> ~ ~20@<~/print-items:format-print-items/~> ~ ~/print-items:format-print-items/~ ~%" timestamp (print-items object) (print-items event) (print-items subject))))) ;;; `style-monitor/object-tree' (defclass style-monitor/object-tree (database-mixin object-tree-printing-mixin rsb.formatting:periodic-printing-mixin rsb.formatting:separator-mixin) () (:default-initargs :separator :clear) (:documentation "Periodically print a snapshot of the introspection tree.")) (service-provider:register-provider/class 'style :monitor/object-tree :class 'style-monitor/object-tree) (defmethod detach ((participant style-monitor/object-tree))) ;; Introspection event => ignore. (defmethod rsb.ep:handle ((sink style-monitor/object-tree) (data list))) ;; Dummy event => return true to indicate that the program should ;; continue. (defmethod rsb.formatting:format-event ((event t) (style style-monitor/object-tree) (target t) &key &allow-other-keys) t) (defmethod rsb.formatting:format-event ((event (eql :trigger)) (style style-monitor/object-tree) (target t) &key &allow-other-keys) (fresh-line target) (let+ (((&structure-r/o style- database max-depth stateful?) style)) (print-object-tree database target :max-depth max-depth :stateful? stateful?))) ;;; `style-object-tree' (defclass style-object-tree (database-mixin object-tree-printing-mixin delay-mixin) () (:documentation "Quickly gather and print a snapshot of the introspection tree. The default behavior is gathering information for one second then printing the resulting snapshot. In most systems, one second should be enough to request and obtain all available introspection information. However, circumstances like degraded system performances or extreme communication latency may required longer delays.")) (service-provider:register-provider/class 'style :object-tree :class 'style-object-tree) (defmethod detach ((participant style-object-tree))) ;; Introspection event => ignore. (defmethod rsb.ep:handle ((sink style-object-tree) (data list))) ;; Dummy event => print the object tree snapshot and return false to ;; indicate that the program should be terminated. (defmethod rsb.formatting:format-event ((event t) (style style-object-tree) (target t) &key &allow-other-keys) (fresh-line target) (let+ (((&structure-r/o style- database max-depth stateful?) style)) (print-object-tree database target :max-depth max-depth :stateful? stateful?)) nil)
10,120
Common Lisp
.lisp
214
36.654206
80
0.614348
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b82f3bc0d349c30d0c7c233bac3c5ec730a0e2b0136a54743c3cc586196fa05b
37,343
[ -1 ]
37,344
package.lisp
open-rsx_rsb-tools-cl/src/formatting/introspection/package.lisp
;;;; package.lisp --- Package definition for the formatting.introspection module. ;;;; ;;;; Copyright (C) 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.formatting.introspection (:use #:cl #:alexandria #:let-plus #:iterate #:rsb #:rsb.model #:rsb.introspection) (:import-from #:rsb.introspection ; for printing #:tracked-quantity #:tracked-quantity-value #:tracked-quantity-history #:timing-tracker-%latency #:timing-tracker-%clock-offset #:entry-%tracker #:remote-introspection-database #:remote-introspection #:introspection-database) (:documentation "This package contains formatting functions for introspection information."))
759
Common Lisp
.lisp
27
24.555556
81
0.722376
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
36a1341a9c1a56302939ee539edcd7d24dbae6923f3884add8199152534fc163
37,344
[ -1 ]
37,345
json.lisp
open-rsx_rsb-tools-cl/src/formatting/introspection/json.lisp
;;;; json.lisp --- JSON serialization of introspection information. ;;;; ;;;; Copyright (C) 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting.introspection) ;;; `style-json' (defclass style-json (database-mixin delay-mixin) ((builder :initarg :builder :reader style-builder :initform t :documentation "Stores the builder used to serialize introspection model objects to JSON.") (serializer :reader style-%serializer :initform (rsb.formatting::make-json-serializer :kind-transform (architecture.builder-protocol.json:default-kind-key-and-value-transform) :peek-function (rsb.formatting::make-json-peek-function)) :documentation "Stores the serializer used to serialize introspection model objects to JSON.")) (:documentation "Serialize introspection information to JSON.")) (service-provider:register-provider/class 'style :json :class 'style-json) (defmethod detach ((participant style-json))) ;; Introspection event => ignore. (defmethod rsb.ep:handle ((sink style-json) (data list))) ;; Dummy event => serialize snapshot to JSON and return false to ;; indicate that the program should be terminated. (defmethod rsb.formatting:format-event ((event (eql :dummy)) (style style-json) (target t) &key) (let+ (((&structure-r/o style- database builder %serializer) style)) (architecture.builder-protocol:with-unbuilder (builder builder) (architecture.builder-protocol.json:serialize-using-serializer builder database target %serializer))) nil)
1,899
Common Lisp
.lisp
40
37.225
115
0.63121
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
feed64649cbddf6d526d8170282ce72e069f7b33f29ceca8be27fa589d673adc
37,345
[ -1 ]
37,346
print.lisp
open-rsx_rsb-tools-cl/src/formatting/introspection/print.lisp
;;;; print.lisp --- Printing of introspection information. ;;;; ;;;; Copyright (C) 2014, 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.formatting.introspection) ;;; Utilities (defun print-elapsed-time (stream start-time &optional colon? at?) (let* ((now-time (local-time:now)) (difference (local-time:timestamp-difference now-time start-time))) (rsb.formatting:print-human-readable-duration stream difference colon? at?))) ;;; Participant (defun print-participant-info-markup (stream participant-info &optional colon? at?) ;; If COLON? is true, include properties of PARTICIPANT-INFO that ;; only make sense when describing a live system. (declare (ignore at?)) (let+ (((&structure-r/o participant-info- kind id scope type) participant-info)) (format stream "~/rsb::print-id/~18,0T" id) (if colon? (format stream "~:[~ ~A~ ~35,0T~A<~A>~ ~58,0T~A~ ~:;~ <missing>~ ~]" (eq :proxy kind) :active kind type (scope-string scope)) (format stream "~:[~ ~16,0T~A<~A>~ ~48,0T~A~ ~:;~ <missing>~ ~]" (eq :proxy kind) kind type (scope-string scope))))) ;;; Process (defun print-process-state-markup (stream state &optional colon? at?) (declare (ignore colon? at?)) (princ state stream)) (defun print-process-info-markup (stream process-info &optional colon? at?) ;; If COLON? is true, include properties of PROCESS-INFO that only ;; make sense when describing a live system. (declare (ignore at?)) (let+ ((remote? (typep process-info 'remote-process-info)) ((&structure process-info- process-id program-name commandline-arguments display-name state) process-info) (*print-lines* 1)) (write-string ; next four lines hack around limitations of nested pretty streams (with-output-to-string (stream) (let ((*print-right-margin* (when-let ((right-margin *print-right-margin*)) (- right-margin 3)))) (format stream "~6,,,'0@A~16,0T" process-id) (when colon? (format stream "~@[ ~/rsb.formatting.introspection::print-process-state-markup/~]~ ~25,0T~@[ (~/rsb.formatting.introspection::print-elapsed-time/)~]~ ~35,0T" (when remote? state) (when remote? (info-most-recent-activity process-info)))) (format stream "~@<~:[~A~:;~:*~A (~A)~]~@[ ~:_~{~A~^ ~:_~}~]~@:>" display-name program-name commandline-arguments))) stream))) (defun print-process-info-details-markup (stream process-info &optional colon? at?) ;; If COLON? is true, include properties of PROCESS-INFO that ;; only make sense when describing a live system. (declare (ignore at?)) (let+ ((remote? (typep process-info 'remote-process-info)) ((&accessors (start-time process-info-start-time) (executing-user process-info-executing-user) (rsb-version process-info-rsb-version) (transports process-info-transports) (latency info-latency)) process-info)) (if colon? (format stream "Uptime ~@[ ~/rsb.formatting.introspection::print-elapsed-time/~]~ ~21,0T│ User ~:[?~:;~:*~A~]~ ~@:_Latency ~/rsb.formatting.introspection::print-time-offset-markup/~ ~21,0T│ RSB Version ~:[?~:;~:*~A~]" start-time executing-user (when remote? latency) rsb-version) (format stream "Start~ ~37,0T│ User ~:[?~:;~:*~A~]~ ~@:_~ ~@[~A~]~ ~37,0T│ RSB Version ~:[?~:;~:*~A~]" executing-user start-time rsb-version)) (format stream "~@:_~ Transports~@[ ~@<~{~A~^, ~_~}~:>~]" (when remote? (mapcar (lambda (uri) (puri:merge-uris (puri:uri "/") uri)) transports))))) ;;; Host (defun print-host-state-markup (stream state &optional colon? at?) (declare (ignore colon? at?)) (princ state stream)) (defun print-time-offset-markup (stream value &optional colon? at?) (declare (ignore colon? at?)) (format stream "~[~ ??? s~ ~;~ ~/rsb.formatting::print-human-readable-duration/~ ~;~ ~/rsb.formatting::print-human-readable-duration/~ ~]" (cond ((null value) 0) ((> (abs value) 0.001) 1) (t 2)) value)) (defun print-host-info-markup (stream host-info &optional colon? at?) ;; If COLON? is true, include properties of HOST-INFO that only make ;; sense when describing a live system. (declare (ignore at?)) (let* ((remote? (typep host-info 'remote-host-info)) (state (when remote? (host-info-state host-info))) (most-recent-activity (when remote? (info-most-recent-activity host-info)))) (format stream "~A" (host-info-hostname host-info)) (when colon? (format stream "~17,0T~@[ ~/rsb.formatting.introspection::print-host-state-markup/~]~ ~25,0T~@[ (~/rsb.formatting.introspection::print-elapsed-time/)~]" state most-recent-activity)))) (defun truncate-string (string max) (let ((length (length string))) (if (> length max) (concatenate 'string "…" (subseq string (- length max -1) length)) string))) (defun print-host-info-details-markup (stream host-info &optional colon? at?) ;; If COLON? is true, include properties of HOST-INFO that only make ;; sense when describing a live system. (declare (ignore at?)) (let+ (((&structure-r/o host-info- machine-type machine-version software-type software-version) host-info) (remote? (typep host-info 'remote-host-info)) (clock-offset (when remote? (info-clock-offset host-info))) (latency (when remote? (info-latency host-info)))) (if colon? (format stream "Clock offset ~/rsb.formatting.introspection::print-time-offset-markup/~ ~21,0T│ Machine type ~:[?~:;~:*~A~]~ ~60,0T│ Software type ~:[?~:;~:*~A~]~ ~@:_Latency ~/rsb.formatting.introspection::print-time-offset-markup/~ ~21,0T│ Machine version ~:[?~:;~:*~A~]~ ~60,0T│ Software version ~:[?~:;~:*~A~]" clock-offset machine-type software-type latency (truncate-string machine-version 20) software-version) (format stream "Machine type ~:[?~:;~:*~A~]~ ~37,0T│ Software type ~:[?~:;~:*~A~]~ ~@:_~ Machine version ~:[?~:;~:*~A~]~ ~37,0T│ Software version ~:[?~:;~:*~A~]" machine-type software-type (truncate-string machine-version 17) software-version)))) ;;; Tree printing (defgeneric entry-children-for-printing (entry) (:method ((entry t)) (node-children entry)) (:method ((entry participant-entry)) (sort-participants (node-children entry))) (:method ((entry process-entry)) (sort-participants (node-children entry)))) (defgeneric print-entry (target entry what &key filter stateful?)) (defmethod print-entry ((target stream) (entry rsb.model:info-mixin) (what t) &rest args &key &allow-other-keys) (apply #'print-entry target (node-info entry) what args)) (defmethod print-entry ((target stream) (entry participant-info) (what (eql :first)) &key stateful? &allow-other-keys) (print-participant-info-markup target entry stateful?) nil) ; return value indicates "no further content" (defmethod print-entry ((target stream) (entry process-info) (what (eql :first)) &key stateful? &allow-other-keys) (print-process-info-markup target entry stateful?) t) ; return value indicates "more content available" (defmethod print-entry ((target stream) (entry process-info) (what (eql :content)) &key stateful? &allow-other-keys) (print-process-info-details-markup target entry stateful?)) (defmethod print-entry ((target stream) (entry host-info) (what (eql :first)) &key stateful? &allow-other-keys) (print-host-info-markup target entry stateful?) t) ; return value indicates "more content available" (defmethod print-entry ((target stream) (entry host-info) (what (eql :content)) &key stateful? &allow-other-keys) (print-host-info-details-markup target entry stateful?)) (defmethod print-entry ((target stream) (entry remote-introspection-database) (what t) &rest args &key filter &allow-other-keys) (declare (ignore filter)) (apply #'print-object-tree1 entry target args)) (defmethod print-entry ((target stream) (entry remote-introspection) (what t) &rest args &key &allow-other-keys) (with-database-lock (entry) ; TODO let client lock (apply #'print-entry target (introspection-database entry) :first args))) ;;; Entry utility functions (defun print-object-tree1 (tree stream &rest args &key (filter (constantly t)) stateful?) (declare (ignore stateful?)) (let* ((args (remove-from-plist args :filter)) (printer (utilities.print-tree:make-folding-node-printer (lambda (stream depth entry) (declare (ignore depth)) (apply #'print-entry stream entry :first args)) (lambda (stream depth entry) (declare (ignore depth)) (apply #'print-entry stream entry :content args)) #'entry-children-for-printing (lambda (depth node) (funcall filter stream node t :depth depth)))) (roots (entry-children-for-printing tree))) (pprint-logical-block (stream roots) (if roots (mapc (lambda (root) (utilities.print-tree:print-tree stream root printer) (pprint-newline :mandatory stream)) roots) (format stream "<no entries>~@:_"))))) (defun sort-participants (participants) (sort (copy-list participants) #'string< :key (compose #'scope-string #'participant-info-scope #'node-info))) ;; Local Variables: ;; coding: utf-8 ;; End:
11,858
Common Lisp
.lisp
247
34.967611
99
0.532745
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c3522def177582d616b786bbb14dab40156ee0933c04c1ab95febb475884ebe7
37,346
[ -1 ]
37,347
idl-loading-converter.lisp
open-rsx_rsb-tools-cl/src/common/idl-loading-converter.lisp
;;;; idl-loading-converter.lisp --- Loading of IDL files at conversion time. ;;;; ;;;; Copyright (C) 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) (defclass idl-loading-converter (rsb.converter:caching-converter) () (:documentation "Load data definitions on-the-fly, then perform actual conversion.")) (service-provider:register-provider/class 'rsb.converter::converter :idl-loading :class 'idl-loading-converter) ;;; Deserialization (defmethod rsb.converter:wire->domain? ((converter idl-loading-converter) (wire-data t) (wire-schema t)) (let+ ((target (rsb.converter:converter-target converter)) ((&flet ask-target () (rsb.converter:wire->domain? target wire-data wire-schema)))) (declare (dynamic-extent #'ask-target)) (maybe-load-idl-for-wire-schema (symbol-name wire-schema) #'ask-target '(:deserializer)))) ;;; Serialization (defmethod rsb.converter:domain->wire? ((converter idl-loading-converter) (domain-object t)) (let+ ((target (rsb.converter:converter-target converter)) (class (class-of domain-object)) (wire-schema (protocol-buffer:descriptor-qualified-name (pb:message-descriptor class))) ((&flet ask-target () (rsb.converter:domain->wire? target domain-object)))) (declare (dynamic-extent #'ask-target)) (maybe-load-idl-for-wire-schema wire-schema #'ask-target '(:packed-size :serializer)))) ;;; Utilities (defun maybe-load-idl-for-wire-schema (wire-schema ask-target purpose) (declare (type string wire-schema) (type function ask-target)) (let+ (((&flet load-definition () (log:info "~@<Trying to load data type definition for ~ wire-schema ~S.~@:>" wire-schema) (restart-case (find-and-load-idl wire-schema :proto :purpose purpose) (continue (&optional condition) :report (lambda (stream) (format stream "~@<Ignore the error to load ~ the data type definition for ~ wire-schema ~S and ~ continue.~@:>" wire-schema)) (declare (ignore condition)) nil)))) (values (multiple-value-list (funcall ask-target)))) (if (and values (first values)) (values-list values) (and (load-definition) (funcall ask-target))))) ;;; Enabling (defun maybe-ensure-idl-loading-converter (&key (converters (default-converters)) (ensure? *load-idl-on-demand?*)) (let+ ((target :protocol-buffer) (converter (rsb.converter:make-converter :idl-loading :target target)) ((&flet substitute-in-sequence (converters) (substitute converter target converters)))) (labels ((substitute-in-alist (converters) ; TODO until let-plus merges adjacent &labels (let* ((cell/old (assoc 'nibbles:octet-vector converters)) (cell/new (cons 'nibbles:octet-vector (substitute-converter (cdr cell/old))))) (substitute cell/new cell/old converters))) (substitute-in-caching-converter (converter) (let* ((target (rsb.converter:converter-target converter)) (new-target (substitute-converter target))) (rsb.converter:make-converter :caching :target new-target))) (substitute-converter (converters) (etypecase converters (rsb.converter:caching-converter (substitute-in-caching-converter converters)) ((cons cons) (substitute-in-alist converters)) (sequence (substitute-in-sequence converters))))) (if ensure? (substitute-converter converters) converters))))
4,325
Common Lisp
.lisp
87
36.034483
92
0.564703
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
85abbefe5c72bad24895460be7237e749bea92e10503e67f784f341f4046e64b
37,347
[ -1 ]
37,348
package.lisp
open-rsx_rsb-tools-cl/src/common/package.lisp
;;;; package.lisp --- Package definition for common module. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.common (:use #:cl #:alexandria #:split-sequence #:let-plus #:iterate #:more-conditions #:net.didierverna.clon #:rsb) (:local-nicknames (#:bp #:architecture.builder-protocol)) ;; Conditions (:export #:call-specification-error #:call-specification-error-specification #:failed-to-load-idl #:failed-to-load-idl-source) ;; Variables (:export #:*info-output* #:*only-user-events-filter*) ;; Error handling (:export #:abort/signal #:continue/verbose #:maybe-relay-to-thread #:call-with-error-policy #:with-error-policy) ;; IDL loading (:export #:load-idl #:find-and-load-idl #:ensure-idl-loaded) ;; Logging (:export #:with-logged-warnings) (:export #:parse-payload-spec #:parse-call-spec #:parse-meta-data #:parse-timestamp #:parse-cause) ;; Commandline options (:export #:make-common-options #:process-commandline-options #:make-error-handling-options #:process-error-handling-options #:make-idl-options #:process-idl-options #:parse-instantiation-spec) ;; Interactive stuff (:export #:with-interactive-interrupt-exit) ;; Help text generation (:export #:show-help-for? #:with-abbreviation #:print-uri-help #:print-filter-help #:make-filter-help-string #:print-version #:print-classes-help-string #:first-line-or-less) ;; Debugging (:export #:trace-things #:disable-debugger #:start-swank #:enable-swank-on-signal) (:documentation "This package contains some common utility functions for RSB: + Commandline option definition and processing + Help text generation + Debugger control"))
1,916
Common Lisp
.lisp
81
19.740741
64
0.689197
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
85f5e8b60d07f5b8fabb69cd271a5f2d1db754c9c6cbc1afa841edabcb1f43ea
37,348
[ -1 ]
37,349
event.lisp
open-rsx_rsb-tools-cl/src/common/event.lisp
;;;; event.lisp --- Event construction utilities. ;;;; ;;;; Copyright (C) 2011-2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) (defun parse-payload-spec (spec) "Parse SPEC as an empty payload, a reference to standard input, a pathname or a Lisp object." (flet ((parse-file-based-payload-spec (spec &key (allow-binary? t)) (cond ;; "-[:binary]" => read from standard input. ((string= spec "-") (read-stream-content-into-string *standard-input*)) ((string= spec "-:binary") (unless allow-binary? (error "~@<Input from standard input stream cannot be ~ interpreted as binary data in this ~ context.~@:>")) (read-stream-content-into-byte-vector *standard-input*)) ;; "#p"NAMESTRING"[:(binary|EXTERNAL-FORMAT)]" => read ;; from file. ((ppcre:register-groups-bind (namestring) ("^#[pP]\"([^\"]+)\":binary$" spec) (unless allow-binary? (error "~@<Content of file ~S cannot be interpreted ~ as binary data in this context.~@:>" namestring)) (read-file-into-byte-vector (parse-namestring namestring)))) ((ppcre:register-groups-bind (namestring external-format) ("^#[pP]\"([^\"]+)\"(?::(.+))?$" spec) (let ((pathname (parse-namestring namestring)) (external-format (when external-format (make-keyword (string-upcase external-format))))) (apply #'read-file-into-string pathname (when external-format (list :external-format external-format))))))))) (cond ;; Empty string => no value. ((emptyp spec) rsb.converter:+no-value+) ;; "true", "false" => t, nil ((string= spec "true") t) ((string= spec "false") nil) ;; "/SCOPE" => parse scope. ((starts-with #\/ spec) (make-scope spec)) ;; File-based specs. ((parse-file-based-payload-spec spec)) ;; "pb:MESSAGE-NAME:(PATHNAME-SPEC|STDIN-SPEC|PROTOBUF-DEBUG-FORMAT)" ;; => parse protocol buffer debug text format and construct ;; message of type MESSAGE-NAME. ((ppcre:register-groups-bind (descriptor body) ("^pb:([^:]+):((?:.|\\n)*)$" spec) (let ((fields (or (when-let ((string (parse-file-based-payload-spec body :allow-binary? nil))) (string-trim '(#\Space #\Tab #\Newline) string)) body))) (build-protocol-buffer-message descriptor fields)))) ;; Otherwise try to `cl:read', potentially signaling an error. (t (let+ (((&values value consumed) (with-standard-io-syntax (let ((*read-default-float-format* 'double-float)) (read-from-string spec))))) (unless (= consumed (length spec)) (error "~@<Junk at end of argument string: ~S.~@:>" (subseq spec consumed))) value))))) (defun parse-call-spec (spec) (with-condition-translation (((error call-specification-error) :specification spec)) (ppcre:register-groups-bind (server-uri method arg) ("^(?:(.+))?/([-_a-zA-Z0-9]+)\\((.*)\\)$" spec) (return-from parse-call-spec (values (rsb::parse-scope-or-uri (or server-uri "/")) method (parse-payload-spec arg)))) (error "~@<The specification is not of the form ~ SERVER-URI/METHOD([ARGUMENT])~@:>" spec))) (defun parse-pair (pair &key (separator #\=) (first-transform #'identity) (second-transform #'identity)) (let ((index (or (position separator pair) (error "~@<~S is not of the form KEY~CVALUE.~@:>" pair separator)))) (list (funcall first-transform (subseq pair 0 index)) (funcall second-transform (subseq pair (1+ index)))))) (defun parse-meta-data (value) (parse-pair value :first-transform #'make-keyword)) (defun parse-timestamp (value) (parse-pair value :first-transform #'make-keyword :second-transform #'local-time:parse-timestring)) (defun parse-cause (value) (apply #'cons (parse-pair value :separator #\: :first-transform #'uuid:make-uuid-from-string :second-transform #'parse-integer)))
4,876
Common Lisp
.lisp
105
33.504762
77
0.522488
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5aa2a19b96b8b4f30202d3930d1346f9d18a819f1c0456ad2a8b7b3e42451df8
37,349
[ -1 ]
37,350
logging.lisp
open-rsx_rsb-tools-cl/src/common/logging.lisp
;;;; logging.lisp --- Logging-related functions. ;;;; ;;;; Copyright (C) 2011, 2013, 2014, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) ;;; Logging configuration (defun (setf log-level) (level) "Set log level LEVEL." (log:config :thread :ndc level)) ;;; Utility macros (defmacro with-logged-warnings (&body body) "Execute BODY with unhandled warnings translated to log messages with warning category." `(handler-bind ((warning (lambda (condition) (log:warn "~A: ~A" (type-of condition) condition) (muffle-warning)))) ,@body))
667
Common Lisp
.lisp
19
30.631579
68
0.664075
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c7015cc710e3c5ef16d0d375efb1bec2ea5f60fa85f91299530e638101e84dd6
37,350
[ -1 ]
37,351
debugger.lisp
open-rsx_rsb-tools-cl/src/common/debugger.lisp
;;;; debugger.lisp --- Disabling the debugger. ;;;; ;;;; Copyright (C) 2011-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) (defun trace-things (specs) "Like `trace', but SPECS is evaluated." #+sbcl (eval (sb-debug::expand-trace specs)) #-sbcl (error "Not implemented")) (defun disable-debugger () "Disable the debugger and return." ;; Reenable the debugger which has been disabled when dumping the ;; image. #+sbcl (sb-ext:enable-debugger) ;; Print condition with sane pretty printer state. (setf *debugger-hook* (lambda (condition previous-value) (declare (ignore previous-value)) (let ((right-margin (max 80 (or *print-right-margin* 0))) (miser-width (min 20 (or *print-miser-width* 0)))) (with-standard-io-syntax (let ((*print-pretty* t) (*print-right-margin* right-margin) (*print-miser-width* miser-width)) (format *error-output* "~&~@<~A~:>~%" condition)))) (uiop:quit 1)))) ;;; Swank (defun start-swank (&key (port-file "./swank-port.txt")) "Start a swank server and write its port to \"./swank-port.txt\"." ;; Load swank, if necessary. (unless (asdf:component-loaded-p (asdf:find-system :swank)) (when-let ((quickload (find-symbol (string '#:quickload) '#:ql))) (funcall quickload :swank))) ;; Delete old port file. (when (probe-file port-file) (delete-file port-file)) ;; Start the swank server. (uiop:symbol-call '#:swank '#:start-server port-file :dont-close t)) (defun enable-swank-on-signal (&key (signal #+(and sbcl (not win32)) sb-posix:SIGUSR1)) "Install a handler for SIGNAL that starts a swank server." #+(and sbcl (not win32)) (sb-unix::enable-interrupt signal (lambda (signal info context) (declare (ignore signal info context)) (start-swank))) #-sbcl (warn "~@<Cannot install signal handler to enable SWANK on this ~ implementation-platfom combination.~@:>"))
2,096
Common Lisp
.lisp
49
37
87
0.639882
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5877c4af02008afd13675572c7af55f1c48a18b1c6983528df5c3c598cec1d37
37,351
[ -1 ]
37,352
error-handling.lisp
open-rsx_rsb-tools-cl/src/common/error-handling.lisp
;;;; error-handling.lisp --- Toplevel error handling functions. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2016 Jan Moringen <[email protected]> ;;;; ;;;; This file may be licensed under the terms of the (cl:in-package #:rsb.tools.common) ;;; Toplevel error handling strategies (defun abort/signal (condition) "Like `cl:abort' but signal CONDITION using the `abort/signal' RESTART. This function is intended to be used as toplevel error policy." (if-let ((abort/signal (find-restart 'abort/signal condition))) (invoke-restart abort/signal condition) (abort condition))) (defun continue/verbose (&optional condition) "Like `cl:continue' but log a warning if `cl:continue' restart is established and a different warning if it is not. This function is intended to be used as toplevel error policy." (if-let ((restart (find-restart 'continue condition))) (progn (log:warn "Error encountered; Recovering via restart ~ ~:@_~:@_~<| ~@;~S: ~A~:>~ ~:@_~:@_. Further processing may yield partial or ~ incorrect results.~@[ Error was:~ ~:@_~:@_~<| ~@;~A~:>~ ~:@_~:@_.~]" (list (restart-name restart) restart) (when condition (list condition))) (invoke-restart restart)) (log:warn "No ~S restart; Cannot recover~@[. Error:~ ~:@_~:@_~<| ~@;~A~:>~ ~:@_~:@_.~]" 'continue (when condition (list condition))))) ;;; Toplevel utility functions and macros (defun maybe-relay-to-thread (policy &key (target-thread (bt:current-thread))) "Return a function of one argument which executes POLICY but establishes a TRANSFER-ERROR restart unless executing in TARGET-THREAD. Invoking the TRANSFER-ERROR restart does not perform a non-local control transfer. That is, POLICY still has to handle the condition after invoking the restart. POLICY has to accept a condition as its sole argument. TARGET-THREAD has to be a `bt:thread' object and defaults to the value of (bt:current-thread) in the thread calling this function." (lambda (condition) (let ((thread (bt:current-thread))) (cond ;; When executing in a different thread, CONDITION can be ;; transferred to TARGET-THREAD. We establish restarts for ;; that. ((not (eq thread target-thread)) (log:info "~@<Applying error policy ~A in background thread ~A~@:>" policy thread) (restart-case (funcall policy condition) (abort (&optional condition) (declare (ignore condition)) (bt:interrupt-thread target-thread #'abort)) (abort/signal (condition) (log:warn "Error policy ~A aborted with condition in ~ background thread ~A. Aborting with condition ~ in main thread. Condition was:~ ~:@_~:@_~<| ~@;~A~:>~ ~:@_~:@_." policy thread (list condition)) (bt:interrupt-thread target-thread (lambda () (invoke-restart 'abort/signal condition))))) ;; IF POLICY did not handle CONDITION or used one of our ;; restarts, we still have to abort the background thread. (log:info "~@<Aborting background thread ~A~@:>" thread) (abort)) ;; When executing in TARGET-THREAD, CONDITION cannot be ;; transferred. Thus, we do not establish any restarts. ;; When POLICY is `abort/signal', we can just unwind, ;; preserving the backtrace. ((eq policy #'abort/signal) (log:info "~@<Error policy ~S in thread ~A; unwinding normally~@:>" policy thread)) ;; Otherwise, we give POLICY a chance to handle CONDITION. (t (funcall policy condition) ;; If POLICY did not handle CONDITION, just we can just ;; unwind preserving the backtrace (as above). ))))) (declaim (ftype (function (function function) *) call-with-error-policy)) (defun call-with-error-policy (policy thunk) "Call THUNK with `cl:abort' and `abort/signal' restarts established. When an error is signaled, call POLICY to (potentially) handle it." (restart-case (handler-bind ((error policy)) (funcall thunk)) (abort (&optional condition) (declare (ignore condition)) (error "Aborted.")) (abort/signal (condition) (error condition)))) (defmacro with-error-policy ((policy) &body body) "Execute BODY with `cl:abort' and `abort/signal' restarts established. When an error is signaled, call POLICY to (potentially) handle it." `(call-with-error-policy (coerce ,policy 'function) (lambda () ,@body)))
4,936
Common Lisp
.lisp
106
37.377358
90
0.613754
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bd123284c176f0fdc7f8b88caa167b09f819944290b7977feadd1faa6b7d464c
37,352
[ -1 ]
37,353
options.lisp
open-rsx_rsb-tools-cl/src/common/options.lisp
;;;; options.lisp --- Common functions related to commandline options. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) (defun make-common-options (&key show) "Return a `clon:group' instance containing common program options." (defgroup (:header "General Options") (flag :long-name "version" :description "Print version information and exit.") (flag :long-name "help" :short-name "h" :description "Print this help and exit.") (stropt :long-name "help-for" :argument-name "CATEGORY" :description "Print help for specified categories and exit. This option can be supplied multiple times.") (enum :long-name "info-stream" :enum '(:stdout :standard-output :stderr :error-output :none) :default-value :error-output :argument-name "STREAM-NAME" :description "Stream to information messages should be sent.") (enum :long-name "log-level" :enum '(:off :trace :debug :info :warn :error :fatal) :default-value :warn :argument-name "LEVEL" :description "Controls the amount of generated log output.") (path :long-name "load" :type :file :hidden (not (show-help-for? :advanced-debug :show show)) :description "Load FILE. This option can be supplied multiple times. Files are loaded in the order in which they appear on the commandline.") (stropt :long-name "eval" :argument-name "SEXP" :hidden (not (show-help-for? :advanced-debug :show show)) :description "Evaluate SEXP as Lisp code. This option can be supplied multiple times. Code fragments are evaluated in the order in which they appear on the commandline.") (stropt :long-name "trace" :argument-name "SPEC" :hidden (not (show-help-for? :advanced-debug :show show)) :description "Trace specified things. This option can be supplied multiple times to trace multiple things. Each occurrence takes an argument which has to have one of the following forms: + \"PACKAGE\" (note the double quotes and uppercase): trace all functions in the package named PACKAGE. + function-name (note: no quotes, actual case of the function name): trace the named function.") (flag :long-name "debug" :hidden (not (show-help-for? :advanced-debug :show show)) :description "Enable debugging. This does the following things: + Set the log level such that debug output is emitted + Enable printing backtraces instead of just condition reports in case of unhandled error conditions.") (flag :long-name "swank" :hidden (not (show-help-for? :advanced-debug :show show)) :description "Start a swank listener (If you don't know what swank is, pretend this option does not exist - or google \"emacs slime\"). Swank will print the port it listens on. In addition, a file named \"./swank-port.txt\" containing the port number is written."))) (defun make-idl-options () "Return a `clon:group' instance containing IDL-related option definitions." (defgroup (:header "IDL Options") (path :long-name "idl-path" :short-name "I" :type :directory-list :default-value nil :description "A list of paths from which data definitions should be loaded. This option can be supplied multiple times.") (stropt :long-name "load-idl" :short-name "l" :argument-name "FILE-OR-GLOB-EXPRESSION" :description "Load data definition from FILE-OR-GLOB-EXPRESSION. If a glob expression is specified, in addition to the canonical globbing syntax, expressions of the form SOMESTUFF/**/MORESTUFF can be used to search directories recursively. If the file designated by FILE-OR-GLOB-EXPRESSION depend on additional data definition files (i.e. contain \"import\" statements), the list of directories supplied via the --idl-path option is consulted to find these files. This option can be supplied multiple times.") (enum :long-name "on-demand-idl-loading" :enum '(:none :blocking) :default-value :none :argument-name "BEHAVIOR" :description "Controls on-demand loading of required data definitions. none Do not attempt to load data definitions on demand. blocking Block computations requiring data definitions until the respective definition has been loaded and processed. Data definition files are located on the path specified using the --idl-path option."))) (defun make-error-handling-options (&key (show :default)) "Return a `clon:group' instance program options related to error handling." (declare (ignore show)) (defgroup (:header "Options related to Handling of Errors") (enum :long-name "on-error" :enum '(:abort :continue) :default-value :abort :argument-name "STRATEGY" :description "Behavior in case (serious) errors are encountered. abort Save and cleanup as much as possible, then terminate with unsuccessful result indication. continue Try to recover from errors and produce best-effort results."))) ;;; Option processing (defun collect-option-values (&rest spec &key (transform (lambda (string) (let ((*read-eval* nil)) (read-from-string string)))) &allow-other-keys) "Return a list of all values that have been supplied for the option specified by SPEC. TRANSFORM is applied to all option values." (let ((spec (remove-from-plist spec :transform))) (iter (for value/string next (apply #'getopt spec)) (while value/string) (collect (funcall transform value/string))))) (defun process-commandline-options (&key (commandline (net.didierverna.clon::cmdline)) (version '(0 1 0)) more-versions update-synopsis return) "Perform the following commandline option processing: + if --version has been supplied, print version information and call RETURN or exit. + if --help has been supplied, print a help text and call RETURN or exit. + if --trace has been supplied (at least once), trace the packages or functions specified in the arguments to --trace. + if --debug has been supplied, keep debugger enabled and adjust log-level, otherwise disable debugger + if --swank is supplied, start a swank server and write its port to ./swank-port.txt" ;; Create a new global context. (make-context :cmdline commandline) ;; Process output-related options (setf *info-output* (ecase (getopt :long-name "info-stream") ((:none) nil) ((:cout :stdout :standard-output) *standard-output*) ((:cerr :stderr :error-output) *error-output*))) ;; Process logging-related options. (let ((level (getopt :long-name "log-level"))) (setf (log-level) level)) ;; Process --trace options. (mapc #'trace-things (collect-option-values :long-name "trace" :transform (lambda (trace-spec) (with-input-from-string (stream trace-spec) (iter (for fragment in-stream stream) (collect fragment)))))) ;; Process --debug option. (unless (getopt :long-name "debug") (disable-debugger)) ;; Process --load options. (with-compilation-unit () (map nil #'load (collect-option-values :long-name "load" :transform #'identity))) ;; Process --eval options. (map nil #'eval (collect-option-values :long-name "eval")) ;; Process --swank option. (when (getopt :long-name "swank") (start-swank)) ;; Load specified RSB plugins, potentially updating the option ;; synopsis afterwards. ;; (rsb::load-plugins) ;; (when update-synopsis ;; (funcall update-synopsis) ;; ;; ;; Create a new global context. ;; (make-context)) ;; Process --version option. (when (getopt :long-name "version") (print-version version *standard-output* :more-versions more-versions) (terpri *standard-output*) (if return (funcall return) (exit 0))) ;; Process --help and --help-for options. (let ((show) (help (getopt :long-name "help"))) (iter (for category next (getopt :long-name "help-for")) (while category) (when (string= category "all") (setf show t) (terminate)) (push (make-keyword (string-upcase category)) show)) (when show (funcall update-synopsis :show show) (make-context :cmdline commandline)) (when (or help show) (help) (if return (funcall return) (exit 0))))) (defun process-error-handling-options () "Process the \"on-error\" commandline option mapping abort to `abort/verbose' and continue to `continue/verbose' and returning the respective function." (ecase (getopt :long-name "on-error") (:abort #'abort/signal) (:continue #'continue/verbose))) ;;; Instantiation spec parsing (defun parse-instantiation-spec (string) "Parse STRING as an instantiation specification of one of the forms KIND KEY1 VALUE1 KEY2 VALUE2 ... and KIND VALUE1 and return the result as a list." (maybe-expand-instantiation-spec (with-input-from-string (stream string) (iter (for token in-stream stream) (collect (if (and (first-iteration-p) (not (keywordp token))) (make-keyword (string-upcase (string token))) token)))))) (defun simple-instantiation-spec? (spec) "Return non-nil if SPEC is a \"simple\" instantiation specification of the form (KIND SOLE-ARGUMENT)." (and (length= 2 spec) (keywordp (first spec)))) (defun maybe-expand-instantiation-spec (spec) "Expand SPEC into a full instantiation specification if it is a simple specification. Otherwise, just return SPEC." (if (simple-instantiation-spec? spec) (cons (first spec) spec) spec))
11,373
Common Lisp
.lisp
241
36.809129
316
0.599423
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
693056c123fb3510a17270e2ec965dcfc7ccc523978d92138c659861aa15a9f0
37,353
[ -1 ]
37,354
conditions.lisp
open-rsx_rsb-tools-cl/src/common/conditions.lisp
;;;; conditions.lisp --- Conditions used in the rsb-tools-common system. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) ;;; Event and payload-related conditions (define-condition call-specification-error (rsb-error simple-error chainable-condition) ((specification :initarg :specification :type string :reader call-specification-error-specification :documentation "Stores the invalid specification.")) (:default-initargs :specification (missing-required-initarg 'call-specification-error :specification)) (:report (lambda (condition stream) (format stream "~@<Error parsing call specification ~S~ ~/more-conditions:maybe-print-explanation/~ ~:*~/more-conditions:maybe-print-cause/~@:>" (call-specification-error-specification condition) condition))) (:documentation "This error is signaled when a call specification cannot be parsed.")) ;;; IDL-related conditions (define-condition failed-to-load-idl (rsb-error chainable-condition) ((source :initarg :source :reader failed-to-load-idl-source :documentation "Stores a designator such as a name or definition source location of the IDL that could not be loaded.")) (:default-initargs :source (missing-required-initarg 'failed-to-load-idl :source)) (:report (lambda (condition stream) (format stream "~@<Failed to load data definition ~ ~A.~/more-conditions:maybe-print-cause/~@:>" (failed-to-load-idl-source condition) condition))) (:documentation "This error is signaled when an attempt to load a data definition fails.")) (defun failed-to-load-idl (source &optional cause) "Convenience function for signaling `failed-to-load-idl'." (apply #'error 'failed-to-load-idl :source source (when cause (list :cause cause))))
2,248
Common Lisp
.lisp
52
33.596154
86
0.624201
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7dd904995917677fcc682769598978aa91346f9b17faf0efa6112e61aa557215
37,354
[ -1 ]
37,355
idl-options.lisp
open-rsx_rsb-tools-cl/src/common/idl-options.lisp
;;;; idl-options.lisp --- IDL-related commandline options. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) (defun existing-directory-or-lose (pathname) "Signal an error unless PATHNAME designates an existing directory." (if-let ((truename (probe-file pathname))) (when (or (pathname-name truename) (pathname-type truename)) (error "~@<Not a directory: ~A.~@:>" truename)) (error "~@<Directory does not exist: ~A.~@:>" pathname))) (defun process-idl-options (&key (purpose nil purpose-supplied?)) "Process the options --idl-path and --load-idl by loading the specified IDL files." ;; Extend data definition source path. (iter (for paths next (getopt :long-name "idl-path")) (while paths) (iter (for path in paths) (with-simple-restart (continue "~@<Skip path ~S~@:>" path) (existing-directory-or-lose path) (pushnew path pbf:*proto-load-path*)))) ;; Load specified data definitions. (let ((sources (collect-option-values :long-name "load-idl" :transform #'identity))) (apply #'load-idl sources :auto (when purpose-supplied? (list :purpose purpose)))) ;; If requested, enable on-demand IDL loading. (case (getopt :long-name "on-demand-idl-loading") (:blocking (setf *load-idl-on-demand?* t))))
1,522
Common Lisp
.lisp
33
38.575758
72
0.625337
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fd2078d20ef7513872b404d87c3cbf589bae77cfd5ce6ec96d43f4503b81fb01
37,355
[ -1 ]
37,356
interactive.lisp
open-rsx_rsb-tools-cl/src/common/interactive.lisp
;;;; interactive.lisp --- Functions for interactive stuff. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) (defun call-with-interactive-interrupt-exit (thunk &key (signals #-win32 `(,sb-posix:SIGHUP ,sb-posix:SIGINT ,sb-posix:SIGTERM)) (target-thread (bt:current-thread))) (restart-case (labels (#-win32 (initial-handler (signal info context) (declare (ignore info context)) (log:info "~@<Caught signal ~D; aborting thread ~ ~A.~@:>" signal target-thread) ;; Install a handler which warns about the repeated ;; signal and then ignores it. (sb-unix::enable-interrupt signal #'noop-handler) ;; If TARGET-THREAD is being interrupted by the signal, ;; just abort. Otherwise interrupt TARGET-THREAD with ;; `abort'. (if (eq (bt:current-thread) target-thread) (abort) (bt:interrupt-thread target-thread #'abort))) (noop-handler (signal info context) (declare (ignore info context)) (log:warn "~@<Caught signal ~D during signal-triggered ~ shutdown; don't do this; ignoring the ~ signal~@:>" signal)) (install-handler (signal) #+win32 (declare (ignore signal)) #-win32 (sb-unix::enable-interrupt signal #'initial-handler))) ;; Install signal handlers unless on windows. #-win32 (mapcar #'install-handler signals) (funcall thunk)) ;; Establish an `abort' restart for signal handlers to invoke ;; (from TARGET-THREAD or other threads). (abort ()))) (defmacro with-interactive-interrupt-exit ((&key (signals nil signals-supplied?) (target-thread nil target-thread-supplied?)) &body body) "Run BODY with an interruption handler that exits non-locally and returns nil instead of entering the debugger." ;; This whole macro is mainly needed for two reasons: ;; 1. Protect against multiple signals ;; 2. Perform proper shutdown for signals other than SIGINT, ;; especially SIGTERM. `(call-with-interactive-interrupt-exit (lambda () ,@body) ,@(when signals-supplied? `(:signals ,signals)) ,@(when target-thread-supplied? `(:target-thread ,target-thread))))
2,615
Common Lisp
.lisp
61
32.836066
71
0.589181
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a1f7eca7e144cdd5d5b66027a7f43c6be2670b165bad358dcb937b93028737fd
37,356
[ -1 ]
37,357
variables.lisp
open-rsx_rsb-tools-cl/src/common/variables.lisp
;;;; variables.lisp --- Variables used in the rsb-tools-common system. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.common) ;;; Output-related variables (declaim (special *info-output*)) (defvar *info-output* *standard-output* "Stream to which status and information messages should be sent.") ;;; Pre-defined filters (defparameter *only-user-events-filter* (rsb.filter:filter `(:not (:scope :scope ,rsb:*reserved-scope*))) "A filter which filters implementation events.")
600
Common Lisp
.lisp
14
41
70
0.731034
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b28d17925a3637630e444360c908eb5cd4ccceb574ce672b277aa7976144261f
37,357
[ -1 ]
37,358
package.lisp
open-rsx_rsb-tools-cl/src/commands/package.lisp
;;;; package.lisp --- Package definition for the commands module. ;;;; ;;;; Copyright (C) 2013, 2014, 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.commands (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:rsb #:rsb.tools.common #:rsb.formatting) (:shadow #:call-method) ;; Utilities (:export #:coerce-to-scope-or-uri #:scope-or-uri-string #:uri-ensure-directory-path) ;; Command protocol (:export #:command-execute) ;; Command creation protocol (:export #:make-command) ;; Command style protocol and mixin (:export #:command-style #:command-style-service #:command-make-style #:style-mixin) ;; Command mixin classes (:export #:output-stream-mixin #:command-stream #:source-mixin #:command-uris #:destination-mixin #:command-destination #:payload-literal-mixin #:command-payload #:event-queue-mixin #:command-max-queued-events #:filter-mixin #:command-filters) ;; General purpose command classes (:export #:redump #:redump-output-file #:redump-static? #:redump-compression) (:documentation "Package definition for the commands module."))
1,285
Common Lisp
.lisp
56
19.214286
65
0.685384
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3ad612768bb1ccb17a3d323839ce7c15edfb16fde5925424a8cd00ea9666ad97
37,358
[ -1 ]
37,359
server.lisp
open-rsx_rsb-tools-cl/src/commands/server.lisp
;;;; server.lisp --- Implementation of the server command. ;;;; ;;;; Copyright (C) 2016, 2017, 2018 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) ;;; `server' command class (defclass server (source-mixin print-items:print-items-mixin) () (:documentation "Accept and service socket transport clients on one or more sockets.")) (service-provider:register-provider/class 'command :server :class 'server) (defmethod command-execute ((command server) &key error-policy) (let+ (((&accessors-r/o (uris command-uris)) command) (uris (mapcar #'%ensure-server-mode uris)) (participants '())) (unwind-protect (progn (mapc (lambda (uri) (format t "Creating server for ~A~%" uri) (push (make-participant :informer uri :introspection? nil :error-policy error-policy) participants)) uris) (format t "Ready~%") (loop (sleep 1))) (mapc #'detach/ignore-errors participants)))) ;;; Utilities (defun %ensure-server-mode (scope-or-uri) (let+ (((&flet check-scope (scope) (unless (scope= scope "/") (warn "~@<Ignoring scope ~A in ~A.~@:>" (scope-string scope) scope-or-uri)))) ((&flet+ check-transport ((transport &rest options)) (unless (member transport '(:socket :tcp-socket :unix :unix-socket)) (error "~@<Server mode is not supported for transport ~ ~A requested via ~A.~@:> " transport scope-or-uri)) (when (member (getf options :server :missing) '(nil "0" "false" "auto") :test #'equal) (error "~@<Cannot create transport according to ~A: ~ server mode must be enabled.~:@>" scope-or-uri)))) ((&flet check-options (raw-options) (let* ((all-options (rsb::effective-transport-options (rsb::merge-transport-options raw-options (transport-options))))) (mapc #'check-transport all-options))))) (etypecase scope-or-uri (puri:uri (let+ ((query (puri:uri-query scope-or-uri)) (query (if (and query (search "server=" query)) query (format nil "~A~@[&~A~]" "server=1" (puri:uri-query scope-or-uri)))) (uri (puri:copy-uri scope-or-uri :path "/" :query query)) ((&values scope options) (rsb:uri->scope-and-options uri))) (check-scope scope) (check-options options) uri)) (scope (check-scope scope-or-uri) (check-options '()) (make-instance 'puri:uri :path "/" :query "server=1")))))
3,087
Common Lisp
.lisp
70
30.985714
76
0.515947
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
79db4bdc199bd756e5b216caf594b3e16519ea72ad5dce3942b258559fce0ae3
37,359
[ -1 ]
37,360
util.lisp
open-rsx_rsb-tools-cl/src/commands/util.lisp
;;;; util.lisp --- Utilities shared between commands. ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) ;;; Scopes and URIs (defun coerce-to-scope-or-uri (thing) (etypecase thing (string (puri:parse-uri thing)) ((or scope puri:uri) thing))) (defun scope-or-uri-string (thing) (etypecase thing (puri:uri thing) (scope (scope-string thing)))) (defun uri-ensure-directory-path (uri) (let ((path (puri:uri-path uri))) (if (ends-with #\/ path) uri (puri:copy-uri uri :path (concatenate 'string path "/"))))) ;;; Converters (defun ensure-fallback-converter (&key (converters (default-converters))) (mapcar (lambda+ ((wire-type . converter)) (cons wire-type (if (and (listp converter) (not (member :fundamental-null converter))) (append converter '(:fundamental-null)) converter))) converters)) (defun make-annotating-converter-for-everything () `((t . ,(make-instance 'rsb.converter::annotating)))) ;;; Queuing (define-condition queue-overflow-error (rsb-error) ((capacity :initarg :capacity :type non-negative-integer :reader queue-overflow-error-capacity :documentation "Stores the capacity of the queue in question.") (count :initarg :count :type non-negative-integer :reader queue-overflow-error-count :documentation "Stores the number of queued items when the queue overflowed.")) (:default-initargs :capacity (missing-required-initarg 'queue-overflow-error :capacity) :count (missing-required-initarg 'queue-overflow-error :count)) (:report (lambda (condition stream) (format stream "~@<~:D event~:P in queue with capacity ~:D.~@:>" (queue-overflow-error-capacity condition) (queue-overflow-error-count condition)))) (:documentation "This error is signaled when an attempt is made to push an item onto a full fixed-capacity queue.")) (defun make-queue (&key max-queued-events) (apply #'lparallel.queue:make-queue (when max-queued-events (list :fixed-capacity max-queued-events)))) (defun make-handler (queue) (lambda (event) (lparallel.queue:with-locked-queue queue ;; When QUEUE is full, establish a restart for flushing it ;; and signal an error. (when (lparallel.queue:queue-full-p/no-lock queue) (restart-case (error 'queue-overflow-error :capacity (lparallel.queue:queue-count/no-lock queue) :count (lparallel.queue:queue-count/no-lock queue)) (continue (&optional condition) :report (lambda (stream) (format stream "~@<Flush all queued events ~ and try to continue.~@:>")) (declare (ignore condition)) (iter (until (lparallel.queue:queue-empty-p/no-lock queue)) (lparallel.queue:pop-queue/no-lock queue))))) ;; Potentially after flushing QUEUE, push EVENT onto it. (lparallel.queue:push-queue/no-lock event queue)))) (defun make-queue-and-handler (&key max-queued-events) (let ((queue (make-queue :max-queued-events max-queued-events))) (values queue (make-handler queue))))
3,525
Common Lisp
.lisp
81
35.185185
73
0.624198
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
52b97516bd3fe3722981337b88a7289b1b404e9db38085d3c8b052d1dfc52602
37,360
[ -1 ]
37,361
protocol.lisp
open-rsx_rsb-tools-cl/src/commands/protocol.lisp
;;;; protocol.lisp --- Protocol provided by the commands module. ;;;; ;;;; Copyright (C) 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) ;;; Command protocol (defgeneric command-execute (command &key error-policy) (:documentation "Execute COMMAND applying ERROR-POLICY in case of errors.")) ;;; Command creation protocol (defgeneric make-command (spec &rest args) (:documentation "Make and return a command instance according to SPEC and ARGS. SPEC must designate a command register in the `command' service.")) ;; Default behavior (defmethod make-command ((spec cons) &rest args) (check-type spec (cons keyword list) "a keyword followed by initargs") (apply #'make-command (first spec) (append (rest spec) args))) (defmethod make-command ((spec t) &rest args &key (service 'command) &allow-other-keys) (apply #'service-provider:make-provider service spec (remove-from-plist args :service))) ;;; Command service (service-provider:define-service command (:documentation "Providers of this service define commands which can be executed by the rsb commandline tool.")) ;;; Command style protocol (defgeneric command-style (command) (:documentation "Return the formatting style used by COMMAND.")) (defgeneric command-style-service (command) (:documentation "Return a designator of the service that should be used to create formatting style instances for COMMAND.")) (defgeneric command-make-style (command spec service) (:documentation "Make and return a style instance according to SPEC and SERVICE. SPEC is a string or sexp specification of the desired style. SERVICE is designator of the service that should be used to make the style instance."))
1,848
Common Lisp
.lisp
43
39.302326
78
0.74217
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ecaf3295a3397a7280a27f4c1a5ae160220e827ebd8ffc6f4ed88a4f7401bf66
37,361
[ -1 ]
37,362
introspect.lisp
open-rsx_rsb-tools-cl/src/commands/introspect.lisp
;;;; introspect.lisp --- Implementation of the introspect command. ;;;; ;;;; Copyright (C) 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) (defclass introspect (source-mixin response-timeout-mixin output-stream-mixin style-mixin print-items:print-items-mixin) ((style-service :allocation :class :initform 'rsb.formatting.introspection::style)) (:documentation "Display information about hosts, processes and participants in a system. The introspection information is limited to hosts, processes and RSB participants reachable via the transports designated by URI* (zero or more URIs). When no URIs are supplied, the default transport configuration is used.")) (service-provider:register-provider/class 'command :introspect :class 'introspect) (defmethod command-execute ((command introspect) &key error-policy) (let+ (((&structure-r/o command- uris stream style response-timeout) command)) (unwind-protect (with-participant (introspection :remote-introspection rsb.introspection:+introspection-scope+ :receiver-uris uris :error-policy error-policy :change-handler (lambda (&rest event) (rsb.ep:handle style event)) :response-timeout response-timeout) (setf (rsb.formatting.introspection::style-database style) (rsb.introspection::introspection-database introspection)) (when (rsb.introspection:with-database-lock (introspection) (rsb.formatting:format-event :dummy style stream)) (sleep most-positive-fixnum))) (detach/ignore-errors style))))
1,897
Common Lisp
.lisp
40
37.45
76
0.650459
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
16ff0c021e336bd15ab4692d3233d8f2f9121db30fab5adb1a34d81a6418bcf1
37,362
[ -1 ]
37,363
logger.lisp
open-rsx_rsb-tools-cl/src/commands/logger.lisp
;;;; logger.lisp --- Implementation of the logger command. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) ;;; Queue and listener management (defun make-queue-pushing-listener (handler uri error-policy filters converters) (let ((listener (make-participant :listener uri :transports '((t :expose (:rsb.transport.wire-schema :rsb.transport.payload-size) &inherit)) :converters converters :error-policy error-policy :filters filters :handlers (list handler)))) (log:info "~@<Created listener ~A~@:>" listener) listener)) ;;; `logger' command class (defclass logger (source-mixin filter-mixin event-queue-mixin output-stream-mixin style-mixin print-items:print-items-mixin) ((while :initarg :while :type (or null function) :reader logger-while :initform nil :documentation "Stores a function that, when called with the number of events processed so far and the current event, returns Boolean to indicate whether processing should continue.")) (:default-initargs :filters (list *only-user-events-filter*)) (:documentation "Display events as they are exchanged between RSB participants. Events can be filtered and displayed in several ways which can be controlled using the --filter and --style options. URIs designate the channel or channels for which events should be received and logged and the transport that should be used to attach to channel(s). If no URIs are specified, the root scope / and default transports are assumed. Use the --help-for=uri or --help-for=all options to display the full help text for this item.")) (service-provider:register-provider/class 'command :logger :class 'logger) (defun process-events (queue stream style &key while) ;; Process events in QUEUE until interrupted, if WHILE is a ;; function, calling WHILE returns false. (let ((continue-function nil)) ; TODO there is a macro for this in rsbag (restart-bind ((continue (lambda (&optional condition) (declare (ignore condition)) (funcall continue-function)) :test-function (lambda (condition) (declare (ignore condition)) continue-function) :report-function (lambda (stream) (format stream "~@<Ignore the ~ failure and ~ continue ~ processing.~@:>")))) (macrolet ((do-it (&optional while) `(iter ,@(when while `((for i :from 0) (while (funcall ,while i event)))) (for event next (lparallel.queue:pop-queue queue)) (when (first-iteration-p) (setf continue-function (lambda () (iter:next-iteration)))) ;; Process EVENT with STYLE. (format-event event style stream)))) (if while (locally (declare (type function while)) (do-it while)) (do-it)))))) (defmethod command-execute ((command logger) &key error-policy) (let+ (((&accessors-r/o (uris command-uris) (max-queued-events command-max-queued-events) (stream command-stream) (style command-style) (filters command-filters) (while logger-while)) command) (converters (rsb.tools.common::maybe-ensure-idl-loading-converter :converters (ensure-fallback-converter))) ((&values queue handler) (make-queue-and-handler :max-queued-events max-queued-events)) (listeners '())) (unwind-protect (progn (mapc (lambda (uri) (push (make-queue-pushing-listener handler uri error-policy filters converters) listeners)) uris) (process-events queue stream style :while while)) (mapc #'detach/ignore-errors listeners))))
4,811
Common Lisp
.lisp
100
33.14
80
0.535745
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5b95eeed804d68beedd9b6428b1b5b7ff0dfe28f117cc09ca1bbfb6fa8379459
37,363
[ -1 ]
37,364
call.lisp
open-rsx_rsb-tools-cl/src/commands/call.lisp
;;;; call.lisp --- Implementation of the call command. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) (eval-when (:compile-toplevel :load-toplevel :execute) (defclass call (destination-mixin payload-literal-mixin style-mixin print-items:print-items-mixin) ((method :initarg :method :type rsb.patterns.request-reply:method-name :reader call-method :documentation "The name of the method that should be called on the remote server.") (timeout :initarg :timeout :type (or null non-negative-real) :reader call-timeout :initform nil :documentation "If the result of the method call does not arrive within the amount of time specified by SPEC, consider the call to have failed and exit with non-zero status.") (no-wait? :initarg :no-wait? :type boolean :reader call-no-wait? :initform nil :documentation "Do not wait for the result of the method call. Immediately return with zero status without printing a result to standard output.")) (:default-initargs :method (missing-required-initarg 'call :method)) (:documentation "Call METHOD of the server at SERVER-URI with argument ARG. ARG is parsed as string when surrounded with double-quotes and as integer or float number when consisting of digits without and with decimal point respectively. If ARG is the single character \"-\", the entire \"contents\" of standard input (until end of file) is read as a string and used as argument for the method call. If ARG is the empty string, i.e. the call specification is of the form SERVER-URI/METHOD(), the method is called without argument. SERVER-URI designates the root scope of the remote server and the transport that should be used.")) (service-provider:register-provider/class 'command :call :class 'call)) (defmethod print-items:print-items append ((object call)) `((:method ,(call-method object) " ~A" ((:after :destination-uri))))) (defmethod service-provider:make-provider ((service (eql (service-provider:find-service 'command))) (provider (eql (service-provider:find-provider 'command :call))) &rest args &key destination method (payload nil payload-supplied?) (payload-spec nil payload-spec-supplied?) (call-spec nil call-spec-supplied?)) ;; Check argument compatibility. (when (and call-spec (or destination method payload-spec-supplied? payload-supplied?)) (incompatible-initargs 'call :call-spec call-spec :destination destination :method method :payload payload :payload-spec payload-spec)) ;; If supplied, parse and translate CALL-SPEC. (if call-spec-supplied? (let+ (((&values uri method arg) (parse-call-spec call-spec))) (apply #'call-next-method service provider :destination uri :method method :payload arg (remove-from-plist args :call-spec))) (call-next-method))) (defmethod shared-initialize :before ((instance call) (slot-names t) &key timeout no-wait?) (when (and timeout no-wait?) (incompatible-initargs 'call :timeout timeout :no-wait? no-wait?))) (defmethod command-execute ((command call) &key error-policy) (let+ (((&accessors-r/o (destination command-destination) (arg command-payload) (style command-style) (method call-method) (timeout call-timeout) (no-wait? call-no-wait?)) command) ((&flet call/raw (server) (cond (no-wait? (rsb.patterns.request-reply:call server method arg :block? nil) (values)) ((not timeout) (rsb.patterns.request-reply:call server method arg :return :event)) (t (handler-case (rsb.patterns.request-reply:call server method arg :return :event :timeout timeout) (bt:timeout (condition) (declare (ignore condition)) (error "~@<Method call timed out after ~S ~ second~:P.~@:>" timeout))))))) ((&flet call/translate (server) (let ((event (call/raw server))) (cond ((not event) (values)) ((typep (event-data event) 'rsb.converter:no-value) (values)) (t event))))) (converters (rsb.tools.common::maybe-ensure-idl-loading-converter))) (log:info "~@<Using URI ~S method ~S arg ~A~@:>" destination method arg) (with-participant (server :remote-server destination :error-policy error-policy :converters converters) (when-let ((reply (multiple-value-list (call/translate server)))) (format-event (first reply) style *standard-output*)))))
6,106
Common Lisp
.lisp
133
31.353383
78
0.527764
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
99656d3c610405fbe9f2dccede62fdfe0ff3e206abd688886a03ea036e0045dc
37,364
[ -1 ]
37,365
send.lisp
open-rsx_rsb-tools-cl/src/commands/send.lisp
;;;; send.lisp --- Entry point of the send tool. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) (defclass send (destination-mixin payload-literal-mixin print-items:print-items-mixin) ((method :initarg :method :type (or null string) :reader send-method :documentation "Set the method field of the event being sent to METHOD. Default behavior is sending an event without method field.") (meta-data :initarg :meta-data :type list #| of (cons keyword (cons string null)) |# :reader send-meta-data :documentation "Set the meta-data item NAME to VALUE in the event being sent. This option can be specified multiple times for distinct NAMEs." ;; argument-spec NAME=VALUE ) (timestamps :initarg :timestamps :initarg :timestamp :type list #| of local-time:timestamp |# :reader send-timestamps :documentation "Set the timestamp named NAME to the timestamp YYYY-MM-DD[THH:MM:SS[.µµµµµµ[+ZH:ZM]]] in the event being sent. This option can be specified multiple times for distinct NAMEs." ;; argument-spec NAME=YYYY-MM-DD[THH:MM:SS[.µµµµµµ[+ZH:ZM]]] ) (causes :initarg :causes :initarg :cause :type list #| of event-id |# :reader send-causes :documentation "Add the event id described by PARTICIPANT-ID:SEQUENCE-NUMBER to the cause vector of the event being sent. This option can be specified multiple times." ;; argument-spec "PARTICIPANT-ID:SEQUENCE-NUMBER" )) (:documentation "Send an event constructed according to EVENT-SPEC to listeners on scopes specified by DESTINATION-URI. EVENT-SPEC is parsed as string when surrounded with double-quotes and as integer or float number when consisting of digits without and with decimal point respectively. If EVENT-SPEC is the single character \"-\", the entire \"contents\" of standard input (until end of file) is read as a string and used as argument for the method send. DESTINATION-URI designates the destination scope to which the event should be sent and the transport configuration which should be used for sending the event.")) (service-provider:register-provider/class 'command :send :class 'send) (defmethod command-execute ((command send) &key error-policy) (let+ (((&accessors-r/o (destination command-destination) (payload command-payload) (method send-method) (meta-data send-meta-data) (timestamps send-timestamps) (causes send-causes)) command) (converters (rsb.tools.common::maybe-ensure-idl-loading-converter))) (with-participant (informer :informer destination :error-policy error-policy :converters converters) (apply #'send informer payload (append (when method (list :method method)) (when timestamps (list :timestamps timestamps)) (when causes (list :causes causes)) meta-data)))))
3,744
Common Lisp
.lisp
78
35.089744
77
0.577461
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d87ca54fce0f0e88c0e378a0c28b1603a9fd6f2efa55ab1e35f5f8a5879fa0bd
37,365
[ -1 ]
37,366
redump.lisp
open-rsx_rsb-tools-cl/src/commands/redump.lisp
;;;; redump.lisp --- Implementation of the redump command. ;;;; ;;;; Copyright (C) 2014, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands) ;;; Library loading behavior (defun make-static () "Hard-wire locations of foreign libraries." ;; Do not reload Spread library. #-win32 (when (find-package '#:network.spread-system) (unless (uiop:symbol-call '#:network.spread-system '#:spread-library-pathname) (error "~@<Spread library pathname not provided (use ~ SPREAD_LIBRARY environment variable).~@:>")) (uiop:symbol-call '#:network.spread '#:use-spread-library :pathname (uiop:symbol-call '#:network.spread-system '#:spread-library-pathname)) (uiop:symbol-call '#:network.spread '#:disable-reload-spread-library))) (defun make-dynamic () "Enable dynamic search for and loading of foreign libraries." ;; Try to reload Spread library. #-win32 (when (find-package '#:network.spread) (ignore-errors (uiop:symbol-call '#:network.spread '#:use-spread-library :pathname nil)) (uiop:symbol-call '#:network.spread '#:enable-reload-spread-library :if-fails #'warn))) ;;; `redump' command class (defclass redump () ((output-file :type pathname :reader redump-output-file :writer (setf redump-%output-file) :documentation "The file into which the current image should be dumped.") (static? :initarg :static? :type boolean :reader redump-static? :initform nil :documentation "Should the binary be static in the sense of expecting foreign libraries in the locations they have been loaded from or should foreign libraries be searched for on startup?") (compression :initarg :compression :type (or null (integer 0 9)) :reader redump-compression :initform nil :documentation "Should the dumped binary be compressed and if so, to which extend? 0 is minimum compression, 9 is maximum compression.")) (:default-initargs :output-file (missing-required-initarg 'redump :output-file)) (:documentation "Dump this program into a new binary. With the specified library loading behavior and the specified core compression.")) (service-provider:register-provider/class 'command :redump :class 'redump) (defmethod shared-initialize :after ((instance redump) (slot-names t) &key (output-file nil output-file-supplied?)) (when output-file-supplied? (setf (redump-%output-file instance) (etypecase output-file (string (parse-namestring output-file)) (pathname output-file))))) (defmethod command-execute ((command redump) &key error-policy) (declare (ignore error-policy)) (let+ (((&structure-r/o redump- output-file static? compression) command)) ;; Change behavior for foreign libraries. Either hard-wire their ;; names into the dumped image ("static") or search for them on ;; image restart. (if static? (make-static) (make-dynamic)) ;; Create new binary. #-sb-core-compression (when compression (warn "~@<Compression is not supported in this ~ implementation~@:>")) (uiop:dump-image output-file :executable t #+sb-core-compression :compression #+sb-core-compression compression)))
3,866
Common Lisp
.lisp
87
34.08046
82
0.60446
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
96ca80e0e1ecc939a4aa466814f4dcedb80517ac7f4067072b3a18c8ae97ff7c
37,366
[ -1 ]
37,367
model.lisp
open-rsx_rsb-tools-cl/src/commands/bridge/model.lisp
;;;; model.lisp --- Description of bridge configurations. ;;;; ;;;; Copyright (C) 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.bridge) ;;; Model classes (macrolet ((define-model-class ((kind &key (name (format-symbol *package* "~A-~A" kind '#:description)) (constructor (format-symbol *package* "~A-~A" '#:make name))) &rest slots) (let+ (((&flet+ composite-slot? ((&ign kind &rest &ign)) (not (eq kind :scalar)))) (scalar-slots (remove-if #'composite-slot? slots)) (composite-slots (set-difference slots scalar-slots)) ((&flet+ make-scalar-slot ((name kind &key type)) (declare (ignore kind)) `(,name nil :type ,type :read-only t))) ((&flet+ make-composite-slot ((name kind &key type)) (etypecase kind ((cons (eql :composite) (cons (eql 1) null)) `(,name nil :type ,type)) ((cons (eql :composite) (cons (eql ?) null)) `(,name nil :type (or null ,type))) ((cons (eql :composite) (cons (eql *) null)) `(,name nil :type list))))) ((&flet+ make-keyword-parameter((name &rest &ign)) `(,name (missing-required-argument ,(make-keyword name))))) ((&flet+ make-initarg ((name &rest &ign)) `(,(make-keyword name) ,name))) ((&flet+ make-relate-method (name (slot-name slot-kind &key type)) (let ((accessor-name (symbolicate name '#:- slot-name))) `(defmethod architecture.builder-protocol:relate ((builder t) (relation (eql ,(make-keyword slot-name))) (left ,name) (right ,type) &key) ,(etypecase slot-kind ((cons (eql :composite) (cons (member 1 ?()) null)) `(setf (,accessor-name left) right)) ((cons (eql :composite) (cons (eql *) null)) `(appendf (,accessor-name left) (list right)))) left))))) `(progn (defstruct (,name (:predicate nil) (:copier nil)) ,@(mapcar #'make-scalar-slot scalar-slots) ,@(mapcar #'make-composite-slot composite-slots)) (defmethod architecture.builder-protocol:make-node ((builder t) (kind (eql ,kind)) &key ,@(mapcar #'make-keyword-parameter scalar-slots)) (,constructor ,@(mapcan #'make-initarg scalar-slots))) ,@(mapcar (curry #'make-relate-method name) composite-slots))))) (define-model-class (:input) (uri :scalar :type puri:uri)) (define-model-class (:output) (uri :scalar :type puri:uri)) (define-model-class (:filter) (class :scalar :type symbol) (initargs :scalar :type list)) (define-model-class (:transform) (class :scalar :type symbol) (initargs :scalar :type list)) (define-model-class (:connection) (inputs (:composite *) :type input-description) (outputs (:composite *) :type output-description) (filters (:composite *) :type filter-description) (transform (:composite ?) :type transform-description) (other-direction (:composite 1) :type t)) (define-model-class (:bridge) (connections (:composite *) :type connection-description))) (defmethod print-object ((object connection-description) stream) (let ((*print-circle* t)) (call-next-method))) ;;; Model checks (defmethod communication? ((output output-description) (input input-description)) ;; TODO consider filters and configuration (communication? (output-description-uri output) (input-description-uri input))) ;; Check DESCRIPTION for problems and either signal a (continuable) ;; error and/or return two values: 1) the checked DESCRIPTION 2) a ;; list of "problems" of the form ;; ;; (INPUT . OUTPUTS) ;; ;; where INPUT is an `input-description' and OUTPUTS is a list of ;; `output-description' such that INPUT would receive events sent by ;; each element of OUTPUTS. (defun check-description (description) (let+ (((&structure-r/o bridge-description- connections) description) (problems ()) ((&flet maybe-problem (kind input input-connection output output-connection) (when (and (eq output-connection (connection-description-other-direction input-connection)) (eq input-connection (connection-description-other-direction output-connection))) (return-from maybe-problem)) (funcall (ecase kind (error (lambda (&rest args) (with-simple-restart (continue "Continue anyway") (apply #'error 'forwarding-cycle-error args)))) (warning (curry #'warn 'forwarding-cycle-warning))) :source input :destination output))) ((&flet record (input output) (if-let ((cell (assoc input problems))) (push output (cdr cell)) (push (cons input (list output)) problems)))) ((&flet+ check-pair ((output output-connection) (input input-connection)) (let+ (((&values result definitive?) (communication? output input))) (cond ((and result definitive?) (maybe-problem 'error input input-connection output output-connection) (record input output)) ((and (not result) (not definitive?)) (maybe-problem 'warning input input-connection output output-connection) (record input output)))))) (all-inputs '()) (all-outputs '()) ((&flet add-inputs+outputs (connection) (let+ (((&structure-r/o connection-description- inputs outputs) connection)) (appendf all-inputs (mapcar #'list inputs (circular-list connection))) (appendf all-outputs (mapcar #'list outputs (circular-list connection))))))) (mapc #'add-inputs+outputs connections) (map-product #'check-pair all-outputs all-inputs) (values description problems))) ;;; Utility functions (declaim (ftype (function (bridge-description list) (values list list)) bridge-description->connection-list)) (defun bridge-description->connection-list (spec self-filters) (let+ ((self-filters self-filters) ((&flet register-description-data (description data) (setf self-filters (sublis (list (cons description data)) self-filters)) data)) ((&flet extract-input-uri (description) (register-description-data description (input-description-uri description)))) ((&flet extract-output-uri (description) (let ((uri (puri:copy-uri (output-description-uri description))) (id (uuid:make-v4-uuid))) (register-description-data description (cons uri id))))) ((&flet make-filter (description) (apply #'rsb.filter:make-filter (filter-description-class description) (filter-description-initargs description)))) ((&flet make-transform (description) (apply #'rsb.transform:make-transform (transform-description-class description) (transform-description-initargs description)))) ((&flet process-spec (spec) (let+ (((&structure-r/o connection-description- inputs outputs filters transform) spec)) (list (mapcar #'extract-input-uri inputs) (mapcar #'extract-output-uri outputs) (mapcar #'make-filter filters) (when transform (make-transform transform)))))) (connections (when spec (mapcar #'process-spec (bridge-description-connections spec))))) (values connections self-filters)))
8,854
Common Lisp
.lisp
183
34.650273
80
0.541368
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
48430b9d97c070d2da2197b9aaf7bddb26ef607a304660caf7d1f23eed6fbc6f
37,367
[ -1 ]
37,368
command.lisp
open-rsx_rsb-tools-cl/src/commands/bridge/command.lisp
;;;; command.lisp --- Implementation of the bridge command. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.bridge) ;;; `bridge' command class (defclass bridge (rsb.tools.commands:event-queue-mixin print-items:print-items-mixin) ((spec :initarg :spec :type bridge-description :reader bridge-spec :documentation "Stores the specification according to which the bridge should be constructed and configured.") (self-filters :initarg :self-filters :type list :reader bridge-self-filters :documentation "Stores a list of filters necessary to prevent forwarding cycles that would otherwise be caused by events sent by the bridge and then received by the bridge.")) (:default-initargs :spec (missing-required-initarg 'bridge :spec)) (:documentation "Forward events from one part of a system to other parts of the system. When executed, the bridge command instantiates a bridge participant containing one or more connection participants. Each connection performs uni- or bidirectional forwarding of events between parts of the RSB system described by transports, scopes and filters.")) (service-provider:register-provider/class 'rsb.tools.commands::command :bridge :class 'bridge) (defmethod shared-initialize :around ((instance bridge) (slot-names t) &rest args &key spec) ;; `check-description' signals (continuable) errors and warnings for ;; detected cycles and returns a list of necessary "self-filters" as ;; its second value. (let+ (((&values spec self-filters) (with-condition-translation (((error specification-error) :spec spec)) (check-description (etypecase spec (string (parse-spec spec)) (bridge-description spec)))))) (apply #'call-next-method instance slot-names :spec spec :self-filters self-filters (remove-from-plist args :spec)))) (defmethod command-execute ((command bridge) &key error-policy) ;; `bridge-description->connection-list' transforms the list of ;; self-filter specifications of the form ;; ;; (INPUT-DESCRIPTION . (OUTPUT-DESCRIPTION₁ OUTPUT-DESCRIPTION₂ …)) ;; ;; into a list of specifications of the form ;; ;; (INPUT-URI . ((OUTPUT-URI₁ . OUTPUT-ID₁) (OUTPUT-URI₂ . OUTPUT-ID₂) …)) ;; ;; which the participant turns into a set of filters while creating ;; its child-participants. (let+ (((&accessors-r/o (max-queued-events command-max-queued-events) (spec bridge-spec) (self-filters bridge-self-filters)) command) ((&values connections self-filters) (bridge-description->connection-list spec self-filters)) (converters (rsb.tools.common::maybe-ensure-idl-loading-converter :converters (rsb.tools.commands::ensure-fallback-converter)))) (with-participant (bridge :bridge "/" :converters converters :connections connections :self-filters self-filters :max-queued-events max-queued-events :error-policy error-policy) (rsb.patterns.bridge:pump-events bridge))))
3,831
Common Lisp
.lisp
79
36.696203
84
0.595602
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
45e7064d8489efb272adb2d7f9511e4d4a3d09d7a3b9854f465e0f4e765cb239
37,368
[ -1 ]
37,369
package.lisp
open-rsx_rsb-tools-cl/src/commands/bridge/package.lisp
;;;; package.lisp --- Package definition for implementation of the bridge command. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.commands.bridge (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:rsb #:rsb.tools.common #:rsb.tools.commands) (:local-nicknames (#:bp #:architecture.builder-protocol)) (:import-from #:esrap #:defrule #:? #:&) (:import-from #:parser.common-rules #:whitespace+ #:whitespace* #:defrule/s) (:import-from #:rsb.model.inference #:communication?) ;; Conditions (:export #:specification-condition #:specification-condition-spec #:specification-error #:forwarding-cycle-condition #:forwarding-cycle-condition-source #:forwarding-cycle-condition-destination #:forwarding-cycle-warning #:forwarding-cycle-error) (:export #:parse-spec) (:documentation "This package contains the implementation of the bridge command."))
1,053
Common Lisp
.lisp
39
23.307692
82
0.703704
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e675286fdb24d06a24e521a50f732f97e108ee6dbc63bff5b739d51aedcf85c3
37,369
[ -1 ]
37,370
grammar.lisp
open-rsx_rsb-tools-cl/src/commands/bridge/grammar.lisp
;;;; grammar.lisp --- Grammar for simple forwarding specification . ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.bridge) ;;; Rules (defrule skippable whitespace+) (defrule skippable? whitespace*) (defrule bridge-specification connection-list (:lambda (connections) (bp:node* (:bridge) (* :connections connections)))) (defrule connection-list (or (and (+ connection+semicolon/?s) connection) (and (and connection) (and))) (:destructure (rest last) (reduce #'append rest :initial-value last))) (defrule/s connection+semicolon (and connection/?s semicolon-keyword) (:function first)) (defrule/s connection (or connection/bidirectional connection/unidirectional)) (let+ (((&flet make-connection (inputs outputs &optional filters transform) (bp:node* (:connection) (* :inputs inputs) (* :outputs outputs) (* :filters filters) (1 :transform transform))))) (defrule connection/unidirectional (and (+ input/?s) right-arrow-keyword/?s (* filter/?s) (? transform/?s) output-list) (:destructure (inputs operator filters transform outputs) (declare (ignore operator)) (list (make-connection inputs outputs filters transform)))) (defrule connection/bidirectional (and (+ input/?s) left-right-arrow-keyword/?s output-list) (:destructure (inputs operator outputs) (declare (ignore operator)) (let+ (((&flet extract-uri (description) (etypecase description (input-description (input-description-uri description)) (output-description (output-description-uri description))))) ((&flet input->output (input) (bp:node* (:output :uri (extract-uri input))))) ((&flet output->input (output) (bp:node* (:input :uri (extract-uri output))))) (to (make-connection inputs outputs)) (from (make-connection (mapcar #'output->input outputs) (mapcar #'input->output inputs)))) (bp:relate* :other-direction to from) (bp:relate* :other-direction from to) (list to from))))) (defrule output-list (or (and (+ output-with-successor) (and output)) (and (and output) (and))) (:destructure (rest last) (append rest last))) (defrule output-with-successor (and output/?s (& output)) (:function first)) (defrule/s input uri (:lambda (uri) (bp:node* (:input :uri uri)))) (defrule/s output uri (:lambda (uri) (bp:node* (:output :uri uri)))) (macrolet ((define-rule (name open-keyword close-keyword kind) `(defrule/s ,name (and ,open-keyword (+ (not ,close-keyword)) ,close-keyword) (:function second) (:text t) (:function parse-instantiation-spec) (:destructure (class &rest initargs) (bp:node* (,kind :class class :initargs initargs)))))) (define-rule filter pipe-keyword/?s pipe/end :filter) (define-rule transform slash-keyword/?s slash/end :transform)) (defrule pipe/end (and (& (and pipe-keyword/?s (* filter/?s) (? transform/?s) output-list)) pipe-keyword)) (defrule slash/end (and (& (and slash-keyword/?s output-list)) slash-keyword)) (defun uri-absolute-path? (uri) (let ((path (puri:uri-parsed-path uri))) (or (emptyp path) (starts-with :absolute path)))) (defrule/s uri (uri-absolute-path? parsable-uri)) (defun parsable-uri? (uri) (ignore-errors (puri:parse-uri uri))) (defrule parsable-uri (parsable-uri? uri-characters) (:function puri:parse-uri)) (defrule uri-characters (+ (or (not (or skippable ";" "->" "<->")) uri-characters/special)) (:text t)) (defrule uri-characters/special (and (or ";" "->" "<->") (& (or uri-characters ";" "->" "<->" (not character)))) (:function first)) (macrolet ((define-keyword-rule (name string) (let ((rule-name (symbolicate name '#:-keyword))) `(defrule/s ,rule-name ,string (:constant ,(make-keyword name)))))) (define-keyword-rule pipe #\|) (define-keyword-rule slash #\/) (define-keyword-rule right-arrow "->") (define-keyword-rule left-right-arrow "<->") (define-keyword-rule semicolon #\;)) (defun parse-spec (source &key (rule 'bridge-specification)) (esrap:parse rule source))
4,727
Common Lisp
.lisp
121
31.834711
78
0.605372
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e5406308418eb422bdf190e28faf60454e1a0524b0662bdb6ce90030030765e3
37,370
[ -1 ]
37,371
conditions.lisp
open-rsx_rsb-tools-cl/src/commands/bridge/conditions.lisp
;;;; conditions.lisp --- Conditions used in the commands.bridge module. ;;;; ;;;; Copyright (C) 2014, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.bridge) ;;; Specification conditions (define-condition specification-condition (rsb-problem-condition chainable-condition) ((spec :initarg :spec :reader specification-condition-spec :documentation "The problematic specification.")) (:default-initargs :spec (missing-required-initarg 'specification-condition :spec)) (:documentation "Superclass for condition classes indicating problems with bridge specifications.")) (define-condition specification-error (specification-condition rsb-error) () (:report (lambda (condition stream) (let ((*print-circle* t)) (format stream "~@<Bridge specification ~A is ~ invalid.~/more-conditions:maybe-print-cause/~@:>" (specification-condition-spec condition) condition)))) (:documentation "This error is signaled when a bridge specification is invalid.")) ;;; Forwarding cycle conditions (define-condition forwarding-cycle-condition (rsb-problem-condition) ((source :initarg :source :reader forwarding-cycle-condition-source :documentation "The event source involved in the forwarding cycle.") (destination :initarg :destination :reader forwarding-cycle-condition-destination :documentation "The event sink involved in the forwarding cycle.")) (:default-initargs :source (missing-required-initarg 'forwarding-cycle-condition :source) :destination (missing-required-initarg 'forwarding-cycle-condition :destination)) (:documentation "Superclass for condition classes indicating forwarding cycles in a bridge configuration.")) (define-condition forwarding-cycle-warning (forwarding-cycle-condition rsb-warning) () (:report (lambda (condition stream) (format stream "~@<Events published by ~A could potentially be ~ received by ~A, creating a forwarding cycle.~@:>" (forwarding-cycle-condition-destination condition) (forwarding-cycle-condition-source condition)))) (:documentation "This warning is signaled when it has been determined that a bridge configuration could potentially create a forwarding cycle. See the documentation of the `rsb.model.inference' package for the meaning of \"potentially\" in this context.")) (define-condition forwarding-cycle-error (forwarding-cycle-condition rsb-error) () (:report (lambda (condition stream) (format stream "~@<Events published by ~A would be received by ~ ~A, creating a forwarding cycle.~@:>" (forwarding-cycle-condition-destination condition) (forwarding-cycle-condition-source condition)))) (:documentation "This error is signaled when it has been determined that a bridge configuration would definitely create a forwarding cycle. See the documentation of the `rsb.model.inference' package for the meaning of \"definitely\" in this context."))
3,450
Common Lisp
.lisp
74
37.945946
84
0.667855
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f3639ef52b61a86b771df3d9446f2a5d196e51c06fbee96df092369923deee3f
37,371
[ -1 ]
37,372
participant.lisp
open-rsx_rsb-tools-cl/src/commands/bridge/participant.lisp
;;;; participant.lisp --- Bridge-related specialized participants. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.patterns.bridge (:use #:cl #:alexandria #:let-plus #:iterate #:rsb) (:export #:bridge #:stop #:pump-events)) (cl:in-package #:rsb.patterns.bridge) ;;; Utilities (define-constant +bridge-origin-key+ :rsb.bridge.origin :test #'eq) (defun make-bridge-timestamp-key (id &key (which '#:received) ) (format-symbol :keyword "~A.~A.~@:(~A~).~A" '#:rsb '#:bridge id which)) (defun make-handler (queue) (let ((connection nil) (handler (rsb.tools.commands::make-handler queue))) (declare (type function handler)) (values (lambda (event) (when connection (funcall handler (cons connection event)))) (lambda (new-value) (setf connection new-value))))) ;;; `connection' (defclass connection (rsb.patterns:composite-participant-mixin rsb.patterns:child-container-mixin rsb.patterns:configuration-inheritance-mixin rsb:participant) () (:documentation "A participant that forwards events between multiple RSB buses. Child participants listen on a \"source\" RSB bus (or multiple source buses) and collect events. Other child participants publish these events on a \"destination\" RSB bus (or multiple destination buses). Forwarded events can optionally be transformed when traversing the bridge. In addition, events can be be tagged with the identity of the bridge participant and the time of traversal of the bridge.")) (rsb::register-participant-class 'connection :connection) (defmethod shared-initialize :after ((instance connection) (slot-names t) &key listeners informers filters (timestamp-events? t) handler self-filters) (let+ (((&structure bridge- %queue) instance) ((&flet add-child (uri kind &rest args) (let ((name (princ-to-string uri))) (setf (rsb.patterns:participant-child instance name kind) (apply #'rsb.patterns:make-child-participant instance uri kind args))))) (transform (let ((initargs (rsb.patterns:make-child-initargs instance t :listener))) (getf initargs :transform))) (read? (or (when transform (rsb.ep:access? transform :data :read)) (rsb.ep:access? filters :data :read))) (write? (when transform (rsb.ep:access? transform :data :write))) ((&flet annotating () (rsb.tools.commands::make-annotating-converter-for-everything))) ((&flet components-to-drop (uri) (length (scope-components (rsb:uri->scope-and-options uri)))))) ;; Create informer … (mapc (lambda (uri) (let+ (((&values uri id) (if (consp uri) (values (car uri) (cdr uri)) uri))) (apply #'add-child uri :informer (append (unless (or read? write?) (list :converters (annotating))) (when id (list :id id)))))) informers) ;; … and listener child participants (the latter potentially with ;; filters and transforms). (mapc (lambda (uri) (apply #'add-child uri :listener :filters filters :handlers (list handler) :filter-ids (mapcar #'cdr (cdr (assoc uri self-filters))) :drop-components (components-to-drop uri) :timestamp-events? timestamp-events? (unless read? (list :converters (annotating))))) listeners))) (defun make-bridge-listener-filters (ids) (mapcar (lambda (id) (let ((predicate (curry #'string= (princ-to-string id)))) (rsb.filter:make-filter :complement :children (list (rsb.filter:make-filter :meta-data :key +bridge-origin-key+ :predicate predicate))))) ids)) (defun make-bridge-listener-transforms (connection-id drop-components timestamp-events?) (let+ ((received-timestamp-key (make-bridge-timestamp-key connection-id)) ((&flet bridge-timestamp! (event) ;; TODO use the adjust-timestamps transform (setf (timestamp event received-timestamp-key) (timestamp event :receive)) event)) ((&flet make-drop-scope-components (count) (lambda (event) (let* ((components (scope-components (event-scope event))) (components (nthcdr count components))) (setf (event-scope event) (make-scope components)) event))))) (append (when (typep drop-components 'positive-integer) (list (make-drop-scope-components drop-components))) (when timestamp-events? (list #'bridge-timestamp!))))) (defmethod rsb.patterns:make-child-initargs ((participant connection) (which t) (kind (eql :listener)) &key filter-ids drop-components timestamp-events?) (let+ ((initargs (call-next-method)) ;; Filter (filters (getf initargs :filters)) (bridge-filters (make-bridge-listener-filters filter-ids)) (effective-filters (append bridge-filters filters)) ;; Transform (transform (getf initargs :transform)) (bridge-transforms (make-bridge-listener-transforms (participant-id participant) drop-components timestamp-events?)) (transforms (append bridge-transforms (when transform (list transform)))) (effective-transform (when (<= 1 (length transforms) 3) (reduce #'compose transforms)))) (log:debug "~@<~A filters: ~:A + ~:A => ~:A~@:>" participant filters bridge-filters effective-filters) (log:debug "~@<~A transforms: ~A + ~:A => ~A~@:>" participant transform bridge-transforms effective-transform) (list* :filters effective-filters :transform effective-transform (remove-from-plist initargs :filters :filter-ids :transform :drop-components :timestamp-events?)))) (defmethod rsb.patterns:make-child-initargs ((participant connection) (which t) (kind (eql :informer)) &key id) (let+ ((initargs (call-next-method)) (transform (getf initargs :transform)) (id/string (princ-to-string id)) ((&flet bridge-origin! (event) (setf (meta-data event +bridge-origin-key+) id/string) event)) (effective-transform (reduce #'compose (when transform (list transform)) :initial-value #'bridge-origin!))) (list* :transform effective-transform initargs))) (defmethod send ((informer connection) (data event) &rest args &key) (let ((informers (remove-if-not (of-type 'informer) ; TODO cache this (rsb.patterns:participant-children informer)))) (mapc (lambda (informer) (let ((event (apply #'make-event ; TODO copy-event (merge-scopes (event-scope data) (participant-scope informer)) (event-data data) :method (event-method data) :timestamps (timestamp-plist data) :causes (event-causes data) :create-timestamp? nil (meta-data-plist data)))) (setf (event-origin event) (event-origin data) (event-sequence-number event) (event-sequence-number data)) (apply #'send informer event :no-fill? t args))) informers) data)) ;;; `bridge' (defclass bridge (rsb.patterns:composite-participant-mixin rsb.patterns:child-container-mixin rsb.patterns:configuration-inheritance-mixin rsb:participant) ((%queue :accessor bridge-%queue)) (:documentation "A participant that forwards events between multiple RSB buses. Child participants listen to a \"source\" RSB bus (or multiple source buses) and collect events. Other child participants publish these events on a \"destination\" RSB bus (or multiple destination buses). Forwarded events can optionally be transformed when traversing the bridge. In addition, events can be tagged with the identity of the bridge participant and the time of traversal of the bridge.")) (rsb::register-participant-class 'bridge :bridge) (defmethod shared-initialize :after ((instance bridge) (slot-names t) &key connections self-filters (timestamp-events? t) max-queued-events) (let+ (((&structure bridge- %queue) instance) (i 0)) (setf %queue (rsb.tools.commands::make-queue :max-queued-events max-queued-events)) (mapc (lambda+ ((listeners informers filters transform)) (let+ (((&values handler set-connection) (make-handler %queue)) (which (princ-to-string (incf i)))) (funcall set-connection (setf (rsb.patterns:participant-child instance which :connection) (rsb.patterns:make-child-participant instance which :connection :listeners listeners :informers informers :filters filters :transform transform :timestamp-events? timestamp-events? :handler handler :self-filters self-filters))))) connections))) (defmethod rsb.patterns:make-child-scope ((participant bridge) (which t) (kind (eql :connection))) (participant-scope participant)) (defgeneric stop (bridge) (:method ((bridge bridge)) (lparallel.queue:push-queue :stop (bridge-%queue bridge)))) (defgeneric pump-events (bridge) (:method ((bridge bridge)) ;; Process events in QUEUE until interrupted. (let ((queue (bridge-%queue bridge)) (continue-function nil)) (restart-bind ((continue (lambda (&optional condition) (declare (ignore condition)) (funcall continue-function)) :test-function (lambda (condition) (declare (ignore condition)) continue-function) :report-function (lambda (stream) (format stream "~@<Ignore the failure ~ and continue ~ processing.~@:>")))) (iter (for item next (lparallel.queue:pop-queue queue)) (when (first-iteration-p) (setf continue-function (lambda () (iter:next-iteration)))) (etypecase item ((eql :stop) (return)) (cons (destructuring-bind (connection . event) item (send connection event)))))))))
12,951
Common Lisp
.lisp
260
33.669231
89
0.516037
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4a68cf03ae9bc0ce3952256687bacccd38d5ed38c0f62312dbe5f5bd971247ac
37,372
[ -1 ]
37,373
command.lisp
open-rsx_rsb-tools-cl/src/commands/web/command.lisp
;;;; command.lisp --- Serve system information via HTTP. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.web) (defvar *default-handlers* '() "Stores a list of functions that return handlers and corresponding paths.") (defclass web (source-mixin response-timeout-mixin http-server-mixin print-items:print-items-mixin) () (:documentation "Serve information about an RSB system via HTTP. Introspection information is limited to hosts, processes and RSB participants reachable via the transports designated by URI* (zero or more URIs). When no URIs are supplied, the default transport configuration is used.")) (service-provider:register-provider/class 'rsb.tools.commands::command :web :class 'web) (defvar *database*) (defmethod command-make-handlers ((command web)) (mapcar (lambda (generator) (multiple-value-call #'cons (funcall generator *database*))) *default-handlers*)) (defmethod command-execute ((command web) &key error-policy) (let+ (((&structure command- uris response-timeout) command)) (with-participant (*database* :remote-introspection rsb.introspection:+introspection-scope+ :receiver-uris uris :error-policy error-policy :response-timeout response-timeout) (call-next-method))))
1,496
Common Lisp
.lisp
36
35.25
81
0.685045
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
081a66454b8456eb66cbd0e9a524c5895cb4d3542d1075088ccc691d8f632db3
37,373
[ -1 ]
37,374
package.lisp
open-rsx_rsb-tools-cl/src/commands/web/package.lisp
;;;; package.lisp --- Package definition for the commands.web module. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.commands.web (:use #:cl #:alexandria #:let-plus #:more-conditions #:rsb #:rsb.tools.commands) (:import-from #:rsb.tools.commands #:response-timeout-mixin #:command-response-timeout) ;; Conditions (:export #:argument-condition #:argument-condition-parameter #:argument-error #:argument-type-error #:argument-parse-error #:argument-parse-error-raw-value) ;; Web command protocol (:export #:command-maker-handlers #:command-register-handler) ;; Resource protocol (:export #:find-resource #:map-resources) (:documentation "Package definition for the commands.web module."))
868
Common Lisp
.lisp
34
22
69
0.702309
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d027618f8a106731dc2a4951caef3fc692361e30dfe7a607ce034ffbc9e37e73
37,374
[ -1 ]
37,375
protocol.lisp
open-rsx_rsb-tools-cl/src/commands/web/protocol.lisp
;;;; Protocol.lisp --- Protocol provided by the tools.commands.web module. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.web) ;;; Handler registration protocol (defgeneric command-make-handlers (command) (:documentation "COMMAND makes and returns a list of handlers with elements of the form (PATH . HANDLER) .")) (defgeneric command-register-handler (command acceptor path handler) (:documentation "COMMAND registers HANDLER under PATH in with ACCEPTOR. If PATH is a string, it corresponds to the prefix of URI paths that should be handled by HANDLER. If PATH is a function, it has to, when called with a `request' instance, return a Boolean indicating whether HANDLER should handle the request. HANDLER is a function of one argument, a `hunchentoot:request', that should be called to handle requests arriving for PATH.")) ;;; Resource protocol (defgeneric find-resource (name container) (:documentation "Return the resource designated by NAME in CONTAINER.")) (defgeneric map-resources (function container) (:documentation "Call FUNCTION with each resource contained in CONTAINER."))
1,260
Common Lisp
.lisp
29
40.068966
74
0.754098
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8977a1975c74cce868090d1d58f7eb7d79179c842374f8b117ea6afe53dfd472
37,375
[ -1 ]
37,376
resources.lisp
open-rsx_rsb-tools-cl/src/commands/web/resources.lisp
;;;; resources.lisp --- Serving resources from image over HTTP. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.web) ;;; Resource loading (defun load-resource-files (files prefix) (let+ ((count 0) (size 0) ((&flet load-resource-file (pathname) (let ((name (pathname (enough-namestring pathname prefix))) (content (read-file-into-byte-vector pathname))) (incf count) (incf size (length content)) (cons name content))))) (log:info "~@<Loading ~:D resource file~:P from ~S.~@:>" (length files) prefix) (prog1 (mapcan (lambda (pathname) (with-simple-restart (continue "Ignore the error") (list (load-resource-file pathname)))) files) (log:info "~@<Loaded ~:D resource file~:P, ~:D byte~:P from ~S.~@:>" count size prefix)))) (defun load-system-resource-files (system sub-directory) (let* ((base (asdf:system-relative-pathname system sub-directory)) (files (remove-if-not #'pathname-name (directory (merge-pathnames "**/*.*" base))))) (load-resource-files files base))) (defparameter *resources* (let ((files (load-system-resource-files :rsb-tools-commands-web "resources/"))) (alist-hash-table files :test #'equalp))) ;;; `resource-handler-mixin' (defclass resource-handler-mixin () ((resources :initarg :resources :reader handler-resources)) (:default-initargs :resources (missing-required-initarg 'resource-handler-mixin :resources)) (:documentation "Adds resource storage.")) (defmethod find-resource ((name t) (container resource-handler-mixin)) (gethash name (handler-resources container))) (defmethod map-resources ((function t) (container resource-handler-mixin)) (maphash function (handler-resources container))) (defmethod print-items:print-items append ((object resource-handler-mixin)) `((:resource-count ,(hash-table-count (handler-resources object)) "(~:D)"))) ;;; `resource-handler' (defclass resource-handler (handler-mixin resource-handler-mixin print-items:print-items-mixin) () (:metaclass closer-mop:funcallable-standard-class) (:documentation "Serves bundle resource files.")) (defmethod rsb.ep:handle ((sink resource-handler) (data hunchentoot:request)) (let ((name (if (equal "/" (hunchentoot:script-name data)) #P"index.html" (hunchentoot:request-pathname data)))) (if-let ((content (find-resource name sink))) (progn (%static-resource-response (hunchentoot:mime-type name)) content) (progn (setf (hunchentoot:return-code*) hunchentoot:+http-not-found+) (hunchentoot:abort-request-handler))))) ;;; `source-archive-handler' (defclass source-archive-handler (handler-mixin resource-handler-mixin print-items:print-items-mixin) () (:metaclass closer-mop:funcallable-standard-class) (:documentation "Serves all bundled resource files in one archive.")) (defmethod rsb.ep:handle ((sink source-archive-handler) (data hunchentoot:request)) (%static-resource-response "application/x-tar") (let ((stream (hunchentoot:send-headers))) (archive:with-open-archive (archive stream :archive-type archive:tar-archive :direction :output) (map-resources (lambda (name content) (let ((entry (make-instance 'archive::tar-entry :pathname name :mode #o550 :typeflag archive::+tar-regular-file+ :uid 0 :gid 0 :size (length content) :mtime 0))) (archive:write-entry-to-archive archive entry :stream (flexi-streams:make-in-memory-input-stream content)))) sink) (archive:finalize-archive archive)))) ;;; Activate the handlers (defmethod command-make-handlers :around ((command web)) ;; If COMMAND does not have a document root directory configured, ;; add one handler for builtin resources and another for download of ;; those in archive form. (if (command-document-root command) (call-next-method) (list* (cons "" (make-instance 'resource-handler :resources *resources*)) (cons "/source.tar" (make-instance 'source-archive-handler :resources *resources*)) (call-next-method)))) ;;; Utilities (defun %static-resource-response (&optional mime-type) (when mime-type (setf (hunchentoot:content-type*) mime-type)) (setf (hunchentoot:header-out "Cache-Control") "no-transform,public,max-age=300,s-maxage=900"))
5,193
Common Lisp
.lisp
116
34.637931
82
0.603322
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c9dce89f8988872acc7bedce9dda5516008110285be7900adab1ae64fd7c2535
37,376
[ -1 ]
37,377
conditions.lisp
open-rsx_rsb-tools-cl/src/commands/web/conditions.lisp
;;;; conditions.lisp --- Conditions used in the commands.web module. ;;;; ;;;; Copyright (C) 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.web) (define-condition argument-condition (condition) ((parameter :initarg :parameter :reader argument-condition-parameter :documentation "Stores the name of request parameter that is the subject of the condition.")) (:default-initargs :parameter (missing-required-initarg 'argument-condition :parameter)) (:documentation "This condition class adds a slot storing the name of request parameter that is the subject of the condition.")) (define-condition argument-error (error argument-condition) () (:documentation "Subclasses of this condition class indicate problems with request arguments.")) (define-condition simple-argument-error (argument-error simple-error chainable-condition) () (:report (lambda (condition stream) (format stream "~@<~?~/more-conditions:maybe-print-cause/~@:>" (simple-condition-format-control condition) (simple-condition-format-arguments condition) condition)))) (defun argument-error (parameter format-control &rest format-arguments) (error 'simple-argument-error :parameter parameter :format-control format-control :format-arguments format-arguments)) (define-condition argument-type-error (argument-error type-error) () (:documentation "This error is signaled when a request argument is not of the expected type.")) (define-condition argument-parse-error (argument-error chainable-condition) ((raw-value :initarg :raw-value :reader argument-parse-error-raw-value :documentation "Stores the unparsed value of the offending request argument.")) (:report (lambda (condition stream) (format stream "~@<Could not parse value ~S of parameter ~ ~S~/more-conditions:maybe-print-cause/~@:>" (argument-parse-error-raw-value condition) (argument-condition-parameter condition) condition))) (:documentation "This error is signaled when a request argument cannot be parsed."))
2,542
Common Lisp
.lisp
61
32.213115
72
0.633387
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bf6b0142a3438be7b62a965a936f7e43b20f9e83399658bae9a3013b9cd2524d
37,377
[ -1 ]
37,378
introspection.lisp
open-rsx_rsb-tools-cl/src/commands/web/introspection.lisp
;;;; introspection.lisp --- Serve introspection information over HTTP. ;;;; ;;;; Copyright (C) 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.web) ;;; `introspection-handler-mixin' (defclass introspection-handler-mixin (handler-mixin) ((database :initarg :database :reader handler-database)) (:default-initargs :database (missing-required-initarg 'introspection-handler-mixin :database)) (:documentation "This class is intended to be mixed into handler classes that serve introspection information.")) ;;; `introspection-snapshot-handler' (defclass introspection-snapshot-handler (introspection-handler-mixin) () (:metaclass closer-mop:funcallable-standard-class) (:documentation "Instances of this class serve JSON-serialized introspection information.")) (defun make-introspection-snapshot-handler (database) (values "/api/introspection/snapshot" (make-instance 'introspection-snapshot-handler :database database))) (pushnew 'make-introspection-snapshot-handler *default-handlers*) (defmethod rsb.ep:handle ((sink introspection-snapshot-handler) (data hunchentoot:request)) (providing-api-endpoint (:request data) () "Replies with a snapshot of the available introspection information. The introspection snapshot is structured as a tree with the root containing host nodes, host nodes containing process nodes and process nodes containing trees of nested participant nodes." (lambda (stream) (let ((database (handler-database sink))) (rsb.introspection:with-database-lock (database) (let ((tree (rsb.introspection::introspection-database database))) (architecture.builder-protocol.json:serialize-using-serializer t tree stream (default-json-serializer)))))))) ;;; `introspection-search-handler' (defclass introspection-search-handler (introspection-handler-mixin) () (:metaclass closer-mop:funcallable-standard-class) (:documentation "Instances of this class serve results of search queries on introspection information.")) (defun make-introspection-search-handler (database) (values "/api/introspection/search" (make-instance 'introspection-search-handler :database database))) (pushnew 'make-introspection-search-handler *default-handlers*) (defun search-parse-query (query) (let+ (((&flet whitespace? (character) (member character '(#\Space #\Tab #\Newline)))) ((&flet wordoid? (character) (or (alphanumericp character) (find character "-_")))) (words (when (every (disjoin #'wordoid? #'whitespace?) query) (split-sequence:split-sequence-if #'whitespace? query :remove-empty-subseqs t))) ((&flet word-query (word) `(:attribute * (:contains (:path (:self :node)) ,word)))) ((&flet word-query/path (word) `(:path ,(word-query word)))) (expression (cond ;; Only whitespace. ((every #'whitespace? query) (argument-error 'query "~@<No search term ~ specified (query has only ~ whitespace characters).~@:>")) ;; One or more "words". ((not (emptyp words)) `(:path (:root :node) (:descendant-or-self :node) ,(if (length= 1 words) (word-query (first words)) `(:child * (:and ,@(mapcar #'word-query/path words)))))) ;; XPath expression. (t (xpath:parse-xpath query))))) `(xpath:xpath ,expression))) (defun search-result-formatter (result navigator &key start count) (etypecase result ((or string number) (when (and start (plusp start)) (argument-error 'start "~@<Positive start index but atom result.~@:>")) (lambda (stream) (json:encode-json result stream))) (xpath:node-set ;; Drop requested number of elements from the pipe. (when (and start (plusp start)) (let ((xpath:*navigator* navigator)) (loop :with pipe = (xpath-sys:pipe-of result) :for i :from 0 :repeat start :when (xpath::pipe-empty-p pipe) :do (argument-error 'start "~@<Start element ~:D requested, but result only ~ has ~:D element~:P.~@:>" start i) :do (setf pipe (xpath-sys:pipe-tail pipe)) :finally (setf (xpath-sys:pipe-of result) pipe)))) ;; Serialize requested number of nodes into the reply. (let ((count (when count (1+ count)))) (lambda (stream) (let ((xpath:*navigator* navigator)) (json:with-array (stream) (xpath:do-node-set (node result) (when (and count (zerop (decf count))) (return)) (let+ (((&flet unwrap (thing) (architecture.builder-protocol.xpath:unwrap navigator thing))) ((&flet parent () (architecture.builder-protocol.xpath::proxy-parent node))) ((&values attribute element) (typecase node (architecture.builder-protocol.xpath::node-proxy (values nil (unwrap node))) (architecture.builder-protocol.xpath::attribute-proxy (values (unwrap node) (unwrap (parent)))) (architecture.builder-protocol.xpath::relation-proxy (values nil (unwrap (parent))))))) (when (or attribute element) (json:as-array-member (stream) (json:with-object (stream) (when attribute (let ((name (string-downcase (car attribute))) (value (rsb.formatting::prepare-initarg-value-for-json (cdr attribute)))) (json:encode-object-member "attribute-name" name stream) (json:encode-object-member "attribute-value" value stream))) (when element (json:as-object-member ("element" stream) (architecture.builder-protocol.json:serialize-using-serializer :reverse element stream (default-json-serializer)))))))))))))))) (defmethod rsb.ep:handle ((sink introspection-search-handler) (data hunchentoot:request)) (providing-api-endpoint (:request data) ((query :transform 'search-parse-query :documentation "The (non-empty) query string. One of the following things: An XPath expression. One or more words: match any node (element, attribute, text) containing all words.") &optional (start :type non-negative-integer :transform 'parse-integer :documentation "Index of first node in match sequence that should be returned.") (count :name "limit" :type positive-integer :transform 'parse-integer :documentation "Number of nodes from the match sequence that should be returned.")) "Run XPath queries against the available introspection information. Return an atomic result for expressions not evaluating to node sets and an array of matches otherwise. An atomic result can be a number or string. For example, the result of the query count(//@foo) is a number. A match can be an attribute match or an element match." (let ((navigator (make-instance 'architecture.builder-protocol.xpath:navigator :builder t :peek-function (lambda (builder relation relation-args node) (declare (ignore builder relation relation-args)) (typecase node (rsb.formatting::stringify-value (rsb.formatting::maybe-stringify-value node)) (number (princ-to-string node)) (string node) (t t))) :printers `((,(lambda (builder node) (declare (ignore builder)) (typep node 'rsb.formatting::stringify-value)) . ,(lambda (builder node) (declare (ignore builder)) (rsb.formatting::maybe-stringify-value node)))))) (database (handler-database sink))) (rsb.introspection:with-database-lock (database) (let* ((tree (rsb.introspection::introspection-database database)) (result (architecture.builder-protocol.xpath:evaluate-using-navigator query navigator tree :node-order nil))) ;; Return a closure that will be called with the reply ;; stream. (search-result-formatter result navigator :start start :count count)))))) ;;; Utilities (defun default-json-serializer () (rsb.formatting::make-json-serializer :symbol-transform #'string-downcase :kind-transform (architecture.builder-protocol.json:default-kind-key-and-value-transform) :peek-function (rsb.formatting::make-json-peek-function)))
10,109
Common Lisp
.lisp
195
37.353846
95
0.563903
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
be6fa5f778873567d4ed2002102f55fb5c375e754f97686360e849cc4597e21d
37,378
[ -1 ]
37,379
mixins.lisp
open-rsx_rsb-tools-cl/src/commands/web/mixins.lisp
;;;; mixins.lisp --- Mixin classes for web-related commands. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.commands.web) ;;; `acceptor' (defclass acceptor (hunchentoot:acceptor rsb.ep:error-policy-mixin) ((dispatch-table :initarg :dispatch-table :type list :accessor acceptor-dispatch-table :initform '() :documentation "Local dispatch table for the acceptor instance.")) (:documentation "Specialized acceptor class with slot-stored dispatch table.")) (defmethod hunchentoot:process-connection :around ((acceptor acceptor) (socket t)) ;; If `hunchentoot:*catch-errors-p*' is `nil', hunchentoot directly ;; enters the debugger for all errors. (let ((hunchentoot:*catch-errors-p* t) (hunchentoot:*show-lisp-backtraces-p* nil) (hunchentoot:*show-lisp-errors-p* nil)) (rsb.ep:with-error-policy (acceptor) (with-simple-restart (continue "~@<Stop processing connection ~A.~@:>" socket) (call-next-method))))) (defmethod hunchentoot:handle-request ((acceptor acceptor) (request t)) (restart-case (if-let ((handler (some (rcurry #'funcall request) (acceptor-dispatch-table acceptor)))) (funcall handler request) (call-next-method)) (continue (&optional condition) :report (lambda (stream) (format stream "~@<Stop processing request ~A.~@:>" request)) (declare (ignore condition)) (setf (hunchentoot:return-code*) hunchentoot:+http-internal-server-error+) (hunchentoot:abort-request-handler)))) (defmethod hunchentoot:acceptor-dispatch-request ((acceptor acceptor) (request t)) (if-let ((handler (some (rcurry #'funcall request) (acceptor-dispatch-table acceptor)))) (funcall handler request) (call-next-method))) (defmethod hunchentoot:acceptor-log-message ((acceptor acceptor) (log-level symbol) (format-string t) &rest format-arguments) (let+ ((logger (load-time-value (log:category) t)) (level (ecase log-level (:error log4cl:+log-level-error+) (:warning log4cl:+log-level-warn+) (:info log4cl:+log-level-info+))) ((&flet write-message (stream) (declare (type stream stream)) (apply #'format stream format-string format-arguments)))) (declare (dynamic-extent #'write-message)) (log4cl::log-with-logger logger level #'write-message *package*))) ;;; `http-server-mixin' (defclass http-server-mixin () ((address :initarg :address :type (or null string) :reader command-address :documentation "Address on which the HTTP server should listen.") (port :initarg :port :type (integer 0 65535) :reader command-port :documentation "Port on which the HTTP server should listen.") (document-root :type (or null pathname) :reader command-document-root :accessor command-%document-root :initform nil :documentation "Directory from which static content such as HTML and CSS files should be read.") (message-log :initarg :message-log :type (or boolean pathname) :reader command-message-log :initform nil :documentation "Pathname of a file to which web server message should be logged. `nil' disables message logging. `t' logs to `*standard-output*'.") (access-log :initarg :access-log :type (or boolean pathname) :reader command-access-log :initform nil :documentation "Pathname of a file to which web server accesses should be logged. `nil' disables access logging. `t' logs to `*standard-output*'.")) (:default-initargs :address "localhost" :port 4444) (:documentation "This class is intended to be mixed into command classes that server data via HTTP.")) (defmethod shared-initialize :after ((instance http-server-mixin) (slot-names t) &key (document-root nil document-root-supplied?)) (when document-root-supplied? (setf (command-%document-root instance) (when document-root (pathname document-root))))) (defmethod print-items:print-items append ((object http-server-mixin)) (let ((endpoint (list (command-address object) (command-port object)))) `((:marker nil " => " ((:after :source-uris))) (:endpoint ,endpoint "~/rsb.tools.commands.web::print-server-url/" ((:after :marker)))))) (defmethod command-register-handler ((command http-server-mixin) (acceptor acceptor) (path string) (handler t)) (log:info "~@<~A is registering handler ~S -> ~A~@:>" command path handler) (push (hunchentoot:create-prefix-dispatcher path handler) (acceptor-dispatch-table acceptor))) (defmethod command-register-handler ((command http-server-mixin) (acceptor acceptor) (path function) (handler t)) (log:info "~@<~A is registering handler ~A -> ~A~@:>" command path handler) (push (lambda (request) (when (funcall path request) handler)) (acceptor-dispatch-table acceptor))) (defmethod command-execute ((command http-server-mixin) &key error-policy) (let+ (((&structure command- address port document-root message-log access-log) command) (acceptor nil) (handlers '())) (unwind-protect (progn ;; Construct acceptor. (setf acceptor (apply #'make-instance 'acceptor :error-policy error-policy :address address :port port :document-root document-root (append (case message-log ((t)) ((nil) (list :message-log-destination nil)) (t (list :message-log-destination message-log))) (case access-log ((t)) ((nil) (list :access-log-destination nil)) (t (list :access-log-destination access-log)))))) ;; Register handlers. (setf handlers (mapcar (lambda+ ((path . handler)) (command-register-handler command acceptor path handler) handler) (command-make-handlers command))) ;; Start acceptor. (log:info "~@<~A is starting acceptor ~A~@:>" command acceptor) (hunchentoot:start acceptor) (format t "Listening on ~/rsb.tools.commands.web::print-server-url/~%~ ~:[Not serving from filesystem~:;~:*Document ~ root is at ~S~]~%" acceptor document-root) (log:info "~@<~A is serving ~@[~S as ~]~ ~/rsb.tools.commands.web::print-server-url//~@:>" command document-root acceptor) ;; Run (loop (sleep most-positive-fixnum))) ;; Clean up. (log:info "~@<~A is stopping acceptor ~A~@:>" command acceptor) (when acceptor (hunchentoot:stop acceptor)) ;; Detach handlers. (mapc #'detach handlers)))) ;;; `handler-mixin' (defclass handler-mixin (function standard-object) () (:metaclass closer-mop:funcallable-standard-class) (:documentation "This class is intended to be mixed into handler classes.")) (defmethod initialize-instance :after ((instance handler-mixin) &key) (closer-mop:set-funcallable-instance-function instance (lambda (request) (rsb.ep:handle instance request)))) (defmethod detach ((participant handler-mixin)) (when (next-method-p) (call-next-method))) ;;; Utilities (defun print-server-url (stream thing &optional at? colon?) (declare (ignore at? colon?)) (multiple-value-call #'format stream "http://~:[*~;~:*~A~]:~D" (etypecase thing (hunchentoot:acceptor (values (hunchentoot:acceptor-address thing) (hunchentoot:acceptor-port thing))) ((cons t (cons t null)) (values-list thing)))))
9,415
Common Lisp
.lisp
201
33.368159
97
0.542487
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d1e88450bc8cd3d829a171f3ce7eb67678f8a11222373aabd59f379566eae29d
37,379
[ -1 ]
37,380
package.lisp
open-rsx_rsb-tools-cl/src/stats/package.lisp
;;;; package.lisp --- Package definition for stats module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.stats (:use #:cl #:alexandria #:let-plus #:iterate #:more-conditions #:rsb) ;; Types (:export #:meta-data-selector #:when-missing-policy) ;; Conditions (:export #:quantity-creation-error #:quantity-creation-error-specification) ;; Quantity protocol (:export #:quantity-name #:quantity-value #:update! #:reset! #:format-value) ;; `collecting-mixin' mixin class (:export #:quantity-values #:collecting-mixin) ;; `extract-function-mixin' mixin class (:export #:quantity-extractor #:extract-function-mixin) ;; `histogram-mixin' mixin class (:export #:histogram-mixin) ;; `moments-mixin' mixin class (:export #:moments-mixin) ;; `all-time-mixin' mixin class (:export #:all-time-mixin) ;; `named-mixin' (:export #:named-mixin) ;; `reduction-mixin' mixin class (:export #:quantity-reduce-by #:reduction-mixin) ;; `rate-mixin' mixin class (:export #:rate-mixin) ;; `meta-data-mixin' mixin class (:export #:meta-data-mixin #:quantity-key #:quantity-when-missing) ;; `format-mixin' mixin class (:export #:format-mixin #:quantity-format) ;; Quantity creation protocol (:export #:make-quantity) ;; Extractor utilities (:export #:event-size #:event-size/power-of-2 #:event-type/simple) ;; Printer (:export #:print-quantity-value) (:documentation "This package contains functions and classes for computing basic statistical quantities over properties of RSB events. Most quantities collect some event property over a period of time and produce some aggregated value from the collection. Examples include + Event frequency + Histogram of event origins + Histogram of event wire-schema + Mean and variance of event payload size + Mean and variance event latency"))
2,099
Common Lisp
.lisp
86
20.581395
68
0.688665
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
493cfd889075b54044dfb8077892d8e5b96eb0a1383b60e86cffc1e8feb7907b
37,380
[ -1 ]
37,381
util.lisp
open-rsx_rsb-tools-cl/src/stats/util.lisp
;;;; util.lisp --- Utility functions used by the stats module. ;;;; ;;;; Copyright (C) 2012, 2013, 2014, 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.stats) ;;; Extractor functions (defun event-size (event &optional (replacement-value :n/a)) "Try to determine and return the size of the payload of EVENT in bytes. Return REPLACEMENT-VALUE, if the size cannot be determined." (labels ((payload-size (payload) (typecase payload (integer (ceiling (integer-length payload) 8)) (rsb.converter::annotated (payload-size (rsb.converter::annotated-wire-data payload))) ((cons t (not list)) replacement-value) (sequence (length payload)) (t replacement-value)))) (or (meta-data event :rsb.transport.payload-size) (payload-size (event-data event))))) (defun event-size/power-of-2 (event &optional (replacement-value :n/a)) "Like `event-size', but the returned size is rounded to the nearest power of two, if it is a positive integer." (let ((size (event-size event replacement-value))) (if (typep size 'non-negative-integer) (ash 1 (integer-length size)) size))) (defun event-type/simple (event) "Return an object designating the type of EVENT." (cond ((meta-data event :rsb.transport.wire-schema)) ((typep (event-data event) 'rsb.converter::annotated) (cons 'rsb.converter::annotated (rsb.converter::annotated-wire-schema (event-data event)))) (t (type-of (event-data event))))) ;;; Printer (defun print-quantity-value (stream quantity &optional colon? at?) "Print value of QUANTITY to STREAM. colon? and at? are ignored." (declare (ignore colon? at?)) (format-value quantity stream))
1,903
Common Lisp
.lisp
46
34.565217
76
0.648108
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2db00fef79a62381464aad728dd16f9ee39383a5483dfbac14a26bbc14904363
37,381
[ -1 ]
37,382
protocol.lisp
open-rsx_rsb-tools-cl/src/stats/protocol.lisp
;;;; protocol.lisp --- Protocol functions of the stats module. ;;;; ;;;; Copyright (C) 2011, 2013, 2014 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.stats) ;;; Quantity protocol (defgeneric quantity-name (quantity) (:documentation "Return the name of QUANTITY.")) (defgeneric quantity-value (quantity) (:documentation "Return the value of QUANTITY.")) (defgeneric update! (quantity event) (:documentation "Update the state of QUANTITY using data from EVENT. Most quantities extract some part of EVENT, possible derive some datum through a transformation and add the datum to a collection from which the actual value of the quantity is computed.")) (defgeneric reset! (quantity) (:documentation "Reset the state of QUANTITY. For quantities that accumulate values like moments-based quantities or histogram-based quantities this clear the collection of accumulated values.")) (defgeneric format-value (quantity stream) (:documentation "Format the value of QUANTITY onto STREAM.")) ;;; Collecting quantity protocol (defgeneric quantity-values (quantity) (:documentation "Return the values that have been collected in order to compute the value of quantity. Only applicable to quantities that accumulate values in some way.")) ;;; Quantity service and creation (service-provider:define-service quantity (:documentation "Providers of this service are classes implementing the quantity protocol.")) (defgeneric make-quantity (spec &rest args) (:documentation "Make and return a quantity instance according to SPEC. SPEC can either be a keyword, designating a quantity class, a list of the form (CLASS KEY1 VALUE1 KEY2 VALUE2 ...) designating a quantity class and specifying initargs, or a quantity instance.")) (define-condition-translating-method make-quantity (spec &rest args) ((error quantity-creation-error) :specification (append (ensure-list spec) args))) (defmethod make-quantity ((spec symbol) &rest args) (apply #'service-provider:make-provider 'quantity spec args)) (defmethod make-quantity ((spec cons) &rest args) (check-type spec (cons keyword list) "a keyword followed by initargs") (if args (apply #'make-quantity (first spec) (append args (rest spec))) (apply #'make-quantity spec))) (defmethod make-quantity ((spec standard-object) &rest args) (when args (apply #'incompatible-arguments :spec spec args)) spec)
2,522
Common Lisp
.lisp
60
38.65
72
0.753273
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
44ba2dbb109fa023de87817af3bbab4715fa08f8826e710877f3166c57fa3d1b
37,382
[ -1 ]
37,383
types.lisp
open-rsx_rsb-tools-cl/src/stats/types.lisp
;;;; types.lisp --- Types used in the stats module. ;;;; ;;;; Copyright (C) 2011, 2013, 2014 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.stats) (deftype meta-data-selector () "Either the name of a meta-data item or one of the special names :keys and :values." '(or keyword (member :keys :values))) (deftype when-missing-policy () "Designator for a policy that should be employed if a meta-data item is missing from an event. The keyword :skip causes the event to be ignored. Strings are used as replacement values." '(or (eql :skip) string))
619
Common Lisp
.lisp
15
38.933333
70
0.71381
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2062e6577fdb51d582c0762b235bfbbd1aabb9dc6983aa73c891872feb6dfc24
37,383
[ -1 ]
37,384
quantity-mixins.lisp
open-rsx_rsb-tools-cl/src/stats/quantity-mixins.lisp
;;;; quantity-mixins.lisp --- Mixin classes for quantity classes. ;;;; ;;;; Copyright (C) 2011-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.stats) ;;; `named-mixin' mixin class (defclass named-mixin () ((name :initarg :name :type string :reader quantity-name :initform (missing-required-initarg 'named-mixin :name) :documentation "Stores the name of the quantity.")) (:documentation "This mixin class is intended to be mixed into quantity classes to take care of the quantity name.")) (defmethod print-object ((object named-mixin) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "~A = " (quantity-name object)) (format-value object stream))) ;;; `extract-function-mixin' mixin class (defclass extract-function-mixin () ((extractor :initarg :extractor :type function :accessor quantity-extractor :initform (missing-required-initarg 'extract-function-mixin :extractor) :documentation "Stores a function that is called to extract a value from some object.")) (:documentation "This mixin class is intended to be mixed into quantity classes that should provide flexible extraction of values from events or other sources.")) (defmethod update! ((quantity extract-function-mixin) (event event)) (update! quantity (funcall (quantity-extractor quantity) event))) ;;; `meta-data-mixin' mixin class (defclass meta-data-mixin (named-mixin) ((key :initarg :key :type meta-data-selector :accessor quantity-key :documentation "Stores the key for which meta-data items should be extracted from processed events.") (when-missing :initarg :when-missing :type when-missing-policy :accessor quantity-when-missing :initform :skip :documentation "Stores a designator the policy that should be employed when a meta-data item is not available.")) (:default-initargs :key (missing-required-initarg 'meta-data-mixin :key)) (:documentation "This class is intended to be mixed into quantity classes that process meta-data items of events.")) (defmethod shared-initialize :around ((instance meta-data-mixin) (slot-names t) &rest args &key key (name (when key (string key)))) (check-type key meta-data-selector) (apply #'call-next-method instance slot-names (append (when name (list :name name)) (remove-from-plist args :name)))) (defmethod update! ((quantity meta-data-mixin) (event event)) (let+ (((&structure-r/o quantity- key when-missing) quantity)) (case key (:keys (mapc (curry #'update! quantity) (meta-data-keys event))) (:values (mapc (curry #'update! quantity) (meta-data-values event))) (t (let ((value (or (meta-data event key) when-missing))) (unless (eq value :skip) (update! quantity value))))))) ;;; `collecting-mixin' mixin class (defclass collecting-mixin () ((values :initarg :values :type vector :reader quantity-values :accessor quantity-%values :initform (make-array 0 :fill-pointer 0 :adjustable t) :documentation "Stores the values that have been collected from events.")) (:documentation "This mixin is intended to be added to quantity classes the values of which are computed by accumulating auxiliary values across multiple events.")) (defmethod update! ((quantity collecting-mixin) (value (eql nil))) ;; Ignore nil value by default. (values)) (defmethod update! ((quantity collecting-mixin) (value t)) ;; Add VALUE to the collected values. (vector-push-extend value (quantity-%values quantity)) (when (next-method-p) (call-next-method))) (defmethod reset! ((quantity collecting-mixin)) ;; Clear the collection of values in QUANTITY. (setf (fill-pointer (quantity-%values quantity)) 0) (when (next-method-p) (call-next-method))) ;;; `filter-mixin' class (defclass filter-mixin () ((order :initarg :order :type non-negative-integer :accessor quantity-order :initform 1 :documentation "Stores the order of the filter that should be applied to ORDER-tuples of the collected data.") (filter :initarg :filter :type function :accessor quantity-filter :documentation "Stores a function which is called with ORDER-tuples of the collected data to implement the actual filter.")) (:default-initargs :filter (missing-required-initarg 'filter-mixin :filter)) (:documentation "This class is intended to be mixed into collecting quantity classes which apply a filter to collected values before further processing.")) (defmethod quantity-values ((quantity filter-mixin)) (let+ (((&structure-r/o quantity- order filter) quantity) (values (call-next-method))) (declare (type fixnum order) (type function filter)) ;; When enough data has been collected, apply the filter function ;; and return filtered data. (when (>= (length values) order) (locally (declare #.rsb:+optimization-fast+unsafe+) (let ((cell (make-list order))) (declare (dynamic-extent cell)) (iter (for (the fixnum i) to (- (length values) order)) (replace cell values :start2 i :end2 (+ i order)) (collect (apply filter cell)))))))) ;;; `reduction-mixin' mixin class (defclass reduction-mixin () ((empty-value :initarg :empty-value :accessor quantity-empty-value :initform 0 :documentation "This class allocated slot stores a value that should be produced when the quantity is queried when no values have been collected.") (reduce-by :initarg :reduce-by :type function :accessor quantity-reduce-by :initform #'+ :documentation "Stores the reduce function that produces the value of the quantity by reducing a collection of values.")) (:documentation "This mixin class is intended to be mixed into quantity classes which compute the quantity value from a collection of values using a reduction function.")) (defmethod quantity-value ((quantity reduction-mixin)) (reduce (quantity-reduce-by quantity) (quantity-values quantity) :initial-value (quantity-empty-value quantity))) ;;; `all-time-mixin' mixin class (defclass all-time-mixin (collecting-mixin reduction-mixin) () (:documentation "This class is intended to be mixed into quantity classes which continuously aggregate new values into the quantity value. Examples include size of all transferred data in a whole session.")) (defmethod reset! ((quantity all-time-mixin)) (setf (quantity-empty-value quantity) (quantity-value quantity)) (when (next-method-p) (call-next-method))) ;;; `moments-mixin' mixin class (defclass moments-mixin (format-mixin) () (:default-initargs :format "~,3F ± ~,3F") (:documentation "This mixin class is intended to be mixed into quantity classes that provided mean and variance of a collection of accumulated values.")) (defmethod quantity-value ((quantity moments-mixin)) (let+ (((&accessors-r/o (values quantity-values)) quantity)) (if (emptyp values) (values :n/a :n/a) (values (mean values) (standard-deviation values))))) (defmethod format-value ((quantity moments-mixin) (stream t)) (apply #'format stream (quantity-format quantity) (multiple-value-list (quantity-value quantity)))) ;;; `histogram-mixin' mixin class (defclass histogram-mixin (format-mixin) ((key :initarg :key :type (or null function) :reader quantity-key :initform nil :documentation "A function that maps values to things suitable for use as keys in the VALUES hash-table.") (values :initarg :values :type hash-table :reader quantity-%values :initform (make-hash-table :test #'equalp) :documentation "Stores a mapping from values in the quantity's domain (potentially transformed by KEY) to the respective frequencies of these values. Concretely, members of the mapping are of the form (KEY VALUE) => (VALUE . COUNT) .")) (:default-initargs :format "~:[N/A~;~:*~{~{~A: ~D~}~^, ~}~]") (:documentation "This mixin class is intended to be mixed into quantity classes that accumulate values in form of a histogram.")) (defmethod quantity-values ((quantity histogram-mixin)) (mapcar #'cdr (hash-table-values (quantity-%values quantity)))) (defmethod quantity-value ((quantity histogram-mixin)) (hash-table-values (quantity-%values quantity))) (defmethod update! ((quantity histogram-mixin) (value t)) (let ((key (if-let ((key (quantity-key quantity))) (funcall key value) value))) (incf (cdr (ensure-gethash key (quantity-%values quantity) (cons value 0)))))) (defmethod reset! ((quantity histogram-mixin)) (clrhash (quantity-%values quantity))) (defmethod format-value ((quantity histogram-mixin) (stream t)) (format stream (quantity-format quantity) (map 'list (lambda (cons) (list (car cons) (cdr cons))) (sort (quantity-value quantity) #'> :key #'cdr)))) ;;; `rate-mixin' mixin class (defclass rate-mixin () ((start-time :initarg :start-time :accessor quantity-%start-time :initform nil :documentation "Stores the start time of the current computation period.")) (:documentation "This class is intended to be mixed into quantity classes that compute the rate of a quantity over a period of time. It takes care of tracking the start and end times of time periods and turns a computed absolute value into a rate value using this information.")) (defmethod quantity-value :around ((quantity rate-mixin)) (let+ ((value (call-next-method)) ((&accessors-r/o (start-time quantity-%start-time)) quantity) (now (local-time:now)) (diff (when start-time (local-time:timestamp-difference now start-time)))) (cond ;; Start time not recorded yet or no difference to start time. ((not (and diff (plusp diff))) :n/a) ;; No value recorded for current time period. ((not (realp value)) :n/a) ;; Everything is fine, compute rate. (t (/ value diff))))) (defmethod reset! ((quantity rate-mixin)) (setf (quantity-%start-time quantity) (local-time:now)) (when (next-method-p) (call-next-method))) ;;; `format-mixin' mixin class (defclass format-mixin () ((format :initarg :format :type string :accessor quantity-format :initform "~A" :documentation "Stores the format string that should be used to format the value of the quantity.")) (:documentation "This class is intended to be mixed into quantity classes which format their value by using `cl:format'. It stores a format string which it uses in a method on `format-value' to format the value of the quantity.")) (defmethod format-value ((quantity format-mixin) (stream t)) (format stream (quantity-format quantity) (quantity-value quantity)))
12,391
Common Lisp
.lisp
290
34.131034
71
0.628702
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
aa3509df4c24c1a9c64a55d9784beedcd2691b5443c4cc023add7185298e0b4d
37,384
[ -1 ]
37,385
quantities.lisp
open-rsx_rsb-tools-cl/src/stats/quantities.lisp
;;;; quantities.lisp --- A collection of simple quantities. ;;;; ;;;; Copyright (C) 2011-2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.stats) ;;; Simple quantities (macrolet ((define-simple-quantity ((name &rest initargs &key (designator (make-keyword name)) (pretty-name (format nil "~(~A~)" name)) (access '()) &allow-other-keys) super-classes &optional doc) (let ((class-name (symbolicate "QUANTITY-" name))) `(progn (defclass ,class-name (named-mixin ,@super-classes) () (:default-initargs :name ,pretty-name ,@(remove-from-plist initargs :designator :pretty-name :access)) ,@(when doc `((:documentation ,doc)))) (service-provider:register-provider/class 'quantity ',designator :class ',class-name) ,@(mapcar (lambda (part) `(defmethod rsb.ep:access? ((processor ,class-name) (part (eql ',part)) (mode (eql :read))) t)) access))))) (define-simple-quantity (count :extractor (constantly 1) :format "~:D") (extract-function-mixin collecting-mixin reduction-mixin format-mixin) "This quantity counts events arriving within a period of time.") (define-simple-quantity (count/all-time :pretty-name "Count" :extractor (constantly 1) :format "~:D") (extract-function-mixin all-time-mixin format-mixin) "This quantity counts all arriving events.") (define-simple-quantity (rate :extractor (constantly 1) :format "~,3F") (extract-function-mixin collecting-mixin reduction-mixin rate-mixin format-mixin) "This quantity measures the event rate by counting the events arriving within a period of time.") (define-simple-quantity (period-time :extractor (rcurry #'timestamp :create) :order 2 :filter (lambda (x y) (local-time:timestamp-difference y x)) :access (:timestamp)) (extract-function-mixin filter-mixin collecting-mixin moments-mixin) "This quantity measures the period time based on event timestamps. The default behavior consists in using creation timestamps.") (define-simple-quantity (throughput :extractor (rcurry #'event-size 0) :format "~,3F" :access (:meta-data)) (extract-function-mixin collecting-mixin reduction-mixin rate-mixin format-mixin) "This quantity measures the throughput by accumulating the sizes of event payloads over a period of time. Note that it is not always possible to determine the size of an event payload and that, consequently, the value of this quantity may not reflect the actual throughput in some cases.") (define-simple-quantity (size :extractor (rcurry #'rsb.stats:event-size nil) :access (:meta-data)) (extract-function-mixin collecting-mixin moments-mixin) "This quantity measures the size of events over a period of time and computes mean and variance of the collected values. Note that it is not always possible to determine the size of an event payload and that, consequently, the value of this quantity may not reflect the actual size statistics in some cases.") (define-simple-quantity (size/log :extractor #'rsb.stats:event-size/power-of-2 :access (:meta-data)) (extract-function-mixin histogram-mixin) "The value of this measures is a histogram of event sizes - rounded to the nearest power of 2 - observed over a period of time. When output is produced, the most frequent sizes are printed first.") (define-simple-quantity (size/all-time :pretty-name "Size" :extractor (rcurry #'rsb.stats:event-size nil) :format "~:D" :access (:meta-data)) (extract-function-mixin all-time-mixin format-mixin) "The value of this quantity consists of the accumulated sizes of all events.") (define-simple-quantity (notification-size :extractor (lambda (event) (or (meta-data event :rsb.transport.notification-size) :n/a)) :access (:meta-data)) (extract-function-mixin collecting-mixin moments-mixin) "This quantity measures the size of notifications over a period of time and computes mean and variance of the collected values. Note that it is not always possible to determine the size the notification through which and events has been transmitted and that, consequently, the value of this quantity may not reflect the actual size statistics in some cases.") (define-simple-quantity (scope :extractor (compose #'scope-string #'event-scope) :access (:scope)) (extract-function-mixin histogram-mixin) "The value of this quantity is a histogram of event scopes observed over a period of time. When output is produced, the most frequent scopes are printed first.") (define-simple-quantity (method :extractor #'event-method) (extract-function-mixin histogram-mixin) "The value of this quantity is a histogram of event methods observed over a period of time. When output is produced, the most frequent methods are printed first.") (define-simple-quantity (origin :extractor #'event-origin :key (lambda (uuid) (when uuid (list (uuid::time-low uuid) (uuid::time-mid uuid) (uuid::time-high uuid) (uuid::clock-seq-var uuid) (uuid::clock-seq-low uuid) (uuid::node uuid)))) :access (:origin)) (extract-function-mixin histogram-mixin) "The value of this quantity is a histogram of event origins observed over a period of time. When output is produced, the most frequent event origins are printed first.") (define-simple-quantity (wire-schema :extractor (lambda (event) (meta-data event :rsb.transport.wire-schema)) :access (:meta-data)) (extract-function-mixin histogram-mixin) "The value of this quantity is a histogram of event wire-schemas observed over a period of time. When output is produced, the most frequent event origins are printed first.") (define-simple-quantity (type :extractor #'event-type/simple :access (:meta-data)) (extract-function-mixin histogram-mixin) "The value of this quantity is a histogram of event types over a period of time. When output is produced, the most frequent event types are printed first.")) ;;; Generic meta-data quantities (defclass meta-data-moments (meta-data-mixin collecting-mixin moments-mixin) () (:documentation "This quantity collects the values of a given meta-data item over a period of time and computes mean and variance of the collected values.")) (service-provider:register-provider/class 'quantity :meta-data-moments :class 'meta-data-moments) (defmethod initialize-instance :before ((instance meta-data-moments) &key key) (when (eq key :keys) (error "~@<Value ~S specified for ~S initarg of ~S quantity, but ~ moments cannot be computed over meta-data keys.~@:>" key :key 'meta-data-moments))) (defmethod rsb.ep:access? ((processor meta-data-moments) (part (eql :meta-data)) (mode (eql :read))) t) (defmethod update! ((quantity meta-data-moments) (event string)) (update! quantity (read-from-string event))) (defclass meta-data-histogram (meta-data-mixin histogram-mixin) () (:documentation "The value of this quantity is a histogram of the values of a meta-data item extracted from events over a period of time. When output is produced, the most frequent values are printed first.")) (service-provider:register-provider/class 'quantity :meta-data-histogram :class 'meta-data-histogram) ;;; Latency quantity (defclass latency (named-mixin extract-function-mixin collecting-mixin moments-mixin) ((from :initarg :from :type keyword :accessor quantity-from :initform (missing-required-initarg 'latency :from) :documentation "Stores a key of the \"from\" (i.e. earlier) timestamp of the pair of timestamps for which the latency should be computed.") (to :initarg :to :type keyword :accessor quantity-to :initform (missing-required-initarg 'latency :to) :documentation "Stores a key of the \"to\" (i.e. later) timestamp of the pair of timestamps for which the latency should be computed.")) (:documentation "This quantity collects the differences between specified timestamps and computes the mean and variance of the resulting latency values.")) (service-provider:register-provider/class 'quantity :latency :class 'latency) (defmethod shared-initialize :around ((instance latency) (slot-names t) &rest args &key from to (name (format nil "Latency ~(~A~)-~(~A~)" from to)) (extractor (make-extractor from to))) (apply #'call-next-method instance slot-names :name name :extractor extractor (remove-from-plist args :name :extractor))) (defmethod (setf quantity-from) :after ((new-value t) (quantity latency)) (setf (quantity-extractor quantity) (make-extractor new-value (quantity-to quantity)))) (defmethod (setf quantity-to) :after ((new-value t) (quantity latency)) (setf (quantity-extractor quantity) (make-extractor (quantity-from quantity) new-value))) (defmethod rsb.ep:access? ((processor latency) (part (eql :timestamp)) (mode (eql :read))) t) (defmethod print-object ((object latency) stream) (print-unreadable-object (object stream :type t :identity t) (format stream "~(~A~) - ~(~A~)" (quantity-from object) (quantity-to object)))) (defun make-extractor (from to) (lambda (event) (when-let ((later (timestamp event to)) (earlier (timestamp event from))) (local-time:timestamp-difference later earlier)))) ;;; Expected quantity (defclass expected (named-mixin) ((target :accessor quantity-target :documentation "Stores a quantity the value of which should be checked in order to determine whether something seems faulty.") (expected :reader quantity-expected :writer (setf quantity-%expected) :documentation "Stores a specification of the expected value of the TARGET quantity. Such a specification can be 1. a function 2. a list of the form (:type TYPE) 3. a value") (check :type function :accessor quantity-%check :documentation "Stores a function which implements the check specified by EXPECTED.")) (:default-initargs :name "expected" :target (missing-required-initarg 'expected :target) :expected (missing-required-initarg 'expected :expected)) (:documentation "This quantity checks the value of a \"slave quantity\" against a supplied specification of acceptable values to determine whether an unexpected (normally meaning suspicious or even faulty) value has been encountered.")) (service-provider:register-provider/class 'quantity :expected :class 'expected) (defmethod shared-initialize :after ((instance expected) (slot-names t) &key target (expected nil expected-supplied?)) (when target (setf (quantity-target instance) (make-quantity target))) (when expected-supplied? (setf (quantity-expected instance) expected))) (defgeneric (setf quantity-expected) (new-value quantity) (:method ((new-value function) (quantity expected)) (setf (quantity-%check quantity) new-value)) (:method ((new-value cons) (quantity expected)) (unless (typep new-value '(cons (eql :type))) (return-from quantity-expected (call-next-method))) (let+ (((&structure quantity- target (check %check)) quantity) ((&ign type) new-value)) (setf check (lambda (value) (if (typep value type) (values t value) (values nil value (lambda (stream) (format stream "~@<not a ~S: ~ ~/rsb.stats:print-quantity-value/~@:>" type target)))))))) (:method ((new-value t) (quantity expected)) (let+ (((&structure quantity- target (check %check)) quantity)) (setf check (lambda (value) (if (equal value new-value) (values t value) (values nil value (lambda (stream) (format stream "~@<!~S: ~ ~/rsb.stats:print-quantity-value/~@:>" new-value target)))))))) (:method :after ((new-value t) (quantity expected)) (setf (quantity-%expected quantity) new-value))) (defmethod rsb.ep:access? ((processor expected) (part t) (mode t)) (rsb.ep:access? (quantity-target processor) part mode)) (defmethod quantity-value ((quantity expected)) (let+ (((&structure-r/o quantity- target (check %check)) quantity)) (funcall check (quantity-value target)))) (defmethod reset! ((quantity expected)) (reset! (quantity-target quantity))) (defmethod update! ((quantity expected) (event t)) (update! (quantity-target quantity) event)) (defmethod format-value ((quantity expected) (stream t)) (let+ (((&structure-r/o quantity- target ((&values ok? &ign description) value)) quantity)) (if ok? (format-value target stream) (funcall description stream))))
16,656
Common Lisp
.lisp
364
32.052198
88
0.552278
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
385ecb400886bd71197ec480e0343c7ae2d2937546b874104164dab9663956b4
37,385
[ -1 ]
37,386
package.lisp
open-rsx_rsb-tools-cl/introspect/package.lisp
;;;; package.lisp --- Package definition for rsb-introspect module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.introspect (:use #:cl #:alexandria #:let-plus #:rsb #:rsb.tools.common #:rsb.tools.commands #:net.didierverna.clon) (:export #:main) (:documentation "Main package of the `cl-rsb-tools-introspect' system."))
480
Common Lisp
.lisp
18
23.5
67
0.677632
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6f56b7d2426f88bd00685e6644e1b5ada73fb016cb83fa997c6d799633a05297
37,386
[ -1 ]
37,387
main.lisp
open-rsx_rsb-tools-cl/introspect/main.lisp
;;;; main.lisp --- Entry point of the introspect tool. ;;;; ;;;; Copyright (C) 2014-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.introspect) (defun make-help-string (&key (show :default)) (with-output-to-string (stream) (format stream "Display introspection information for hosts, ~ processes and RSB participants reachable via the ~ transports designated by URI* (zero or more URIs). ~@ ~@ When no URIs are supplied, the default transport ~ configuration is used. ~@ ") (with-abbreviation (stream :uri show) (format stream "URI* are of the form~@ ~@ ") (print-uri-help stream :uri-var "URI*")))) (defun make-style-help-string (&key (show :default)) (with-output-to-string (stream) (with-abbreviation (stream :styles show) (write-string (rsb.formatting::make-style-service-help-string :service 'rsb.formatting.introspection::style :initarg-blacklist '(:database)) stream)))) (defun make-examples-string (&key (program-name "rsb introspect")) (format nil "~2@T~A~@ ~@ Use the default transport configuration to gather a ~ snapshot of the system state and print a tree of hosts, ~ processes and participants.~@ ~@ ~2@T~:*~A socket: spread://somehost~@ ~@ Gather introspection information via two transports: the ~ socket transport and the Spread transport. The gathered ~ information is merged as if all collected processes and ~ participants were participating in a single RSB bus.~@ ~@ ~2@T~:*~A --style monitor/object-tree~@ ~@ Like the first example, but instead of printing one ~ snapshot and exiting, continue gathering introspection ~ information and periodically print an updated object ~ tree.~@ ~@ ~2@T~:*~A --style monitor/events~@ ~@ Continuously collect introspection information and print ~ information about significant changes in the observed ~ system. Significant changes include start and termination ~ of processes and addition and removal of participants.~@ " program-name)) (defun update-synopsis (&key (show :default) (program-name "rsb introspect")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "URI*" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Introspection Options") (lispobj :long-name "response-timeout" :typespec 'positive-real :default-value .5 :argument-name "SECONDS" :description "Time in seconds to wait for responses to introspection requests. In most systems, all replies should arrive within a few milliseconds. However, circumstances like heavily loaded system, degraded system performance or extreme communication latency may require larger values.") (stropt :long-name "style" :short-name "s" :default-value "object-tree" :argument-name "SPEC" :description (make-style-help-string :show show))) ;; Append RSB options. :item (make-options :show? (show-help-for? :rsb :show show)) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the cl-rsb-tools-introspect system." (let ((program-name (concatenate 'string (namestring program-pathname) " introspect"))) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (rsb-tools-introspect-system:version/list :commit? t) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main))) (enable-swank-on-signal)) (let* ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (uris (or (remainder) (list "/"))) (style (getopt :long-name "style")) (response-timeout (getopt :long-name "response-timeout")) (command (make-command :introspect :uris uris :style-spec style :response-timeout response-timeout))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) (with-interactive-interrupt-exit () (command-execute command :error-policy error-policy)))))))
5,594
Common Lisp
.lisp
114
36.859649
210
0.573282
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
26990263963be0c83b285adb25a2eddc0517457e43f59a44cca12c34292ebff9
37,387
[ -1 ]
37,388
package.lisp
open-rsx_rsb-tools-cl/call/package.lisp
;;;; package.lisp --- Package definition for the call utility. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.call (:use #:cl #:alexandria #:iterate #:let-plus #:rsb #:rsb.patterns.request-reply #:rsb.tools.common #:rsb.formatting #:rsb.tools.commands #:net.didierverna.clon) (:export #:main) (:documentation "Main package of the `cl-rsb-tools-call' system."))
528
Common Lisp
.lisp
21
21.857143
66
0.668663
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5fe47f5cd77d72e5ade1209b6ab9c766f73181add609eca01d20d18f3854fe51
37,388
[ -1 ]
37,389
main.lisp
open-rsx_rsb-tools-cl/call/main.lisp
;;;; main.lisp --- Entry point of the call tool. ;;;; ;;;; Copyright (C) 2011-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.call) (defun make-help-string (&key (show :default)) "Return a help that explains the commandline option interface." (with-output-to-string (stream) (format stream "Call METHOD of the server at SERVER-URI with ~ argument ARG.~@ ~@ If ARG is the empty string, i.e. the call ~ specification is of the form ~ SERVER-URI/METHOD(), METHOD is called without ~ argument.~@ ~@ If ARG is one of the strings \"true\" and ~ \"false\", it is parsed as the corresponding ~ Boolean value.~@ ~@ ARG is parsed as string when surrounded with ~ double-quotes and as integer or float number when ~ consisting of digits without and with decimal ~ point respectively.~@ ~@ ARG is parsed as a scope when starting with the ~ \"/\" character.~@ ~@ If ARG is the single character \"-\" or the string ~ \"-:binary\", the entire \"contents\" of standard ~ input (until end of file) is read as a string or ~ octet-vector respectively and used as argument for ~ the method call.~@ ~@ If ARG is of one the forms #P\"PATHNAME\", ~ #P\"PATHNAME\":ENCODING or #P\"PATHNAME\":binary, ~ the file designated by PATHNAME is read into a ~ string (optionally employing ENCODING) or ~ octet-vector and used as argument for the method ~ call.~@ ~@ If ARG is of the form ~ pb:.MESSAGE-TYPE-NAME:{FIELDS}, a protocol buffer ~ message of type MESSAGE-TYPE-NAME is constructed ~ and its fields are populated according to ~ FIELDS. FIELDS uses the syntax produced/consumed ~ by the various TextFormat classes of the protocol ~ buffer API and the --decode/--encode options of ~ the protoc binary.~@ ~@ If ARGUMENT is of one of the forms~@ * pb:.MESSAGE-TYPE-NAME:#P\"PATHNAME\"~@ * pb:.MESSAGE-TYPE-NAME:#P\"PATHNAME\":ENCODING~@ * pb:.MESSAGE-TYPE-NAME:-~@ , a protocol buffer message of type ~ MESSAGE-TYPE-NAME is constructed according to the ~ contents of the file designated by PATHNAME.~@ ~@ Note that, when written as part of a shell ~ command, some of the above forms may require ~ protection from processing by the shell, usually ~ by surrounding the form in single quotes (').~@ ~@ SERVER-URI designates the root scope of the remote ~ server and the transport that should be used.~@ ~@ ") (with-abbreviation (stream :uri show) (format stream "A SERVER-URI of the form~@ ~@ ") (print-uri-help stream :uri-var "SERVER-URI")))) (defun make-examples-string (&key (program-name "rsb call")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A 'spread://localhost:4811/my/interface/method(5)'~@ ~@ Use the spread transport to call the method \"method\" of ~ the server at \"/my/inferface\" passing it the integer ~ argument \"5\".~@ ~@ Note the single quotes (') to prevent the shell from ~ interpreting the \"(\" and \")\".~@ ~@ ~2@T~:*~A 'spread:/interface?name=4803/method(5)'~@ ~@ Like the previous example, but use the \"daemon name\" ~ option of the Spread transport instead of specifying host ~ and port. Note how URI options, being part of the server ~ URI, are inserted between the URI path component and the ~ method name.~@ ~@ ~2@T~:*~A '/my/interface/noarg()'~@ ~@ Use the default transport configuration to call the ~ \"noarg\" method of the server at scope \"/my/interface\" ~ without argument.~@ ~@ ~2@T~:*~A --no-wait '/remotecontrol/stop(\"now\")'~@ ~@ Use the default transport configuration to call the ~ \"stop\" method of the server at scope \"/remotecontrol\" ~ passing it the string argument \"now\". Do not wait for a ~ result of the method call.~@ ~@ ~2@Tcat my-arg.txt | ~:*~A 'socket:/printer/print(-)'~@ ~2@Tcat my-arg.txt | ~:*~A 'socket:/printer/print(-:binary)'~@ ~2@T~:*~A 'socket:/printer/print(#P\"my-data.txt\")'~@ ~2@T~:*~A 'socket:/printer/print(#P\"my-data.txt\":latin-1)'~@ ~2@T~:*~A 'socket:/printer/print(#P\"my-data.txt\":binary)'~@ ~@ Call the \"print\" method of the server at scope ~ \"/printer\" using the socket transform (with its default ~ configuration) using the content of the file \"my-arg.txt\" ~ as argument of the call. This only works if the called ~ method accepts an argument of type string or octet-vector.~@ ~@ Note the use of single quotes (') to prevent elements of ~ the pathname #P\"my-data.txt\" from being processed by the ~ shell.~@ ~@ ~2@T~:*~A \\~@ ~4@T-IPATH-TO-RST/proto/stable/ \\~@ ~4@T-lPATH-TO-RST/proto/stable/rst/robot/RobotCollision.proto \\~@ ~4@T'socket:/mycomponent/handlecollision(~ pb:.rst.robot.RobotCollision:{kind: \"SELF\" ~ collision_detail: { geometry: { contact_points: [ { x: 0 y: ~ 1 z: 2 frame_id: \"foo\" }, { x: 3 y: 4 z: 5 } ] } ~ object_1: \"o1\" } })'~@ ~@ Call the \"handlecollision\" method of the server at scope ~ \"/mycomponent\" with a protocol buffer message ~ argument. The protocol buffer message is of type ~ rst.robot.RobotCollision with kind enum field set to SELF ~ and an embedded rst.kinematics.ObjectCollision message with ~ two contact points in the collision_detail field.~@ ~@ The specification of the message content uses the syntax ~ produced/consumed by the various TextFormat classes of the ~ protocol buffer API and the --decode/--encode options of ~ the protoc binary.~@ ~@ Note how the definition of the protocol buffer message type ~ is loaded using -I and -l commandline options.~@ ~@ " program-name)) (defun update-synopsis (&key (show :default) (program-name "rsb call")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "SERVER-URI/METHOD(ARG)" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Call options") (lispobj :long-name "timeout" :short-name "t" :typespec 'non-negative-real :argument-name "SPEC" :description "If the result of the method call does not arrive within the amount of time specified by SPEC, consider the call to have failed and exit with non-zero status.") (flag :long-name "no-wait" :short-name "w" :description "Do not wait for the result of the method call. Immediately return with zero status without printing a result to standard output.") (stropt :long-name "style" :short-name "s" :default-value "payload :separator nil" :argument-name "SPEC" :description (make-style-help-string :show show))) ;; Append IDL options. :item (make-idl-options) ;; Append RSB options. :item (make-options :show? (or (eq show t) (and (listp show) (member :rsb show)))) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the cl-rsb-tools-call system." (let ((program-name (concatenate 'string (namestring program-pathname) " call"))) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (rsb-tools-call-system:version/list :commit? t) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main))) (enable-swank-on-signal)) ;; Validate commandline options. (unless (length= 1 (remainder)) (error "~@<Supply call specification of the form ~ SERVER-URI/METHOD(ARG).~@:>")) (let ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (spec (first (remainder))) (timeout (getopt :long-name "timeout")) (no-wait? (getopt :long-name "no-wait")) (style (getopt :long-name "style"))) (with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) ;; Load IDLs as specified on the commandline. (process-idl-options :purpose '(:packed-size :serializer :deserializer)) ;; 1. Parse the method call specification ;; 2. Call the method and ;; 3. Potentially wait for a reply ;; Format it (let ((command (make-command :call :call-spec spec :style-spec style :timeout timeout :no-wait? no-wait?))) (with-interactive-interrupt-exit () (command-execute command :error-policy error-policy))))))))
11,236
Common Lisp
.lisp
224
35.852679
183
0.529171
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f1dc0c1fe313d3e3bd91c1b16c41059d87576403821e20e1ac14d32968c80038
37,389
[ -1 ]
37,390
package.lisp
open-rsx_rsb-tools-cl/send/package.lisp
;;;; package.lisp --- Package definition for the send utility. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.send (:use #:cl #:alexandria #:let-plus #:iterate #:rsb #:rsb.tools.common #:rsb.tools.commands #:net.didierverna.clon) (:export #:main) (:documentation "Main package of the `cl-rsb-tools-send' system."))
476
Common Lisp
.lisp
19
21.842105
66
0.662971
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8dfaad7996541a7ace0f47b16eb0fd5035d959cf5cb595f8bf4ba449baf88f68
37,390
[ -1 ]
37,391
main.lisp
open-rsx_rsb-tools-cl/send/main.lisp
;;;; main.lisp --- Entry point of the send tool. ;;;; ;;;; Copyright (C) 2011-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.send) (defun make-help-string (&key (show :default)) "Return a help that explains the commandline option interface." (with-output-to-string (stream) (format stream "Send an event constructed according to EVENT-SPEC ~ to listeners on scopes specified by ~ DESTINATION-URI.~@ ~@ If EVENT-SPEC is the empty string, an event ~ without payload is sent.~@ ~@ If EVENT-SPEC is one of the strings \"true\" and ~ \"false\", it is parsed as the corresponding ~ Boolean value.~@ ~@ EVENT-SPEC is parsed as string when surrounded ~ with double-quotes and as integer or float number ~ when consisting of digits without and with decimal ~ point respectively.~@ ~@ EVENT-SPEC is parsed as a scope when starting with ~ the \"/\" character.~@ ~@ If EVENT-SPEC is the single character \"-\" or the ~ string \"-:binary\", the entire \"contents\" of ~ standard input (until end of file) is read as a ~ string or octet-vector respectively and sent.~@ ~@ If EVENT-SPEC is of one the forms #P\"PATHNAME\", ~ #P\"PATHNAME\":ENCODING or #P\"PATHNAME\":binary, ~ the file designated by PATHNAME is read into a ~ string (optionally employing ENCODING) or ~ octet-vector and sent.~@ ~@ If EVENT-SPEC is of the form ~ pb:.MESSAGE-TYPE-NAME:{FIELDS}, a protocol buffer ~ message of type MESSAGE-TYPE-NAME is constructed ~ and its fields are populated according to ~ FIELDS. FIELDS uses the syntax produced/consumed ~ by the various TextFormat classes of the protocol ~ buffer API and the --decode/--encode options of ~ the protoc binary.~@ ~@ If EVENT-SPEC is of one of the forms~@ * pb:.MESSAGE-TYPE-NAME:#P\"PATHNAME\"~@ * pb:.MESSAGE-TYPE-NAME:#P\"PATHNAME\":ENCODING~@ * pb:.MESSAGE-TYPE-NAME:-~@ , a protocol buffer message of type ~ MESSAGE-TYPE-NAME is constructed according to the ~ contents of the file designated by PATHNAME.~@ ~@ Note that, when written as part of a shell ~ command, some of the above forms may require ~ protection from processing by the shell, usually ~ by surrounding the form in single quotes (').~@ ~@ DESTINATION-URI designates the destination scope ~ to which the event should be sent and the ~ transport configuration which should be used for ~ sending the event.~@ ~@ ") (with-abbreviation (stream :uri show) (progn (format stream "A DESTINATION-URI is of the form~@ ~@ ~2@T") (print-uri-help stream :uri-var "DESTINATION-URI"))))) (defun make-examples-string (&key (program-name "rsb send")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A '' /mycomponent/trigger~@ ~@ Send an event without a payload to the channel designated ~ by the scope /mycomponent/trigger.~@ ~@ Note the use of single quotes (') to allow specifying an ~ empty payload.~@ ~@ ~2@T~:*~A '\"running\"' 'spread:/mycomponent/state'~@ ~@ Send an event whose payload is the string \"running\" to ~ the channel designated by the scope /mycomponent/state.~@ ~@ Note the use of single quotes (') to prevent the shell from ~ processing the double quotes (\") that identify the payload ~ as a string.~@ ~@ ~2@T~:*~A 5 'spread:/somescope?name=4803'~@ ~@ Send an integer. Use spread transport, like in the previous ~ example, but use the \"daemon name\" option of the Spread ~ transport instead of specifying host and port.~@ ~@ Note the use of single quotes (') to prevent elements of ~ the destination URI from being processed by the shell (not ~ necessary for all shells).~@ ~@ ~2@Tcat my-data.txt | ~:*~A -- - 'socket:/printer'~@ ~2@Tcat my-data.txt | ~:*~A -- -:binary 'socket:/printer'~@ ~2@T~:*~A '#P\"my-data.txt\"' 'socket:/printer'~@ ~2@T~:*~A '#P\"my-data.txt\":latin-1' 'socket:/printer'~@ ~2@T~:*~A '#P\"my-data.txt\":binary' 'socket:/printer'~@ ~@ Several ways of sending the content of the file ~ \"my-data.txt\" to the scope \"/printer\" using the socket ~ transport (with its default configuration). These forms can ~ only be used for sending string and octet-vector ~ payloads.~@ ~@ Note the use of single quotes (') to prevent elements of ~ the pathname #P\"my-data.txt\" from being processed by the ~ shell.~@ ~@ ~2@T~:*~A \\~@ ~4@T-IPATH-TO-RST/proto/stable/ \\~@ ~4@T-lPATH-TO-RST/proto/stable/rst/robot/RobotCollision.proto \\~@ ~4@T'pb:.rst.robot.RobotCollision:{kind: \"SELF\" ~ collision_detail: { geometry: { contact_points: [ { x: 0 y: ~ 1 z: 2 frame_id: \"foo\" }, { x: 3 y: 4 z: 5 } ] } ~ object_1: \"o1\" } }'~@ ~4@T'socket:/collisions'~@ ~@ Send a protocol buffer message to scope /collisions. The ~ protocol buffer message is of type rst.robot.RobotCollision ~ with kind enum field set to SELF and an embedded ~ rst.kinematics.ObjectCollision message with two contact ~ points in the collision_detail field.~@ ~@ The specification of the message content uses the syntax ~ produced/consumed by the various TextFormat classes of the ~ protocol buffer API and the --decode/--encode options of ~ the protoc binary.~@ ~@ Note how the definition of the protocol buffer message type ~ is loaded using -I and -l commandline options.~@ ~@ " program-name)) (defun update-synopsis (&key (show :default) (program-name "rsb send")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "EVENT-SPEC [DESTINATION-URI]" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Event Options" :hidden (not (show-help-for? '(:event) :default t :show show))) (stropt :long-name "method" :short-name "m" :argument-name "METHOD" :description "Set the method field of the event being sent to METHOD. Default behavior is sending an event without method field.") (stropt :long-name "meta-data" :short-name "D" :argument-name "NAME=VALUE" :description "Set the meta-data item NAME to VALUE in the event being sent. This option can be specified multiple times for distinct NAMEs.") (stropt :long-name "timestamp" :short-name "T" :argument-name "NAME=YYYY-MM-DD[THH:MM:SS[.µµµµµµ[+ZH:ZM]]]" :description "Set the timestamp named NAME to the timestamp YYYY-MM-DD[THH:MM:SS[.µµµµµµ[+ZH:ZM]]] in the event being sent. This option can be specified multiple times for distinct NAMEs.") (stropt :long-name "cause" :short-name "c" :argument-name "PARTICIPANT-ID:SEQUENCE-NUMBER" :description "Add the event id described by PARTICIPANT-ID:SEQUENCE-NUMBER to the cause vector of the event being sent. This option can be specified multiple times.")) ;; Append IDL options :item (make-idl-options) ;; Append RSB options. :item (make-options :show? (or (eq show t) (and (listp show) (member :rsb show)))) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the cl-rsb-tools-send system." (let ((program-name (concatenate 'string (namestring program-pathname) " send"))) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (rsb-tools-send-system:version/list :commit? t) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main))) (enable-swank-on-signal)) (unless (length= 2 (remainder)) (error "~@<Supply event specification and destination URI.~@:>")) (let+ ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (method (when-let ((value (getopt :long-name "method"))) (make-keyword value))) (meta-data (iter (for value next (getopt :long-name "meta-data")) (while value) (appending (parse-meta-data value)))) (timestamps (iter (for value next (getopt :long-name "timestamp")) (while value) (appending (parse-timestamp value)))) (causes (iter (for value next (getopt :long-name "cause")) (while value) (collect (parse-cause value)))) ((payload-spec &optional (destination "/")) (remainder))) (with-logged-warnings (with-error-policy (error-policy) ;; Load IDLs as specified on the commandline. (process-idl-options :purpose '(:packed-size :serializer :deserializer)) (let ((command (make-command :send :destination destination :method method :meta-data meta-data ; TODO summarize these as some event-spec or something? :timestamps timestamps :causes causes :payload-spec payload-spec))) (with-interactive-interrupt-exit () (command-execute command :error-policy error-policy)))))))
12,062
Common Lisp
.lisp
230
36.904348
198
0.524382
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1f18d8f4a71df24e05721de0df95bc97759c809afdb1816213023f1a2bc1e00b
37,391
[ -1 ]
37,392
package.lisp
open-rsx_rsb-tools-cl/web/package.lisp
;;;; package.lisp --- Package definition for rsb-introspect module. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.web (:use #:cl #:alexandria #:let-plus #:rsb #:rsb.tools.common #:rsb.tools.commands #:net.didierverna.clon) (:export #:main) (:documentation "Main package of the `cl-rsb-tools-web' system."))
442
Common Lisp
.lisp
18
21.388889
67
0.667464
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ae2b437480acc4d1624785e5478868c72e0e5841f41b1568377be8941aec9bc5
37,392
[ -1 ]
37,393
main.lisp
open-rsx_rsb-tools-cl/web/main.lisp
;;;; main.lisp --- Entry point of the web tool. ;;;; ;;;; Copyright (C) 2015, 2016, 2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.web) (defun make-help-string (&key (show :default)) (with-output-to-string (stream) (format stream "Serve system information such as introspection via HTTP. ~ Collect information via the transports designated ~ by URI* (zero or more URIs).~@ ~@ When no URIs are supplied, the default transport ~ configuration is used.~@ ~@ ") (with-abbreviation (stream :uri show) (format stream "URI* are of the form~@ ~@ ") (print-uri-help stream :uri-var "URI*")))) (defun make-examples-string (&key (program-name "rsb web")) (format nil "~2@T~A~@ ~@ Use the default transport configuration to gather a ~ information about the system and serve it on the default ~ address and port (i.e. http://localhost:4444).~@ ~@ ~2@T~:*~A socket: spread://somehost~@ ~@ Gather information via two transports: the socket transport ~ and the Spread transport. The gathered information is ~ merged as if all collected processes and participants were ~ participating in a single RSB bus.~@ " program-name)) (defun update-synopsis (&key (show :default) (program-name "rsb web")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "URI*" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Introspection Options") (lispobj :long-name "response-timeout" :typespec 'positive-real :default-value .5 :argument-name "SECONDS" :description "Time in seconds to wait for responses to introspection requests. In most systems, all replies should arrive within a few milliseconds. However, circumstances like heavily loaded system, degraded system performance or extreme communication latency may require larger values.")) :item (defgroup (:header "HTTP Server Options") (stropt :long-name "address" :default-value "localhost" :argument-name "ADDRESS" :description "Address on which the HTTP server should listen.") (lispobj :long-name "port" :typespec '(integer 0 65535) :default-value 4444 :argument-name "PORT" :description "Port on which the HTTP server should listen.") (path :long-name "document-root" :type :directory :argument-name "DIRECTORY" :description "Directory from which static content such as HTML pages and CSS files should be read. If this option is not supplied, a built-in version of the static content is usually used.") (path :long-name "message-log-file" :type :file :description "Name of a file to which web server message should be logged.") (path :long-name "access-log-file" :type :file :description "Name of a file to which web server accesses should be logged.")) ;; Append RSB options. :item (make-options :show? (show-help-for? :rsb :show show)) ;; HTTP endpoints. :item (defgroup (:header "HTTP Endpoints") (make-text :contents"http://ADDRESS:PORT/ Either the contents of the directory specified via the document-root option or built-in resource files are made available here. http://ADDRESS:PORT/api/introspection/snapshot A JSON-serialization of a snapshot of the introspection data for the system or systems specified via URI can be obtained here. http://ADDRESS:PORT/api/introspection/search Query the introspection database using XPath, receive JSON-serialized results. Return an atomic result for expressions not evaluating to node sets and an array of matches otherwise. An atomic result can be a number or string. For example, the result of the query count(//@foo) is a number. A match can be an attribute match or an element match. Accepted query parameters: * query [required] The (non-empty) query string. One of the following things: * An XPath expression. * One or more words: match any node (element, attribute, text) containing all words. * start: non-negative-integer [optional] Index of first node in match sequence that should be returned. * limit: positive-integer [optional] Number of nodes from the match sequence that should be returned. For all /api/** endpoints at least the content types text/html and application/json are supported. If the Accept header indicates that the response content type should be HTML, the response body is a HTML document containing a human-readable description of the endpoint. If the Accept header indicates that the response content type should be JSON, the response body is of one of the forms {\"data\": DATA} {\"error\": DESCRIPTION} {\"data\": DATA, \"error\": DESCRIPTION} i.e. at least one of the \"data\" and \"error\" properties is present. Both can be present if an error occurs while streaming the body of an initially successful response.")) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the cl-rsb-tools-web system." (let ((program-name (concatenate 'string (namestring program-pathname) " web"))) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (rsb-tools-web-system:version/list :commit? t) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main))) (enable-swank-on-signal)) (let ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (uris (or (remainder) (list "/"))) (response-timeout (getopt :long-name "response-timeout")) (address (getopt :long-name "address")) (port (getopt :long-name "port")) (document-root (getopt :long-name "document-root")) (message-log-file (getopt :long-name "message-log-file")) (access-log-file (getopt :long-name "access-log-file"))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) (let ((command (make-command :web :uris uris :response-timeout response-timeout :address address :port port :document-root document-root :message-log message-log-file :access-log access-log-file))) (with-interactive-interrupt-exit () (command-execute command :error-policy error-policy))))))))
8,205
Common Lisp
.lisp
149
42.597315
211
0.588287
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a6275e55a89b78ff69767ba1a61b77c35ff54786061f6702bc89b2b264eeaf60
37,393
[ -1 ]
37,394
package.lisp
open-rsx_rsb-tools-cl/server/package.lisp
;;;; package.lisp --- Package definition for the server utility. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.server (:use #:cl #:alexandria #:let-plus #:rsb #:rsb.tools.common #:rsb.tools.commands #:net.didierverna.clon) (:export #:main) (:documentation "Main package of the `cl-rsb-tools-server' system."))
469
Common Lisp
.lisp
18
22.888889
66
0.669663
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f409a3fce8fe70fab5c6b65d3665affb39091f87d24d0b0a214752f041441f6c
37,394
[ -1 ]
37,395
main.lisp
open-rsx_rsb-tools-cl/server/main.lisp
;;;; main.lisp --- Entry point of the server tool. ;;;; ;;;; Copyright (C) 2011-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.server) (defun make-help-string (&key (show :default)) "Return a help that explains the commandline option interface." (with-output-to-string (stream) (format stream "Run a server which accepts clients according to ~ URIs.~@ ~@ Currently only supports the RSB socket transport.~@ ~@ ") (with-abbreviation (stream :uri show) (progn (format stream "A URI is of the form~@ ~@ ~2@T") (print-uri-help stream :uri-var "URI"))))) (defun make-examples-string (&key (program-name "rsb server")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A~@ ~@ Unless the RSB configuration is non-default, accept ~ socket connections on the default port.~@ ~@ ~2@T~:*~A 'socket://localhost:0?portfile=/tmp/port.txt'~@ ~@ Accept socket connections on an available port which is ~ written into the file /tmp/port.txt after it has been ~ chosen.~@ ~@ Note the use of single quotes (') to prevent the shell ~ from interpreting syntactically relevant characters in ~ the URI." program-name)) (defun update-synopsis (&key (show :default) (program-name "rsb server")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "URI*" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) ;; Append RSB options. :item (make-options :show? (or (eq show t) (and (listp show) (member :rsb show)))) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the cl-rsb-tools-server system." (let ((program-name (concatenate 'string (namestring program-pathname) " server"))) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (rsb-tools-server-system:version/list :commit? t) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main))) (enable-swank-on-signal)) (let+ ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (uris (or (remainder) (list "/")))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) (let ((command (make-command :server :uris uris))) (with-interactive-interrupt-exit () (command-execute command :error-policy error-policy))))))))
3,473
Common Lisp
.lisp
78
34.038462
74
0.576276
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5770a7c14b34e9cbe64e83dfaa55cb231034eb90b9df31ecbcfcddb349cbb539
37,395
[ -1 ]
37,396
package.lisp
open-rsx_rsb-tools-cl/logger/package.lisp
;;;; package.lisp --- Package definition for rsb-logger module. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsb.tools.logger (:use #:cl #:alexandria #:iterate #:let-plus #:more-conditions #:rsb #:rsb.tools.common #:rsb.formatting #:rsb.tools.commands #:net.didierverna.clon) (:export #:main) (:documentation "Main package of the `cl-rsb-tools-logger' system."))
522
Common Lisp
.lisp
21
21.571429
66
0.668687
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d7cae7e10ad40874c5f99b758213dd20600a149bd7b4f32f65c457ff6caecf14
37,396
[ -1 ]
37,397
main.lisp
open-rsx_rsb-tools-cl/logger/main.lisp
;;;; main.lisp --- Entry point of the logger tool. ;;;; ;;;; Copyright (C) 2011-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.logger) (defun update-synopsis (&key (show :default) (program-name "rsb logger")) "Create and return a commandline option tree." (make-synopsis ;; Basic usage and specific options. :postfix "URI*" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (defgroup (:header "Logging Options" :hidden (not (show-help-for? '(:logging :filters :styles :columns :quantities) :default t :show show))) (stropt :long-name "filter" :short-name "f" :argument-name "SPEC" :description (make-filter-help-string :show show)) (stropt :long-name "style" :short-name "s" :default-value "monitor" :argument-name "SPEC" :description (make-style-help-string :show show)) (lispobj :long-name "max-queued-events" :typespec '(or null positive-integer) :default-value 2000 :argument-name "NUMBER-OF-EVENTS" :description "The maximum number of events which may be queued for processing at any given time. Note that choosing a large value can require a large amount of memory.") (lispobj :long-name "stop-after" :typespec 'positive-integer :argument-name "NUMBER-OF-EVENTS" :description "Terminate after the specified number of events have been processed.")) :item (make-idl-options) ;; Append RSB options. :item (make-options :show? (show-help-for? :rsb :show show)) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun main (program-pathname args) "Entry point function of the cl-rsb-tools-logger system." (let ((program-name (concatenate 'string (namestring program-pathname) " logger"))) (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (process-commandline-options :commandline (list* program-name args) :version (rsb-tools-logger-system:version/list :commit? t) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main))) (enable-swank-on-signal)) (let* ((error-policy (maybe-relay-to-thread (process-error-handling-options))) (uris (or (remainder) (list "/"))) (filters (iter (for spec next (getopt :long-name "filter")) (while spec) (collect (apply #'rsb.filter:filter (parse-instantiation-spec spec))))) (event-style (getopt :long-name "style")) (max-queued-events (getopt :long-name "max-queued-events")) (stop-after (getopt :long-name "stop-after")) (while-function (when stop-after (lambda (count event) (declare (ignore event)) (< count stop-after))))) (with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) ;; Load IDLs as specified on the commandline. TODO should the command do this? (process-idl-options :purpose '(:deserializer)) ;; The command creates the required participants and starts ;; the receiving and printing loop. (let ((command (apply #'make-command :logger :uris uris :style-spec event-style :max-queued-events max-queued-events :while while-function (when filters (list :filters filters))))) (with-interactive-interrupt-exit () (command-execute command :error-policy error-policy))))))))
4,875
Common Lisp
.lisp
93
36.311828
179
0.512246
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
adc854098575dd9d56e6e5db07b5bd4c6eb8b6c26718c59bc08082d60ca55fa9
37,397
[ -1 ]
37,398
help.lisp
open-rsx_rsb-tools-cl/logger/help.lisp
;;;; help.lisp --- Help text generation for the logger program. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsb.tools.logger) (defun make-help-string (&key (show :default)) "Return a help that explains the commandline option interface." (with-output-to-string (stream) (format stream "Show events exchanged on the RSB channel ~ designated by URIs. Events can be filtered and ~ displayed in several ways which can be controlled ~ using the --filter and --style options.~@ ~@ URIs designate the channel or channels for which ~ events should be received and logged and the ~ transport that should be used to attach to ~ channel(s). If no URIs are specified the root ~ scope / and default transports are assumed.~@ ~@ ") (with-abbreviation (stream :uri show) (format stream "Zero or more URIs of the form~@ ~@ ~2@T") (print-uri-help stream)))) (defun make-examples-string (&key (program-name "rsb logger")) "Make and return a string containing usage examples of the program." (format nil "~2@T~A~@ ~@ Use all enabled transports with their respective ~ default configuration to access the bus. Receive and ~ display all events exchanged on the entire bus (since ~ the channel designated by the root scope, \"/\", is ~ implicitly used).~@ ~@ ~2@T~:*~A spread://localhost:4811~@ ~@ Use the Spread daemon listening on port 4811 on ~ localhost to connect to the bus. Since no scope is ~ specified, receive and print all events exchanged on ~ the entire bus.~@ ~@ ~2@T~:*~A -f 'regex :regex ~ \"^mypattern\" :fallback-policy :do-not-match' ~ --style detailed spread:/my/channel~@ ~@ Use the default configuration of the Spread transport ~ to connect to the bus. Receive events on the channel ~ designated by \"/my/channel\" (and sub-channels) the ~ payloads of which match the regular expression ~ \"^mypattern\". Display matching events using the ~ \"detailed\" display style.~@ ~@ ~2@T~:*~A socket:/foo spread:/bar~@ ~@ Display events from two channels: the channel ~ designated by \"/foo\", accessed via Spread transport, ~ and the channel designated by \"/bar\", accessed via ~ socket transport." program-name))
2,992
Common Lisp
.lisp
62
34.370968
71
0.543218
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e2daa3e842dcbaab3b629018ec9f4a3dca4abf995a3aad35f157d8a29bb01072
37,398
[ -1 ]
37,399
plot-events.lisp
open-rsx_rsb-tools-cl/scripts/plot-events.lisp
;;;; plot-events.lisp --- Plot events for multiple scopes. ;;;; ;;;; Copyright (C) 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> ;;;; Requires Gnuplot version 4.6 or newer. (unless (boundp 'initialized?) (setf (symbol-value 'initialized?) t *random-state* (make-random-state t)) (let+ (;; Tunable parameters (timestamp :receive) (terminal-name "pngcairo") (terminal-options "enhanced font \"Verdana,12\" size 2000, 1500") (type "png") ;; http://www.gnuplotting.org/ease-your-plotting-with-config-snippets/ (borders (format nil "set border 0~@ set style line 101 lt 0 lw 2 lc rgb '#808080'~@ set grid back ls 101")) ;; http://www.gnuplotting.org/tag/colormap/ (colors #+no '(#x0072bd #xd95319 #xedb120 #x7e2f8e #x77ac30 #x4dbeee #xa2142f)) (palette (when colors (with-output-to-string (stream) (loop :for i :from 1 :to 100 :for color :in (apply #'circular-list colors) :do (format stream "set style line ~D lt 1 lc rgb '#~6,'0X'~%" i color) :finally (write-string "set style increment user" stream))))) (tick-count-limit 100) ;; Internal ((&flet random-name (type) (format nil "/tmp/~8,'0X.~A" (random (expt 16 8)) type))) (plot-file (random-name "plt")) (scopes (make-hash-table :test #'eq))) (defun open-data-file () (let ((data-file (random-name "txt"))) (values data-file (open data-file :if-does-not-exist :create :if-exists :supersede :direction :output)))) (defun process-event (event) (let+ ((scope (intern-scope (event-scope event))) (timestamp (timestamp event timestamp)) ((&ign stream) (ensure-gethash scope scopes (multiple-value-list (open-data-file)))) (*print-pretty* nil)) (format stream "~A, ~A~%" timestamp (event-size event)))) (defun write-plot-commands-for-scope (stream scope file timestamps index first? tics?) (let* ((scope (scope-string scope)) (title (ppcre:regex-replace-all "_" scope "\\\\\\\\_"))) (format stream "~:[, \\~%~:;~]~S ~ u ~D:(~F):(log10(3+$~D/100))~:[~:;:yticlabel(\"~A\")~] ~ pt 7 ps variable notitle" first? file 1 index 2 tics? title))) (defun write-plot-commands (scopes output script) (with-output-to-file (stream script :if-does-not-exist :create :if-exists :supersede) (let* ((scope-count (hash-table-count scopes)) (tick-divisor (max 1 (ceiling scope-count tick-count-limit)))) (format stream "set terminal ~A~@[ ~A~] set output \"~A.~A\" ~@[~A~] ~A set xdata time set timefmt \"%Y-%m-%dT%H:%M:%S+01:00\" set xtics font \",10\" set xtics rotate by -30 set ytics font \",10\" set title \"Events by ~(~A~) timestamp\" plot " terminal-name terminal-options output type palette borders timestamp) (iter (for (scope . (file)) in (sort (hash-table-alist scopes) #'string< :key (compose #'scope-string #'car))) (for index :from 0) (for first? :first t :then nil) (write-plot-commands-for-scope stream scope file timestamp index first? (zerop (mod index tick-divisor))))))) (push (lambda () (mapc (compose #'close #'second) (hash-table-values scopes)) (write-plot-commands scopes "events" plot-file) (sb-ext:run-program "gnuplot" (list plot-file) :search t :error *error-output*) (mapc (compose #'delete-file #'first) (hash-table-values scopes)) (delete-file plot-file)) sb-ext:*exit-hooks*))) (process-event %event)
4,700
Common Lisp
.lisp
93
34.634409
90
0.479747
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d927bdab2d7e8fb979b8a839ea71917fba652b5c21fcbd8603b93caf570d82d3
37,399
[ -1 ]
37,400
rsb-formatting-json.asd
open-rsx_rsb-tools-cl/rsb-formatting-json.asd
;;;; rsb-formatting-json.asd --- Formatting support for JSON payloads. ;;;; ;;;; Copyright (C) 2014-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> #.(progn (load (merge-pathnames "rsb-formatting.asd" *load-truename*)) (values)) (cl:in-package #:rsb-formatting-system) ;;; System definitions (defsystem :rsb-formatting-json :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "This system provides some formatting of JSON payloads." :depends-on (:alexandria :let-plus (:version :architecture.builder-protocol.universal-builder "0.3") (:version :architecture.builder-protocol.json "0.3") (:version :rsb-builder #.(version/string :revision? nil)) (:version :rsb-model-builder #.(version/string :revision? nil)) (:version :rsb-formatting #.(version/string))) :encoding :utf-8 :components ((:module "formatting" :pathname "src/formatting" :components ((:file "event-style-json"))) (:module "formatting-introspection" :pathname "src/formatting/introspection" :depends-on ("formatting") :components ((:file "json")))) :in-order-to ((test-op (test-op :rsb-formatting/test))))
1,653
Common Lisp
.asd
32
43.40625
109
0.576303
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3d2b0240681dd3d68dcc8b0d51559b7f802d41b943ff5a1168bc2c47b36c3b35
37,400
[ -1 ]
37,401
rsb-formatting-and-rsb-common.asd
open-rsx_rsb-tools-cl/rsb-formatting-and-rsb-common.asd
;;;; rsb-formatting-and-rsb-common.asd --- Commandline options for formatting styles. ;;;; ;;;; Copyright (C) 2013-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (load (merge-pathnames "rsb-formatting.asd" *load-pathname*)) (cl:in-package #:rsb-formatting-system) ;;; System definition (defsystem :rsb-formatting-and-rsb-common :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "This system adds formatting-related handling of commandline options." :depends-on ((:version :rsb-formatting #.(version/string)) (:version :rsb-tools-common #.(version/string))) :encoding :utf-8 :components ((:file "help" :pathname "src/formatting/help")))
918
Common Lisp
.asd
20
42.25
85
0.692394
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3ba34164cb0eb647d55dc41f8f2bf8ff44bd624bf085dd35b74f770e5e6804f8
37,401
[ -1 ]
37,402
rsb-tools-commands-web-resources.asd
open-rsx_rsb-tools-cl/rsb-tools-commands-web-resources.asd
;;;; rsb-tools-commands-web-resources.asd --- Serve resources from image over HTTP. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> #.(cl:progn (cl:load (cl:merge-pathnames "rsb-tools-commands.asd" cl:*load-truename*)) (cl:values)) (cl:in-package #:rsb-tools-commands-system) ;;; System definition (defsystem :rsb-tools-commands-web-resources :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "Serve web interface resources from image over HTTP." :depends-on (:alexandria :let-plus (:version :log4cl "1.1.1") :hunchentoot :archive (:version :rsb-tools-commands #.(version/string)) (:version :rsb-tools-commands-web #.(version/string))) :encoding :utf-8 :components ((:file "src/commands/web/resources")))
1,103
Common Lisp
.asd
25
38.16
83
0.637127
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e1cf290cc13bdeab67546a9ccf983efde0911a6aab6ec52d1203cc130e53be1a
37,402
[ -1 ]
37,403
rsb-formatting-and-rsb-stats.asd
open-rsx_rsb-tools-cl/rsb-formatting-and-rsb-stats.asd
;;;; rsb-formatting-and-rsb-stats.asd --- Formatting styles based on rsb-stats. ;;;; ;;;; Copyright (C) 2013-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (load (merge-pathnames "rsb-formatting.asd" *load-pathname*)) (cl:in-package #:rsb-formatting-system) ;;; System definition (defsystem :rsb-formatting-and-rsb-stats :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "This system adds a column-based event formatting style, the columns of which are quantities defined in the rsb-stats system." :depends-on ((:version :rsb-formatting #.(version/string)) (:version :rsb-stats #.(version/string))) :encoding :utf-8 :components ((:module "formatting" :pathname "src/formatting" :serial t :components ((:file "timeline") (:file "quantity-column") (:file "event-style-statistics") (:file "event-style-monitor") (:file "event-style-timeline")))))
1,316
Common Lisp
.asd
27
40.037037
79
0.596573
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d749b9edc1112a80b84f0559406abd67d599b50bacc6c9b0c24abf9c3ea5a0bc
37,403
[ -1 ]
37,404
rsb-tools-commands-web.asd
open-rsx_rsb-tools-cl/rsb-tools-commands-web.asd
;;;; rsb-tools-commands-web.asd --- Serve system information over HTTP. ;;;; ;;;; Copyright (C) 2014-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> #.(cl:progn (cl:load (cl:merge-pathnames "rsb-tools-commands.asd" cl:*load-truename*)) (cl:values)) (cl:in-package #:rsb-tools-commands-system) ;;; System definition (defsystem :rsb-tools-commands-web :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "Serve introspection information over HTTP." :depends-on (:alexandria :let-plus (:version :log4cl "1.1.1") (:version :architecture.builder-protocol.json "0.4") (:version :architecture.builder-protocol.xpath "0.4") :hunchentoot (:version :rsb #.(version/string :revision? nil)) (:version :rsb-introspection #.(version/string :revision? nil)) (:version :rsb-model-builder #.(version/string :revision? nil)) (:version :rsb-tools-commands #.(version/string)) (:version :rsb-formatting-json #.(version/string))) :encoding :utf-8 :components ((:module "web" :pathname "src/commands/web" :serial t :components ((:file "package") (:file "protocol") (:file "conditions") (:file "mixins") (:file "macros") (:file "command") (:file "introspection")))) :in-order-to ((test-op (test-op :rsb-tools-commands-web/test)))) (defsystem :rsb-tools-commands-web/test :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "Unit tests for rsb-tools-commands system." :depends-on (:alexandria :let-plus :drakma (:version :lift "1.7.1") (:version :rsb-tools-commands-web #.(version/string)) (:version :rsb/test #.(version/string :revision? nil)) (:version :rsb-tools-commands/test #.(version/string :revision? nil))) :encoding :utf-8 :components ((:module "commands" :pathname "test/commands/web" :serial t :components ((:file "package") (:file "command"))))) (defmethod perform ((operation test-op) (component (eql (find-system :rsb-tools-commands-web/test)))) (funcall (find-symbol "RUN-TESTS" :lift) :config (funcall (find-symbol "LIFT-RELATIVE-PATHNAME" :lift) "lift-rsb-tools-commands-web.config")))
3,302
Common Lisp
.asd
63
40.507937
97
0.524371
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cb3ea50f919446b9fe99e1ba33e00daaa2d559b20ca7a158301c77103c5244c7
37,404
[ -1 ]
37,405
rsb-formatting-png.asd
open-rsx_rsb-tools-cl/rsb-formatting-png.asd
;;;; rsb-formatting-png.asd --- Formatting support for PNG payloads. ;;;; ;;;; Copyright (C) 2013-2019 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> #.(progn (load (merge-pathnames "rsb-formatting.asd" *load-truename*)) (values)) (cl:in-package #:rsb-formatting-system) ;;; System definition (defsystem :rsb-formatting-png :author "Jan Moringen <[email protected]>" :maintainer "Jan Moringen <[email protected]>" :version #.(version/string) :license "GPLv3" ; see COPYING file for details. :description "This system provides some formatting of PNG payloads." :depends-on (:alexandria :let-plus :iterate :zpng (:version :rsb-formatting #.(version/string :revision? nil))) :encoding :utf-8 :components ((:module "formatting" :pathname "src/formatting" :components ((:file "payload-image-png")))) :in-order-to ((test-op (test-op :rsb-formatting/test))))
1,079
Common Lisp
.asd
26
35.461538
77
0.638623
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1c182bdf8c1420e4bd5422b9de690c159795b4de5ab7eb811dba579b60aa343b
37,405
[ -1 ]
37,406
sbclrc
open-rsx_rsb-tools-cl/sbclrc
(defun load-system (system) (let ((*compile-verbose* nil) (*compile-print* nil) (*load-verbose* nil) (*load-print* nil)) (ql:quickload system :verbose nil :explain nil :prompt nil)))
223
Common Lisp
.cl
6
31.166667
65
0.589862
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
913f91816da8dc8c673bc3054e25a43314e99971c25824fa15a95a5d7913e7ad
37,406
[ -1 ]
37,407
sbcl.cmake.in
open-rsx_rsb-tools-cl/sbcl.cmake.in
# Work around clon's attempt to compile termio stuff on win32. if(NOT WIN32) set(ENV{CC} "@CMAKE_C_COMPILER@") endif() 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@ --load "@CMAKE_CURRENT_SOURCE_DIR@/sbclrc" @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()
962
Common Lisp
.cl
21
30.761905
76
0.5
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5c62807dd4f2a03e65967c64a8469c8e6d240867047b9b10dde66b03ea33c8db
37,407
[ -1 ]
37,408
CPackInclude.cmake
open-rsx_rsb-tools-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)
522
Common Lisp
.cl
10
50
198
0.775591
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0226db680780bdc8029d641eca88c852cbe38ff03231ec5aa187ad6f9334f0d1
37,408
[ -1 ]
37,412
lift-rsb-tools-commands-web.config
open-rsx_rsb-tools-cl/lift-rsb-tools-commands-web.config
;;; Configuration for LIFT tests ;; Settings (:print-length 10) (:print-level 5) (:print-test-case-names t) ;; Suites to run (rsb.tools.commands.web.test:commands-web-root) ;; Report properties (:report-property :title "rsb-tools-commands-web | Test Results") (:report-property :relative-to rsb-tools-commands-web-test) (:report-property :format :html) (:report-property :full-pathname "test-report-rsb-tools-commands-web.html/") (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :format :junit) (:report-property :full-pathname "test-results-rsb-tools-commands-web.xml") (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
864
Common Lisp
.l
22
38
76
0.721292
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
20bfd67fddb909de3b2077e19e18fbe8fca96b1b82a4b0e3b13bef4abf54bd83
37,412
[ -1 ]
37,414
lift-rsb-tools-common.config
open-rsx_rsb-tools-cl/lift-rsb-tools-common.config
;;; Configuration for LIFT tests ;; Settings (:print-length 10) (:print-level 5) (:print-test-case-names t) ;; Suites to run (rsb.tools.common.test:common-root) ;; Report properties (:report-property :title "rsb-tools-common | Test Results") (:report-property :relative-to rsb-tools-common-test) (:report-property :format :html) (:report-property :full-pathname "test-report-rsb-tools-common.html/") (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :format :junit) (:report-property :full-pathname "test-results-rsb-tools-common.xml") (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
828
Common Lisp
.l
22
36.363636
70
0.71625
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6a9468d375d390d9a920156530359142886b52144dab35213aaa2763818de119
37,414
[ -1 ]
37,416
lift-rsb-tools-commands.config
open-rsx_rsb-tools-cl/lift-rsb-tools-commands.config
;;; Configuration for LIFT tests ;; Settings (:print-length 10) (:print-level 5) (:print-test-case-names t) ;; Suites to run (rsb.tools.commands.test:commands-root) ;; Report properties (:report-property :title "rsb-tools-commands | Test Results") (:report-property :relative-to rsb-tools-commands-test) (:report-property :format :html) (:report-property :full-pathname "test-report-rsb-tools-commands.html/") (:report-property :if-exists :supersede) (:report-property :style-sheet "test-style.css") (:build-report) (:report-property :format :junit) (:report-property :full-pathname "test-results-rsb-tools-commands.xml") (:report-property :if-exists :supersede) (:build-report) (:report-property :format :describe) (:report-property :full-pathname *standard-output*) (:build-report)
840
Common Lisp
.l
22
36.909091
72
0.720443
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ca84a78eb98f3a0b33a74e11acd87db8e0a412864e036eec6d8d348d809d1237
37,416
[ -1 ]
37,417
Simple.proto
open-rsx_rsb-tools-cl/test/data/test/Simple.proto
package test; message Simple { required bytes data = 1; }
62
Common Lisp
.l
4
13.5
28
0.724138
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f5c9ecd004bd16abf887837f80aee4d34085566e74263b95a93871989c8885f9
37,417
[ -1 ]
37,536
hack.html
open-rsx_rsb-tools-cl/resources/hack.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Web: Hack</title> <link rel="stylesheet" type="text/css" href="base.css"/> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="https://code.cor-lab.org/projects/rsb"> <img alt="Brand" src="/images/logo.png"/> </a> </div> <ol class="nav navbar-nav"> <ol class="breadcrumb"> <li><a href="../index.html"><span class="glyphicon glyphicon-home"></span></a></li> <li class="active">Hack</li> </ol> </ol> </div> </nav> </header> <main class="container"> <div class="panel panel-default"> <div class="panel-body"> <!-- TODO adapt this according to presence or absence of --document-root option --> <ol> <li> <p> <a href="source.tar"> <span class="glyphicon glyphicon-download"></span> Download HTML, CSS and Javascript sources. </a> </p> <p> All files obtained in this download are made available under the <a href="https://fsf.org/licenses/gpl.html">GNU General Public License Version 3</a> unless stated differently in a specific directory or file. </p> <p> A particular exception are the files in the <code>lib/</code> directory which come with their own license information and are mostly distributed under the <a href="https://en.wikipedia.org/wiki/MIT_License">MIT License</a>. </li> <li> Save sources in a directory <samp>DIRECTORY</samp> </li> <li> Restart server, telling it to serve from <samp>DIRECTORY</samp>: <pre>$ rsb-tools web --document-root <samp>DIRECTORY</samp></pre> </li> <li>Hack</li> </ol> </div> </div> </main> <footer> <div class="muted credit"> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web </div> </footer> </body> </html>
2,511
Common Lisp
.l
71
24.15493
97
0.510481
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
82f3b818aa3f90d77491cbab02a6afa474e04d2e56aade91b90ebac8ac6f7647
37,536
[ -1 ]
37,537
index.html
open-rsx_rsb-tools-cl/resources/index.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Web Tools</title> <link rel="stylesheet" type="text/css" href="base.css"/> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="https://code.cor-lab.org/projects/rsb"> <img alt="Brand" src="/images/logo.png"/> </a> </div> <ol class="nav navbar-nav"> <ol class="breadcrumb"> <li class="active"><span class="glyphicon glyphicon-home"></span></li> </ol> </ol> </div> </nav> </header> <main class="container"> <div class="list-group"> <a href="introspection/root.html" class="list-group-item"> <h4 class="list-group-item-heading">Introspection</h4> Browse hosts, processes and participants of a running RSB system. </a> </div> <p> <small> This program comes with ABSOLUTELY NO WARRANTY. This program is free software, and you are welcome to redistribute most parts under the terms and conditions of the <a href="https://fsf.org/licenses/gpl.html">GNU General Public License Version 3</a>. </small> </p> </main> <footer> <div class="muted credit"> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web | <a href="/hack.html">Modify this web interface</a> </div> </footer> </body> </html>
1,674
Common Lisp
.l
50
25.34
84
0.57081
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e197957fe900a691e97dd5c06088a4c83017424fc0b1194a84e7f7b9c66fd13f
37,537
[ -1 ]
37,538
search.html
open-rsx_rsb-tools-cl/resources/introspection/search.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Web: Introspection</title> <link rel="stylesheet" type="text/css" href="base.css"/> <style> #search-help ul li:not(:first-child):before { content: "|"; } #search-help ul li { display: inline; list-style-type: none; } </style> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="https://code.cor-lab.org/projects/rsb"> <img alt="Brand" src="/images/logo.png"/> </a> </div> <ol class="nav navbar-nav"> <ol class="breadcrumb"> <li><a id="breadcrumbs-root" href="../index.html"><span class="glyphicon glyphicon-home"></span></a></li> <li><a id="breadcrumbs-introspection" href="root.html">Introspection</a></li> <li class="active">Search</li> </ol> </ol> </div> </nav> </header> <main class="container-fluid"> <div class="panel panel-default"> <div class="panel-body"> <form id="search" role="search"></form> <small id="search-help"> <ul> <li> Simple queries searching for one or more words in all attributes <a href="?query=linux"><code>linux</code></a> </li> <li> Select host, process or participant nodes with <a href="?query=//host"><code>//host</code></a>, <a href="?query=//process"><code>//process</code></a>, <a href="?query=//participant"><code>//participant</code></a> </li> <li> Select attributes with <a href="?query=//@id"><code>//@id</code></a> </li> <li> Combine the two <a href="?query=//host/@id"><code>//host/@id</code></a> </li> <li> Restrict matches with predicates <a href="?query=//participant[@kind!=&quot;listener&quot;]"><code>//participant[@kind!="listener"]</code></a> </li> <li> Substring match <a href="?query=//participant/@scope[contains(., &quot;/&quot;)]"> <code>//participant/@scope[contains(., "/")]</code> </a> </li> </ul> </small> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Matches <span id="result-count" class="badge"></span> </h2> </div> <div class="panel-body"> <div class="container-fluid"> <div class="row"> <div id="result-list" class="col-md-8"></div> <div id="result-plot" class="col-md-4" style="display: none"></div> </div> </div> </div> </div> </main> <footer> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web | <a href="/hack.html">Modify this web interface</a> </footer> <script type="text/javascript" src="../lib/jquery-2.1.3/jquery.min.js"></script> <script type="text/javascript" src="../lib/bootstrap-3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript" src="../lib/flot-0.8.3/jquery.flot.min.js"></script> <script type="text/javascript" src="../lib/flot-0.8.3/jquery.flot.pie.min.js"></script> <script type="text/javascript" src="Introspection.js"></script> <script type="text/javascript" src="SearchWidget.js"></script> <script type="text/javascript" src="introspection.js"></script> <script type="text/javascript"> var introspection = new Introspection(); var search = new SearchWidget(introspection, $('#search')); $(function () { search.on('submit', function(event) { showRunning($('#result-list'), $('#result-count')); }); search.on('result', function(event, result) { showResults($('#result-list'), $('#result-count'), $('#result-plot'), result); }); search.on('error', function(event, error) { showError($('#result-list'), $('#result-count'), error); }); var query = getURLParameter('query'); if (query) { search.setValue(query); search.search(); } }) </script> </body> </html>
4,782
Common Lisp
.l
125
27.456
125
0.51034
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
937c9b4ce76952475f29b1af6299a486a0a64284f6587bf34cf67bec570556ac
37,538
[ -1 ]
37,539
root.html
open-rsx_rsb-tools-cl/resources/introspection/root.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Web: Introspection</title> <link rel="stylesheet" type="text/css" href="base.css"/> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <span class="navbar-brand"> <img alt="Brand" src="/images/logo.png"/> </span> </div> <div class="collapse navbar-collapse"> <div class="nav navbar-nav"> <ol id="breadcrumbs"></ol> </div> <div id="refresh" class="navbar-form navbar-right"></div> <form id="global-search" class="navbar-form navbar-right" role="search"> </form> </div> </div> </nav> </header> <main class="container-fluid"> <div class="row"> <div id="col-main" class="col-md-8"> <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title">Summary</h2></div> <div id="summary" class="panel-body"> <div class="container-fluid"> <div class="row"> <div id="col-main" class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Hosts <span id="host-count" class="badge"></span> </h2> </div> <div id="host-list" class="panel-body"></div> </div> </div> <div id="col-main" class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Processes <span id="process-count" class="badge"></span> </h2> </div> <div id="process-list" class="panel-body"></div> </div> </div> </div> </div> </div> </div> </div> <div id="col-graph" class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Overview </h2> </div> <div id="graph" class="panel-body"> <em>coming soonâ„¢</em> </div> </div> </div> </div> </main> <footer> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web | <a href="/hack.html">Modify this web interface</a> </footer> <script type="text/javascript" src="../lib/jquery-2.1.3/jquery.min.js"></script> <script type="text/javascript" src="Introspection.js"></script> <script type="text/javascript" src="introspection.js"></script> <script type="text/javascript" src="BreadcrumbsWidget.js"></script> <script type="text/javascript" src="SearchWidget.js"></script> <script type="text/javascript" src="RefreshWidget.js"></script> <script type="text/javascript"> var introspection = new Introspection(); var breadcrumbs = new BreadcrumbsWidget(introspection, $('#breadcrumbs'), { level: 'introspection' }); var search = new GlobalSearchWidget(introspection, $('#global-search')); var refreshTODO = new RefreshWidget(introspection, $('#refresh')); var timer; function refresh() { if (timer) clearTimeout(timer); function refreshBlock(query, listElement, countElement) { showRunning(listElement, countElement); introspection.search('query=' + query) .done(function(result) { showResults(listElement, countElement, null, result, { max: 20, flat: true }); }) .fail(function(message) { showError(listElement, countElement, message); }); } refreshBlock('children/host', $('#host-list'), $('#host-count')); refreshBlock('children/host/children/process', $('#process-list'), $('#process-count')); timer = setTimeout(refresh, 10000); } $(function () { refresh(); }); </script> </body> </html>
4,680
Common Lisp
.l
117
26.948718
98
0.492193
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d9e23b1c8f5bf60667f0163ff900ee45d3510ba72e41c2eb3e36d49e35980b47
37,539
[ -1 ]
37,540
DetailsWidget.js
open-rsx_rsb-tools-cl/resources/introspection/DetailsWidget.js
// Copyright (C) 2014, 2015, 2016 Jan Moringen // // Author: Jan Moringen <[email protected]> // requires moment.js /// Utility functions function makeTitle(kind, id, title) { var urlSpec = {}; urlSpec[id] = undefined; return $('<td> \ <a href="' + makeSearchURL(kind, urlSpec) + '">' + title + '</a> \ </td>'); } function makeSimpleValue(id) { return $('<td id="' + id + '-value" style="font-family: monospace"> \ <span class="glyphicon glyphicon-refresh glyphicon-spin"></span> \ </td>'); } function updateSimpleValue(element, kind, id, value) { var urlSpec = {}; urlSpec[id] = value; var url = makeSearchURL(kind, urlSpec); element.find('#' + id + '-value').html('<a href="' + url + '">' + value + '</a>'); } function makeTimeValue(id) { return $('<td> \ <span id="' + id + '-value" style="font-family: monospace"> \ <span class="glyphicon glyphicon-refresh glyphicon-spin"></span> \ </span> \ <span id="' + id + '-livestamp" style="font-style: italic"> \ <span class="glyphicon glyphicon-refresh glyphicon-spin"></span> \ </span> \ </td>'); } function updateTimeValue(element, kind, id, value) { var time = moment(value); element.find('#' + id + '-value').html(time.format()); element.find('#' + id + '-livestamp').html('(' + time.fromNow() + ')'); } /// Details widget function DetailsWidget(element, specs) { var self = this; this.specs = specs; this.element = element; this.element.addClass('table'); $.each(this.specs.lines, function(i, spec) { var row = $('<tr/>'); row.append(makeTitle(specs.kind, spec.id, spec.title)); row.append(spec.valueMaker(spec.id)); self.element.append(row); }); } DetailsWidget.prototype.refresh = function updateDetails(object) { var self = this; $.each(this.specs.lines, function (i, spec) { spec.valueUpdater(self.element, self.specs.kind, spec.id, object[spec.id]); }); } /// Participant var participantDetailSpecs = { kind: 'participant', lines: [ { title: 'Scope', id: 'scope', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Kind', id: 'kind', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'State', id: 'state', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Type', id: 'type', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'ID', id: 'id', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Transports', id: 'transports', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue } ]}; /// Process var processDetailSpecs = { kind: 'process', lines: [ { title: 'Process ID', id: 'process-id', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Executing User', id: 'executing-user', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Start Time', id: 'start-time', valueMaker: makeTimeValue, valueUpdater: updateTimeValue }, { title: 'Program Name', id: 'program-name', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Commandline Arguments', id: 'commandline-arguments', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'State', id: 'state', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'RSB Version', id: 'rsb-version', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Transports', id: 'transports', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue } ] }; /// Host var hostDetailSpecs = { kind: 'host', lines: [ { title: 'ID', id: 'id', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Hostname', id: 'hostname', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Machine Type', id: 'machine-type', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Machine Version', id: 'machine-version', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Software Type', id: 'software-type', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue }, { title: 'Software Version', id: 'software-version', valueMaker: makeSimpleValue, valueUpdater: updateSimpleValue } ] };
6,263
Common Lisp
.l
199
21.60804
86
0.482627
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
669cd1da1e3ee469b1b09b2b632c68af1cfa548fe2121fedfa127b9837ebd23e
37,540
[ -1 ]
37,541
host.html
open-rsx_rsb-tools-cl/resources/introspection/host.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Web: Introspection</title> <link rel="stylesheet" type="text/css" href="base.css"/> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="https://code.cor-lab.org/projects/rsb"> <img alt="Brand" src="/images/logo.png"/> </a> </div> <div class="nav navbar-nav"> <ol id="breadcrumbs"></ol> </div> <div id="refresh" class="navbar-form navbar-right"></div> <form id="global-search" class="navbar-form navbar-right" role="search"></form> </div> </nav> </header> <main class="container-fluid"> <div id="messages"> </div> <div class="row"> <div id="col-main" class="col-md-8"> <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title">Host Details</h2></div> <div class="panel-body"> <div class="row"> <div class="col-md-6"> <table id="host-details"></table> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Processes <span id="process-count" class="badge"></span> </h2> </div> <div id="process-list" class="panel-body"></div> </div> </div> <div class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"><h3 class="panel-title">Communication Latency</h3></div> <div class="panel-body"> <div> Current estimation: <span id="latency-value"> <span class="glyphicon glyphicon-refresh glyphicon-spin"></span> </span> s </div> <div id="latency-plot" style="width: 100%; height: 100px"></div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"><h3 class="panel-title">Clock Offset</h3></div> <div class="panel-body"> <div> Current estimation: <span id="clock-offset-value"> <span class="glyphicon glyphicon-refresh glyphicon-spin"></span> </span> s </div> <div id="clock-offset-plot" style="width: 100%; height: 100px"></div> </div> </div> </div> </div> </div> </div> </div> <div id="col-graph" class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Overview </h2> </div> <div id="graph" class="panel-body"> <em>coming soonâ„¢</em> </div> </div> </div> </div> </main> <footer> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web | <a href="/hack.html">Modify this web interface</a> </footer> <script type="text/javascript" src="../lib/jquery-2.1.3/jquery.min.js"></script> <script type="text/javascript" src="../lib/bootstrap-3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript" src="../lib/flot-0.8.3/jquery.flot.min.js"></script> <script type="text/javascript" src="Introspection.js"></script> <script type="text/javascript" src="introspection.js"></script> <script type="text/javascript" src="BreadcrumbsWidget.js"></script> <script type="text/javascript" src="SearchWidget.js"></script> <script type="text/javascript" src="RefreshWidget.js"></script> <script type="text/javascript" src="DetailsWidget.js"></script> <script type="text/javascript"> var introspection = new Introspection(); var breadcrumbs = new BreadcrumbsWidget(introspection, $('#breadcrumbs'), { level: 'host' }); var search = new GlobalSearchWidget(introspection, $('#global-search')); var refreshTODO = new RefreshWidget(introspection, $('#refresh')); var details = new DetailsWidget($('#host-details'), hostDetailSpecs); var hostId; var timer; var latencyPlot, clockOffsetPlot; function setupPlots() { latencyPlot = $.plot("#latency-plot", []); clockOffsetPlot = $.plot("#clock-offset-plot", []); } function update(data, hostId) { var host = findHost(data, hostId); if (!host) return false; breadcrumbs.refresh({ 'level': 'host', 'host': host, 'hosts': data.children }); details.refresh(host); updatePlotAndValue(latencyPlot, $('#latency-value'), host['latency']); updatePlotAndValue(clockOffsetPlot, $('#clock-offset-value'), host['clock-offset']); return true; } function refresh(newHostId) { if (timer) clearTimeout(timer); hostId = newHostId || hostId || getURLParameter('hostId'); introspection.get().done(function (data) { if (update(data, hostId)) timer = setTimeout(refresh, 10000); else showMessage('Host ' + hostId + ' seems to have disappeared.'); }); function refreshBlock(query, listElement, countElement) { showRunning(listElement, countElement); introspection.search('query=' + query) .done(function(result) { showResults(listElement, countElement, null, result, { max: 20, flat: true }); }) .fail(function(message) { showError(listElement, countElement, message); }); } refreshBlock('children/host[@id="' + hostId + '"]/children/process', $('#process-list'), $('#process-count')); } $(function () { setupPlots(); refresh(); }); </script> </body> </html>
6,838
Common Lisp
.l
160
28.85
103
0.496917
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
643918afc2c62c7d309dfa8c381785d57abce20629c1e91f216ce24626158958
37,541
[ -1 ]
37,542
process.html
open-rsx_rsb-tools-cl/resources/introspection/process.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Introspection</title> <link rel="stylesheet" type="text/css" href="base.css"/> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="https://code.cor-lab.org/projects/rsb"> <img alt="Brand" src="/images/logo.png"/> </a> </div> <div class="collapse navbar-collapse"> <div class="nav navbar-nav"> <ol id="breadcrumbs"></ol> </div> <div id="refresh" class="navbar-form navbar-right"></div> <form id="global-search" class="navbar-form navbar-right" role="search"></form> </div> </div> </nav> </header> <main class="container-fluid"> <div id="messages"> </div> <div class="row"> <div id="col-main" class="col-md-8"> <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title">Process Details</h2></div> <div class="panel-body"> <div class="row"> <div class="col-md-6"> <table id="process-details"></table> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Participants <span id="participant-count" class="badge"></span> </h2> </div> <div id="participant-list" class="panel-body"></div> </div> </div> <div class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"><h3 class="panel-title">Communication Latency</h3></div> <div class="panel-body"> <div> Current estimation: <span id="latency-value"> <span class="glyphicon glyphicon-refresh glyphicon-spin"></span> </span> s </div> <div id="latency-plot" style="width: 100%; height: 100px"></div> </div> </div> </div> </div> </div> </div> </div> <div id="col-graph" class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Overview </h2> </div> <div id="graph" class="panel-body"> <em>coming soonâ„¢</em> </div> </div> </div> </div> </main> <footer> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web | <a href="/hack.html">Modify this web interface</a> </footer> <script type="text/javascript" src="../lib/jquery-2.1.3/jquery.min.js"></script> <script type="text/javascript" src="../lib/moment-2.14.1/moment.min.js"></script> <script type="text/javascript" src="../lib/bootstrap-3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript" src="../lib/flot-0.8.3/jquery.flot.min.js"></script> <script type="text/javascript" src="Introspection.js"></script> <script type="text/javascript" src="introspection.js"></script> <script type="text/javascript" src="BreadcrumbsWidget.js"></script> <script type="text/javascript" src="SearchWidget.js"></script> <script type="text/javascript" src="RefreshWidget.js"></script> <script type="text/javascript" src="DetailsWidget.js"></script> <script type="text/javascript"> var introspection = new Introspection(); var breadcrumbs = new BreadcrumbsWidget(introspection, $('#breadcrumbs'), { level: 'process' }); var search = new GlobalSearchWidget(introspection, $('#global-search')); var refreshTODO = new RefreshWidget(introspection, $('#refresh')); var details = new DetailsWidget($('#process-details'), processDetailSpecs); var hostId, processId; var latencyPlot; var timer; function setupPlot() { latencyPlot = $.plot("#latency-plot", []); } function update(data, hostId, processId) { var host = findHost(data, hostId); if (!host) return false; var process = findProcess(host, processId); if (!process) return false; breadcrumbs.refresh({ 'level': 'process', 'host': host, 'hosts': data.children, 'process': process, 'processes': host.children }); details.refresh(process); var latency = process['latency']; updatePlotAndValue(latencyPlot, $('#latency-value'), latency); return true; }; function refresh (newProcessId) { if (timer) clearTimeout(timer); hostId = hostId || getURLParameter('hostId'); processId = newProcessId || processId || getURLParameter('processId'); introspection.get().done(function (data) { if (update(data, hostId, processId)) timer = setTimeout(refresh, 10000); else showMessage('Process ' + processId + ' no longer exists.'); }); function refreshBlock(query, listElement, countElement) { showRunning(listElement, countElement); introspection.search('query=' + query) .done(function(result) { showResults(listElement, countElement, null, result, { max: 20, flat: true }); }) .fail(function(message) { showError(listElement, countElement, message); }); } refreshBlock('children/host[@id="' + hostId + '"]/children/process[@process-id="' + processId + '"]/children/participant', $('#participant-list'), $('#participant-count')); } $(function () { setupPlot(); refresh(); }); </script> </body> </html>
6,620
Common Lisp
.l
154
29.655844
132
0.510248
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f4ef647390a221498b63461c367d2a3ddb34993e4f011178477be2dcebb9309c
37,542
[ -1 ]
37,543
participant.html
open-rsx_rsb-tools-cl/resources/introspection/participant.html
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"/> <title>RSB Web: Introspection</title> <link rel="stylesheet" type="text/css" href="base.css"/> </head> <body> <header> <nav class="navbar navbar-inverse" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="https://code.cor-lab.org/projects/rsb"> <img alt="Brand" src="/images/logo.png"/> </a> </div> <div class="collapse navbar-collapse"> <div class="nav navbar-nav"> <ol id="breadcrumbs"></ol> </div> <div id="refresh" class="navbar-form navbar-right"></div> <form id="global-search" class="navbar-form navbar-right" role="search"> </div> </div> </nav> </header> <main class="container-fluid"> <div class="row"> <div id="col-main" class="col-md-8"> <div class="panel panel-default"> <div class="panel-heading"><h2 class="panel-title">Participant Details</h2></div> <div class="panel-body"> <table id="participant-details"></table> </div> </div> </div> <div id="col-graph" class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading"> <h2 class="panel-title"> Overview </h2> </div> <div id="graph" class="panel-body"> <em>coming soonâ„¢</em> </div> </div> </div> </div> </main> <footer> Generated by <a href="https://code.cor-lab.org/projects/rsb">RSB</a> web | <a href="/hack.html">Modify this web interface</a> </footer> <script type="text/javascript" src="../lib/jquery-2.1.3/jquery.min.js"></script> <script type="text/javascript" src="../lib/bootstrap-3.3.5/js/bootstrap.min.js"></script> <script type="text/javascript" src="Introspection.js"></script> <script type="text/javascript" src="introspection.js"></script> <script type="text/javascript" src="BreadcrumbsWidget.js"></script> <script type="text/javascript" src="SearchWidget.js"></script> <script type="text/javascript" src="RefreshWidget.js"></script> <script type="text/javascript" src="DetailsWidget.js"></script> <script type="text/javascript"> var introspection = new Introspection(); var breadcrumbs = new BreadcrumbsWidget(introspection, $('#breadcrumbs'), { level: 'participant' }); var search = new GlobalSearchWidget(introspection, $('#global-search')); var refreshTODO = new RefreshWidget(introspection, $('#refresh')); var details = new DetailsWidget($('#participant-details'), participantDetailSpecs); var participantId; var timer; function updateDetails(participant) { } function update(data, participantId) { var context = findParticipant(data, participantId); if (!context) return false; var participant = context.participant; context.level = 'participant'; context.hosts = data.children; context.processes = context.host.children; context.participants = context.process.children; breadcrumbs.refresh(context); details.refresh(participant); updateDetails(participant); return true; } function refresh(newParticipantId) { if (timer) clearTimeout(timer); participantId = newParticipantId || participantId || getURLParameter('participantId'); introspection.get().done(function (data) { if (update(data, participantId)) timer = setTimeout(refresh, 10000); else showMessage('Participant ' + participantId + ' no longer exists'); }); } $(function () { refresh(); }); </script> </body> </html>
4,208
Common Lisp
.l
104
30.432692
96
0.570693
open-rsx/rsb-tools-cl
0
0
4
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e599f45b8a9fc780f2544570c4bdea63d1fef55d38fa6cb60c18f859f60e25a8
37,543
[ -1 ]
37,568
send-test-events.lisp
open-rsx_rsbag-tools-cl/test/send-test-events.lisp
(defun send-test-event-and-exit () (sleep 1) (rsb:with-participant (i :informer "inprocess:") (let ((buffer (nibbles:make-octet-vector 4))) (setf (nibbles:ub32ref/le buffer 0) 1) (rsb:send i buffer :rsb.transport.wire-schema "UINT32"))) (sleep 1) (sb-ext:exit)) (let ((timer (sb-ext:make-timer #'send-test-event-and-exit :thread t))) (sb-ext:schedule-timer timer 2))
394
Common Lisp
.lisp
10
35.7
71
0.671018
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
285f7574150e2e88c27e98fea2d3cf78c27bbd0e0ee3de2b66e2f07980135691
37,568
[ -1 ]
37,569
package.lisp
open-rsx_rsbag-tools-cl/test/commands/package.lisp
;;;; package.lisp --- Package definition for unit tests of the commands module. ;;;; ;;;; Copyright (C) 2015 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.commands.test (:use #:cl #:let-plus #:more-conditions #:lift #:rsbag.tools.commands) (:export #:rsbag-tools-commands-root) (:documentation "This package contains unit tests for the commands module.")) (cl:in-package #:rsbag.tools.commands.test) (deftestsuite rsbag-tools-commands-root () () (:documentation "Root unit test suite for the commands module."))
616
Common Lisp
.lisp
21
26.380952
79
0.710884
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9e7383b8bec2917bb70a01c9e4d92801d372ce6d52fc38424d65fad1fe3d2717
37,569
[ -1 ]
37,570
play.lisp
open-rsx_rsbag-tools-cl/test/commands/play.lisp
;;;; play.lisp --- Tests for the play command class. ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands.test) (deftestsuite play-root (rsbag-tools-commands-root) () (:documentation "Test suite for the `play' command.")) (addtest (play-root :documentation "Test construction of the `play' command.") construction (ensure-cases (initargs &optional expected) `(;; Some invalid cases with missing initargs. (() missing-required-initarg) ; :input-files is missing ((:input-files ("foo.tide")) missing-required-initarg) ; :destination is missing ;; Some invalid cases with incompatible initargs. ((:input-files ("foo.tide") :destination "/" :replay-strategy ,(rsbag.rsb.replay:make-strategy :as-fast-as-possible) :replay-strategy-spec "as-fast-as-possible") incompatible-initargs) ;; These are Ok. ((:input-files ("foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible")) ((:input-files (,#P"foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible")) ((:input-files ("foo.tide") :destination ,(puri:uri "/") :replay-strategy-spec "as-fast-as-possible")) ((:input-files ("foo.tide") :destination ,(rsb:make-scope "/") :replay-strategy-spec "as-fast-as-possible")) ((:input-files ("foo.tide") :destination "/" :replay-strategy ,(rsbag.rsb.replay:make-strategy :as-fast-as-possible))) ((:input-files ("foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible" :start-index 0)) ((:input-files ("foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible" :end-index 0)) ((:input-files ("foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible" :num-repetitions 1)) ((:input-files ("foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible" :filters ,(list (rsb.filter:filter :scope :scope "/")))) ((:input-files ("foo.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible" :progress-style :none)) ((:input-files ("foo.tide" "bar.tide") :destination "/" :replay-strategy-spec "as-fast-as-possible"))) (let+ (((&flet do-it () (apply #'rsb.tools.commands:make-command :play :service 'rsbag.tools.commands::command initargs)))) (case expected (missing-required-initarg (ensure-condition missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition incompatible-initargs (do-it))) (t (ensure (typep (princ-to-string (do-it)) 'string)))))))
3,512
Common Lisp
.lisp
76
35.328947
97
0.505395
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1b6f5d25ad7e17751b5211d16f1662674a49e9d08f132807afd27ef7d6790ea1
37,570
[ -1 ]
37,571
introspect.lisp
open-rsx_rsbag-tools-cl/test/commands/introspect.lisp
;;;; introspect.lisp --- Tests for the introspect command class. ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands.test) (deftestsuite introspect-root (rsbag-tools-commands-root) () (:documentation "Test suite for the `introspect' command.")) (addtest (introspect-root :documentation "Test construction of the `introspect' command.") construction (ensure-cases (initargs &optional expected) `(;; Some invalid cases with missing initargs. (() missing-required-initarg) ; :input-files is missing ((:input-files ("foo.tide") :style ,(rsb.formatting:make-style :object-tree :service 'rsb.formatting.introspection::style) :style-spec "object-tree") incompatible-initargs) ((:input-files ("foo.tide") :style-spec "object-tree" :end-index 0 :end-time -1) incompatible-initargs) ;; These are Ok. ((:input-files ("foo.tide") :style-spec "object-tree")) ((:input-files ("foo.tide") :style-spec "object-tree" :end-index 10)) ((:input-files ("foo.tide") :style-spec "object-tree" :end-time -5.0)) ((:input-files ("foo.tide") :style-spec "object-tree :stateful? t")) ((:input-files ("foo.tide" "bar.tide") :style-spec "object-tree"))) (let+ (((&flet do-it () (apply #'rsb.tools.commands:make-command :introspect :service 'rsbag.tools.commands::command initargs)))) (case expected (missing-required-initarg (ensure-condition missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition incompatible-initargs (do-it))) (t (ensure (typep (princ-to-string (do-it)) 'string)))))))
2,341
Common Lisp
.lisp
50
35.6
106
0.498249
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5b8af0347ce727097650169cfb93126a93d44a974c02a9630de34604bc9526bc
37,571
[ -1 ]
37,572
transform.lisp
open-rsx_rsbag-tools-cl/test/commands/transform.lisp
;;;; transform.lisp --- Tests for the transform command class. ;;;; ;;;; Copyright (C) 2015, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands.test) (deftestsuite transform-root (rsbag-tools-commands-root) () (:documentation "Test suite for the `transform' command.")) (addtest (transform-root :documentation "Test construction of the `transform' command.") construction (ensure-cases (initargs &optional expected) `(;; Some invalid cases with missing initargs. (() missing-required-initarg) ; :input-files is missing ((:input-files ("foo.tide")) missing-required-initarg) ; :output-file is missing ;; Some invalid cases with incompatible initargs. ((:input-files ("foo.tide") :output-file "foo.tide" :channel-allocation ,(rsbag.rsb.recording:make-strategy :scope-and-type) :channel-allocation-spec "scope-and-type") incompatible-initargs) ;; These are Ok. ((:input-files ("foo.tide") :output-file "bar.tide")) ((:input-files (,#P"foo.tide") :output-file "bar.tide")) ((:input-files ("foo.tide") :output-file ,#P"bar.tide")) ((:input-files ("foo.tide") :output-file "bar.tide" :start-index 0)) ((:input-files ("foo.tide") :output-file "bar.tide" :end-index 0)) ((:input-files ("foo.tide" "baz.tide") :output-file "bar.tide")) ((:input-files ("foo.tide") :output-file "bar.tide" :index-timestamp nil)) ((:input-files ("foo.tide") :output-file "bar.tide" :index-timestamp :create)) ((:input-files ("foo.tide") :output-file "bar.tide" :channel-allocation ,(rsbag.rsb.recording:make-strategy :scope-and-type))) ((:input-files ("foo.tide") :output-file "bar.tide" :channel-allocation-spec "scope-and-type"))) (let+ (((&flet do-it () (apply #'rsb.tools.commands:make-command :transform :service 'rsbag.tools.commands::command initargs)))) (case expected (missing-required-initarg (ensure-condition missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition incompatible-initargs (do-it))) (t (ensure (typep (princ-to-string (do-it)) 'string)))))))
2,885
Common Lisp
.lisp
61
38.196721
97
0.514022
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e7c80de92d4a67101f7c281f32247c4837a1cf3c7c4ab9a493554914ee1dfd4e
37,572
[ -1 ]
37,573
cat.lisp
open-rsx_rsbag-tools-cl/test/commands/cat.lisp
;;;; cat.lisp --- Tests for the cat command class. ;;;; ;;;; Copyright (C) 2015, 2016, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands.test) (deftestsuite cat-root (rsbag-tools-commands-root) () (:documentation "Test suite for the `cat' command.")) (addtest (cat-root :documentation "Test construction of the `cat' command.") construction (ensure-cases (initargs &optional expected) `(;; Some invalid cases with missing initargs. (() missing-required-initarg) ; :input-files is missing ((:input-files ("foo.tide")) missing-required-initarg) ; :replay-strategy is missing ((:input-files ("foo.tide") :replay-strategy-spec "as-fast-as-possible") missing-required-initarg) ; :style[-spec] is missing ;; Some invalid cases with incompatible initargs. ((:input-files ("foo.tide") :replay-strategy ,(rsbag.rsb.replay:make-strategy :as-fast-as-possible) :replay-strategy-spec "as-fast-as-possible") incompatible-initargs) ((:input-files ("foo.tide") :replay-strategy-spec "as-fast-as-possible" :style ,(rsb.formatting:make-style :detailed) :style-spec "detailed") incompatible-initargs) ;; These are Ok. ((:input-files ("foo.tide") :replay-strategy-spec "as-fast-as-possible" :style-spec "detailed")) ((:input-files (,#P"foo.tide") :replay-strategy-spec "as-fast-as-possible" :style-spec "detailed")) ((:input-files ("foo.tide") :replay-strategy-spec "as-fast-as-possible" :style-spec "detailed" :filters ,(list (rsb.filter:filter :scope :scope "/")))) ((:input-files ("foo.tide") :replay-strategy ,(rsbag.rsb.replay:make-strategy :as-fast-as-possible) :style-spec "detailed")) ((:input-files ("foo.tide") :replay-strategy "as-fast-as-possible" :style-spec "detailed" :progress-style :line)) ((:input-files ("foo.tide" "bar.tide") :replay-strategy-spec "as-fast-as-possible" :style-spec "detailed"))) (let+ (((&flet do-it () (apply #'rsb.tools.commands:make-command :cat :service 'rsbag.tools.commands::command initargs)))) (case expected (missing-required-initarg (ensure-condition missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition incompatible-initargs (do-it))) (t (ensure (typep (princ-to-string (do-it)) 'string)))))))
3,171
Common Lisp
.lisp
64
37.75
110
0.516129
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
08159ef46d607dbca386c156e40fcbf2ca878d78699d763357898a68369fc9b7
37,573
[ -1 ]
37,574
info.lisp
open-rsx_rsbag-tools-cl/test/commands/info.lisp
;;;; info.lisp --- Tests for the info command class. ;;;; ;;;; Copyright (C) 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands.test) (deftestsuite info-root (rsbag-tools-commands-root) () (:documentation "Test suite for the `info' command.")) (addtest (info-root :documentation "Test construction of the `info' command.") construction (ensure-cases (initargs &optional expected) `(;; Some invalid cases with missing initargs. (() missing-required-initarg) ; :input-files is missing ((:input-files ("foo.tide")) missing-required-initarg) ; :style[-spec] is missing ;; Incompatible initargs. ((:input-files ("foo.tide") :style 1 :style-spec "tree") incompatible-initargs) ;; These are Ok. ((:input-files ("foo.tide") :style-spec "tree")) ((:input-files (,#P"foo.tide") :style-spec "tree")) ((:input-files ("foo.tide") :style-spec "tree" :stream ,*standard-output*)) ((:input-files ("foo.tide") :style-spec "tree" :stream-spec :error-output))) (let+ (((&flet do-it () (apply #'rsb.tools.commands:make-command :info :service 'rsbag.tools.commands::command initargs)))) (case expected (missing-required-initarg (ensure-condition missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition incompatible-initargs (do-it))) (t (ensure (typep (princ-to-string (do-it)) 'string)))))))
1,813
Common Lisp
.lisp
44
31.818182
94
0.549376
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8f4d792f6c711680a2930aee3623fd823a00464bc17e9396f743d28bc02836f9
37,574
[ -1 ]
37,575
record.lisp
open-rsx_rsbag-tools-cl/test/commands/record.lisp
;;;; record.lisp --- Tests for the record command class. ;;;; ;;;; Copyright (C) 2015, 2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.commands.test) (deftestsuite record-root (rsbag-tools-commands-root) () (:documentation "Test suite for the `record' command.")) (addtest (record-root :documentation "Test construction of the `record' command.") construction (ensure-cases (initargs &optional expected) `(;; Some invalid cases with missing initargs. (() missing-required-initarg) ; :uris is missing ((:uris ("/")) missing-required-initarg) ; :output-file is missing ;; Some invalid cases with incompatible initargs. ((:uris ("/") :output-file "foo.tide" :channel-allocation ,(rsbag.rsb.recording:make-strategy :scope-and-type) :channel-allocation-spec "scope-and-type") incompatible-initargs) ((:uris ("/") :output-file "foo.tide" :flush-strategy ,(rsbag.backend:make-flush-strategy :and) :flush-strategy-spec "and") incompatible-initargs) ;; These are Ok. ((:uris ("/") :output-file "foo.tide")) ((:uris (,(puri:uri "/")) :output-file "foo.tide")) ((:uris (,(rsb:make-scope "/")) :output-file "foo.tide")) ((:uris ("/") :output-file ,#P"foo.tide")) ((:uris ("/") :output-file "foo.tide" :index-timestamp :create)) ((:uris ("/") :output-file "foo.tide" :channel-allocation ,(rsbag.rsb.recording:make-strategy :scope-and-type))) ((:uris ("/") :output-file "foo.tide" :channel-allocation-spec "scope-and-type")) ((:uris ("/") :output-file "foo.tide" :flush-strategy ,(rsbag.backend:make-flush-strategy :and))) ((:uris ("/") :output-file "foo.tide" :flush-strategy-spec "and")) ((:uris ("/") :control-uri ,(puri:uri "/control"))) ((:uris ("/") :output-file "foo.tide" :control-uri ,(puri:uri "/control")))) (let+ (((&flet do-it () (apply #'rsb.tools.commands:make-command :record :service 'rsbag.tools.commands::command initargs)))) (case expected (missing-required-initarg (ensure-condition missing-required-initarg (do-it))) (incompatible-initargs (ensure-condition incompatible-initargs (do-it))) (t (ensure (typep (princ-to-string (do-it)) 'string)))))))
3,152
Common Lisp
.lisp
68
37.132353
89
0.475138
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f1e97e7e1068afef8e91c13f41c849581879e66ce9b9456d206a40f110897493
37,575
[ -1 ]
37,576
package.lisp
open-rsx_rsbag-tools-cl/main/package.lisp
;;;; package.lisp --- Package definition for the main bag program. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.main (:use #:cl #:alexandria #:iterate #:let-plus #:net.didierverna.clon #:rsbag #:rsb.tools.common) (:export #:main) (:export #:make-static #:make-dynamic) (:documentation "Package definition for the main bag program."))
498
Common Lisp
.lisp
21
20.47619
66
0.666667
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8416a0a86852bccf001b71e65723637af90158d288cb1f6cca0ee6373e513ee8
37,576
[ -1 ]
37,577
package.lisp
open-rsx_rsbag-tools-cl/bag-play/package.lisp
;;;; package.lisp --- Package definition for the bag-play program. ;;;; ;;;; Copyright (C) 2011, 2012, 2013, 2015, 2016 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:defpackage #:rsbag.tools.play (:shadowing-import-from #:rsbag #:direction #:meta-data #:meta-data-count #:meta-data-keys #:meta-data-values #:meta-data-plist #:meta-data-alist) (:use #:cl #:alexandria #:let-plus #:iterate #:net.didierverna.clon #:rsb #:rsb.tools.common #:rsbag #:rsbag.rsb #:rsbag.tools.common) (:export #:main) (:documentation "Package definition for the bag-play program."))
670
Common Lisp
.lisp
29
19.62069
66
0.662461
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f9b932774507e364839fc43be1af7b35a682055a263cf0c71762cbcdf6605bcd
37,577
[ -1 ]
37,578
main.lisp
open-rsx_rsbag-tools-cl/bag-play/main.lisp
;;;; main.lisp --- Main function of the bag-play program. ;;;; ;;;; Copyright (C) 2011-2017 Jan Moringen ;;;; ;;;; Author: Jan Moringen <[email protected]> (cl:in-package #:rsbag.tools.play) (defun update-synopsis (&key (show :default) (program-name "rsbag play")) "Create and return a commandline option tree." (make-synopsis :postfix "INPUT-FILE+ [BASE-URI]" :item (make-text :contents (make-help-string :show show)) :item (make-common-options :show show) :item (make-error-handling-options :show show) :item (make-replay-options :show show :show-progress-default :line :action "replay") ;; Append RSB options. :item (make-options :show? (or (eq show t) (and (listp show) (member :rsb show)))) ;; Append examples. :item (defgroup (:header "Examples") (make-text :contents (make-examples-string :program-name program-name))))) (defun make-channel-filter (specs) (when specs (apply #'disjoin (mapcar (lambda (spec) (lambda (channel) (cl-ppcre:scan spec (channel-name channel)))) specs)))) (defun parse-inputs-and-uri (arguments) (case (length arguments) (1 (values arguments "/")) (t (values (butlast arguments) (lastcar arguments))))) (defun main (program-pathname args) "Entry point function of the bag-play program." (let ((program-name (concatenate 'string (namestring program-pathname) " play")) (*readtable* (copy-readtable *readtable*))) ; TODO still necessary? (update-synopsis :program-name program-name) (setf *configuration* (options-from-default-sources)) (local-time:enable-read-macros) (process-commandline-options :commandline (list* program-name args) :version (cl-rsbag-tools-play-system:version/list :commit? t) :more-versions (list :rsbag (cl-rsbag-system:version/list :commit? t) :rsbag-tidelog (cl-rsbag-system:version/list :commit? t)) :update-synopsis (curry #'update-synopsis :program-name program-name) :return (lambda () (return-from main)))) (unless (>= (length (remainder)) 1) (error "~@<Specify one or more input files and, optionally, base URI.~@:>")) (let+ ((error-policy (maybe-relay-to-thread (process-error-handling-options))) ((&values input-files base-uri) (parse-inputs-and-uri (remainder))) (channels (let ((specs (iter (for channel next (getopt :long-name "channel")) (while channel) (collect channel)))) (or (make-channel-filter specs) t))) ((&values start-time start-index end-time end-index) (process-bounds-options)) (loop (getopt :long-name "loop")) (filters (iter (for spec next (getopt :long-name "filter")) (while spec) (collect (apply #'rsb.filter:filter (parse-instantiation-spec spec))))) (replay-strategy (getopt :long-name "replay-strategy")) (progress-style (getopt :long-name "show-progress"))) (rsb.formatting:with-print-limits (*standard-output*) (with-logged-warnings (with-error-policy (error-policy) (let ((command (rsb.tools.commands:make-command :play :service 'rsbag.tools.commands::command :input-files input-files :channels channels :start-time start-time :start-index start-index :end-time end-time :end-index end-index :num-repetitions loop :filters filters :replay-strategy-spec replay-strategy :destination base-uri :progress-style progress-style))) (with-interactive-interrupt-exit () (rsb.tools.commands:command-execute command :error-policy error-policy)) (when (eq progress-style :line) (terpri *standard-output*))))))))
4,653
Common Lisp
.lisp
95
36.221053
86
0.534183
open-rsx/rsbag-tools-cl
0
0
3
GPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f262488254e0d2b770b856a6019a43779452209c4fc49bffe3673f20dcaedb6e
37,578
[ -1 ]