247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
-
+
|
(assert (remote? runremote) "FATAL: http-transport:client-api-send-receive called with serverdat="serverdat)
(let* ((fullurl (remote-api-req runremote))
(res (vector #f "uninitialized"))
(success #t)
(sparams (db:obj->string params transport: 'http))
(server-id (remote-server-id runremote)))
(debug:print-info 11 *default-log-port* "cmd=" cmd " fullurl=" fullurl " server-id=" server-id " current time:" (current-seconds))
(assert fullurl "FATAL: http-transposrt:client-api-send-receive remote-api-req not set")
;; set up the http-client here
(max-retry-attempts 1)
;; consider all requests indempotent
(retry-request? (lambda (request)
#f))
;; send the data and get the response
;; extract the needed info from the http data and
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
-
+
-
+
+
-
-
-
-
+
+
+
+
+
|
(if (remote? runremote)
(let ((api-dat (remote-api-uri runremote)))
(handle-exceptions
exn
(begin
(print-call-chain *default-log-port*)
(debug:print-error 0 *default-log-port* " closing connection failed with error: " ((condition-property-accessor 'exn 'message) exn) ", exn=" exn))
(if (and (args:any-defined? "-server" "-execute" "-run")
(if (not (args:get-arg "-server"))
api-dat)
(begin ;; NOTE: Verify this actually ever gets hit. Jan 16, 2023.
(if api-dat
(begin
(debug:print-info 0 *default-log-port* "Closing connections to "api-dat)
(close-connection! api-dat)))
(remote-conndat-set! runremote #f)
#t))
(debug:print-info 0 *default-log-port* "Closing connections to "api-dat)
(close-connection! api-dat)))
(remote-api-req-set! runremote #f) ;; use api-req as a flag for a working connection
#t)
#f)))
#f))
;; run http-transport:keep-running in a parallel thread to monitor that the db is being
;; used and to shutdown after sometime if it is not.
;;
(define (http-transport:keep-running)
;; if none running or if > 20 seconds since
|