221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
(ok-res . #t)))
(vector #f res))
(begin
#;(common:telemetry-log (conc "api-out:"(->string cmd))
payload: `((params . ,params)
(ok-res . #f)))
(vector #t res))))))))
(define (api:dispatch-request dbstruct cmd run-id params)
(case cmd
;;===============================================
;; READ/WRITE QUERIES
;;===============================================
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
(ok-res . #t)))
(vector #f res))
(begin
#;(common:telemetry-log (conc "api-out:"(->string cmd))
payload: `((params . ,params)
(ok-res . #f)))
(vector #t res))))))))
;; indat is (cmd run-id params meta)
(define (api:tcp-dispatch-request dbstruct indat) ;; cmd run-id params)
(set! *api-process-request-count* (+ *api-process-request-count* 1))
(match (deserialize indat)
((cmd run-id params meta)
(let* ((status (cond
((> *api-process-request-count* 50) 'busy)
((> *api-process-request-count* 25) 'loaded)
(else 'ok)))
(errmsg (case status
((busy) (conc "Server overloaded, "*api-process-request-count*" threads in flight"))
((loaded) (conc "Server loaded, "*api-process-request-count*" threads in flight"))
(else #f)))
(result (case status
((busy) #f)
(else (api:dispatch-request dbstruct cmd run-id params))))
(payload (list status errmsg result '()))
(pdat (serialize payload)))
(set! *api-process-request-count* (- *api-process-request-count* 1))
pdat))
(else
(let* ((msg (conc "(deserialize indat)="(deserialize indat)", indat="indat)))
(assert #f "FATAL: failed to deserialize indat "msg)))))
(define (api:dispatch-request dbstruct cmd run-id params)
(case cmd
;;===============================================
;; READ/WRITE QUERIES
;;===============================================
|