13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
(declare (uses rmt))
(declare (uses db))
;; These are called by the server on recipt of /api calls
(define (api:execute-requests dbstruct cmd params)
(case (string->symbol cmd)
;; KEYS
((get-key-val-pairs) (apply db:get-key-val-pairs dbstruct params))
((get-keys) (db:get-keys dbstruct))
;; TESTS
;; json doesn't do vectors, convert to list
((get-test-info-by-id) (apply db:get-test-info-by-id dbstruct params))
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
(declare (uses rmt))
(declare (uses db))
;; These are called by the server on recipt of /api calls
(define (api:execute-requests dbstruct cmd params)
(case (string->symbol cmd)
;; SERVERS
((start-server) (apply server:kind-run params))
;; ((kill-server)
;; (db:sync-tables (db:tbls *inmemdb*) *inmemdb* *db*) ;; (db:sync-to *inmemdb* *db*)
;; (let ((hostname (car *runremote*))
;; (port (cadr *runremote*))
;; (pid (if (null? params) #f (car params)))
;; (th1 (make-thread (lambda ()(thread-sleep! 3)(debug:print 0 "Server exiting!")(exit 0)) "Server exit thread")))
;; (debug:print 0 "WARNING: Server on " hostname ":" port " going down by user request!")
;; (debug:print-info 1 "current pid=" (current-process-id))
;; (open-run-close tasks:server-deregister tasks:open-db
;; hostname
;; port: port)
;; (set! *server-run* #f)
;; (thread-sleep! 3)
;; (if pid
;; (process-signal pid signal/kill)
;; (thread-start! th1))
;; '(#t "exit process started")))
;; KEYS
((get-key-val-pairs) (apply db:get-key-val-pairs dbstruct params))
((get-keys) (db:get-keys dbstruct))
;; TESTS
;; json doesn't do vectors, convert to list
((get-test-info-by-id) (apply db:get-test-info-by-id dbstruct params))
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
((general-call) (let ((stmtname (car params))
(run-id (cadr params))
(realparams (cddr params)))
(db:with-db dbstruct run-id #t ;; these are all for modifying the db
(lambda (db)
(db:general-call db stmtname realparams)))))
((sync-inmem->db) (db:sync-touched dbstruct run-id force-sync: #t))
;; ((kill-server)
;; (db:sync-tables (db:tbls *inmemdb*) *inmemdb* *db*) ;; (db:sync-to *inmemdb* *db*)
;; (let ((hostname (car *runremote*))
;; (port (cadr *runremote*))
;; (pid (if (null? params) #f (car params)))
;; (th1 (make-thread (lambda ()(thread-sleep! 3)(debug:print 0 "Server exiting!")(exit 0)) "Server exit thread")))
;; (debug:print 0 "WARNING: Server on " hostname ":" port " going down by user request!")
;; (debug:print-info 1 "current pid=" (current-process-id))
;; (open-run-close tasks:server-deregister tasks:open-db
;; hostname
;; port: port)
;; (set! *server-run* #f)
;; (thread-sleep! 3)
;; (if pid
;; (process-signal pid signal/kill)
;; (thread-start! th1))
;; '(#t "exit process started")))
((sdb-qry) (apply sdb:qry params))
;; TESTMETA
((testmeta-get-record) (apply db:testmeta-get-record dbstruct params))
((testmeta-add-record) (apply db:testmeta-add-record dbstruct params))
((testmeta-update-field) (apply db:testmeta-update-field dbstruct params))
(else
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
((general-call) (let ((stmtname (car params))
(run-id (cadr params))
(realparams (cddr params)))
(db:with-db dbstruct run-id #t ;; these are all for modifying the db
(lambda (db)
(db:general-call db stmtname realparams)))))
((sync-inmem->db) (db:sync-touched dbstruct run-id force-sync: #t))
((sdb-qry) (apply sdb:qry params))
;; TESTMETA
((testmeta-get-record) (apply db:testmeta-get-record dbstruct params))
((testmeta-add-record) (apply db:testmeta-add-record dbstruct params))
((testmeta-update-field) (apply db:testmeta-update-field dbstruct params))
(else
|