Coverage report: /development/source/library/org/datagraph/spocq-shard/src/spocq-server/streams/start.lisp
| Kind | Covered | All | % |
| expression | 0 | 98 | 0.0 |
| branch | 0 | 2 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; -*- Mode: lisp; Syntax: ansi-common-lisp; Base: 10; Package: org.datagraph.spocq.server.implementation; -*-
2
;;; (load #p"patches/model.lisp")
4
(in-package :org.datagraph.spocq.server.implementation)
6
(defun mqtt:main (&rest args &key (init-name (or (getarg "--spocqinit") "init-mqtt")) &allow-other-keys)
7
"Provide the main entry point for an mqtt service:
8
- configure from --spocqinit
9
- initialize spocq runtime to start logs and establish connection to store
10
- run the mqtt service
12
(when (getarg "--spocqhelp") ;; --help is seen by sbcl
13
(format *trace-output* "~a :~{~% ~a~}~%" (first (spocq.i::command-line-argument-list))
14
(sort spocq.i::*getarg-options* #'string-lessp))
16
(setq spocq.i:*configuration-pathname*
17
(merge-pathnames init-name (make-pathname :directory '(:relative) :type "sxp")))
18
(handler-case (spocq.i:initialize-spocq)
20
(log-error "mqtt:main: termination due to condition: ~a" condition)
21
(spocq.i::maybe-exit-on-error)))
22
;; avoid first initialization error
23
(handler-case (make-instance 'spocq.i::query :sse-expression () :id "" :repository-id "system/system")
24
(error (c) (warn "initial instantiation error: ~a" c))
25
(:no-error (result) (format t "instantiated: ~a" result)))
26
(apply #'mqtt:run args))
28
(defun mqtt:run (&key (request-limit *mqtt-request-limit*)
29
(thread-limit *mqtt-thread-limit*)
30
(request-class nil request-class-supplied-p)
31
(response-class nil response-class-supplied-p)
32
(query-class nil query-class-supplied-p)
33
(host-name (dydra:server-host-name))
34
(host-package (or (find-package host-name)
35
(make-package host-name :use ()))))
37
"Initiate the mqtt service with a background admin process.
38
- create an acceptor with setting for the mqtt broker
39
- bind the response operators
42
(spocq.i:enable-interrupt :sigterm #'spocq.i:sigterm-handler)
43
(unless spocq.i:*start-timestamp*
44
(setq spocq.i:*start-timestamp* (iso-time)))
45
(setq spocq.i:*response-header-types* nil) ; to be sure that no prefixes are sent out
46
#+sbcl(sb-ext:gc :full t)
48
(dydra:log-info "Start MQTT ~a." (iso-time))
50
(when request-class-supplied-p
51
(setq mqtt:*class.request* request-class))
52
(when response-class-supplied-p
53
(setq mqtt:*class.response* response-class))
54
(when query-class-supplied-p
55
(setq dydra:*class.query* query-class))
58
(make-instance 'mqtt:acceptor
59
:port mqtt:*port* ;; for active connections rather than accepting
61
:name (format nil "~a@~a" "dydra" (spocq.i::host-name))
62
:broker-url mqtt:*broker-url*
65
:request-class request-class
66
:response-class response-class
67
:thread-limit thread-limit
68
:request-limit request-limit
70
(import '(spocq.si::GRAPH-STORE-RESPONSE ;; support sparql
71
spocq.si::ldf-response ;; support ldf+rsp
73
(with-package-iterator (next host-package :internal)
74
(loop (multiple-value-bind (symbol-p symbol) (next)
75
(unless symbol-p (return))
76
(export symbol host-package))))
78
(setf (http:acceptor-dispatch-function mqtt:*acceptor*) host-package)
80
(dydra:log-info "accepting mqtt on ~a @ ~a." mqtt:*port* mqtt:*broker-url*)
81
(http:start mqtt:*acceptor*))