Overview
Comment: | beginnings of basic client |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.6584-ck5 |
Files: | files | file ages | folders |
SHA1: |
4ab7adb0ade32d7aeb6c6a1a12e998e5 |
User & Date: | matt on 2021-05-01 12:10:01 |
Other Links: | branch diff | manifest | tags |
Context
2021-05-02
| ||
15:41 | wip check-in: 9f8cd866ea user: matt tags: v1.6584-ck5 | |
2021-05-01
| ||
12:10 | beginnings of basic client check-in: 4ab7adb0ad user: matt tags: v1.6584-ck5 | |
2021-04-29
| ||
22:37 | basics for main.db working check-in: a80b708d01 user: matt tags: v1.6584-ck5 | |
Changes
Modified http-transportmod.scm from [c6036c9806] to [1d4bd0c79a].
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 | (defstruct servdat host port uuid dbfile ) (define (http-transport:make-server-url hostport) (if (not hostport) #f (conc "http://" (car hostport) ":" (cadr hostport)))) ;;====================================================================== ;; S E R V E R | > > > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | (defstruct servdat host port uuid dbfile ) (define (servdat->url sdat) (conc (srvdat-host sdat)":"(srvdat-port srvdat))) (define (http-transport:make-server-url hostport) (if (not hostport) #f (conc "http://" (car hostport) ":" (cadr hostport)))) ;;====================================================================== ;; S E R V E R |
︙ | ︙ | |||
288 289 290 291 292 293 294 295 296 297 298 299 300 301 | (set! *http-connections-next-cleanup* (+ (current-seconds) 10)) (mutex-unlock! *http-mutex*)) (define (http-transport:inc-requests-and-prep-to-close-all-connections) (mutex-lock! *http-mutex*) (set! *http-requests-in-progress* (+ 1 *http-requests-in-progress*))) ;; Send "cmd" with json payload "params" to serverdat and receive result ;; (define (http-transport:client-api-send-receive run-id serverdat cmd params #!key (numretries 3)(area-dat #f)) (let* ((fullurl (if (vector? serverdat) (http-transport:server-dat-get-api-req serverdat) (begin (debug:print 0 *default-log-port* "FATAL ERROR: http-transport:client-api-send-receive called with no server info") | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | (set! *http-connections-next-cleanup* (+ (current-seconds) 10)) (mutex-unlock! *http-mutex*)) (define (http-transport:inc-requests-and-prep-to-close-all-connections) (mutex-lock! *http-mutex*) (set! *http-requests-in-progress* (+ 1 *http-requests-in-progress*))) ;; serverdat contains uuid to be used for connection validation ;; ;; TODO: translate http-transport:client-connect to use servdat ;; (define (http-transport:basic-send-receive serverdat cmd params #!key (numretries 3)) (let* ((fullurl (servdat->url serverdat)) (res #f) (success #t) (server-id (servdat-uuid serverdat))) ;; 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 process and return it. (let* ((send-recieve (lambda () (set! res (vector #t ;; success (with-input-from-request fullurl (list (cons 'key server-id) (cons 'cmd cmd) (cons 'params sparams)) read))))) (time-out (lambda () (thread-sleep! 45) (debug:print 0 *default-log-port* "WARNING: send-receive took more than 45 seconds!!") #f)) (th1 (make-thread send-recieve "with-input-from-request")) (th2 (make-thread time-out "time out"))) (thread-start! th1) (thread-start! th2) (thread-join! th1) (close-idle-connections!) (thread-terminate! th2) (if (vector? res) (if (vector-ref res 0) ;; this is the first flag or the second flag? (let* ((res-dat (vector-ref res 1))) (if (and (string? res-dat) (string-contains res-dat "server-id mismatch")) (signal (make-composite-condition (make-property-condition 'servermismatch 'message (vector-ref res 1)))) res)) ;; this is the *inner* vector? seriously? why? (if (debug:debug-mode 11) (let ((call-chain (get-call-chain))) ;; note: this code also called in nmsg-transport - consider consolidating it (print-call-chain (current-error-port)) (debug:print-error 11 *default-log-port* "error above occured at server, res=" res) ;; " message: " ((condition-property-accessor 'exn 'message) exn)) (debug:print 11 *default-log-port* " server call chain:") (pp (vector-ref res 1) (current-error-port)) (signal (vector-ref res 0))) res)) (signal (make-composite-condition (make-property-condition 'timeout 'message "nmsg-transport:client-api-send-receive-raw timed out talking to server"))))))) ;; Send "cmd" with json payload "params" to serverdat and receive result ;; (define (http-transport:client-api-send-receive run-id serverdat cmd params #!key (numretries 3)(area-dat #f)) (let* ((fullurl (if (vector? serverdat) (http-transport:server-dat-get-api-req serverdat) (begin (debug:print 0 *default-log-port* "FATAL ERROR: http-transport:client-api-send-receive called with no server info") |
︙ | ︙ |