56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
srfi-1
srfi-13
srfi-18
srfi-69
commonmod
apimod
itemsmod
debugprint
mtver
regex
tasksmod
pgdb
(prefix mtargs args:)
dbmod
|
>
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
srfi-1
srfi-13
srfi-18
srfi-69
commonmod
apimod
itemsmod
http-client
debugprint
mtver
regex
tasksmod
pgdb
(prefix mtargs args:)
dbmod
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
;; Defaults to
;;
(define (rmt:send-receive cmd rid params #!key (attemptnum 1)(area-dat #f))
(if (not *rmt:remote*)(set! *rmt:remote* (make-rmt:remote)))
(let* ((apath *toppath*)
(conns *rmt:remote*)
(dbname (db:run-id->dbname rid)))
(rmt:send-receive-real conns apath dbname rid params)))
;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed
;; sometime in the future
;;
(define (rmt:send-receive-real remote apath dbname rid params)
(let* ((conn (rmt:get-connection remote apath dbname)))
(assert conn "FATAL: Unable to connect to db "apath"/"dbname)
#t ;; here we do the actual connection work
))
(define (rmt:print-db-stats)
(let ((fmtstr "~40a~7-d~9-d~20,2-f")) ;; "~20,2-f"
(debug:print 18 *default-log-port* "DB Stats\n========")
(debug:print 18 *default-log-port* (format #f "~40a~8a~10a~10a" "Cmd" "Count" "TotTime" "Avg"))
(for-each (lambda (cmd)
(let ((cmd-dat (hash-table-ref *db-stats* cmd)))
(debug:print 18 *default-log-port* (format #f fmtstr cmd (vector-ref cmd-dat 0) (vector-ref cmd-dat 1) (/ (vector-ref cmd-dat 1)(vector-ref cmd-dat 0))))))
|
|
|
>
|
>
>
>
>
>
>
|
>
|
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
;; Defaults to
;;
(define (rmt:send-receive cmd rid params #!key (attemptnum 1)(area-dat #f))
(if (not *rmt:remote*)(set! *rmt:remote* (make-rmt:remote)))
(let* ((apath *toppath*)
(conns *rmt:remote*)
(dbname (db:run-id->dbname rid)))
(rmt:send-receive-real conns apath dbname rid cmd params)))
;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed
;; sometime in the future
;;
(define (rmt:send-receive-real remote apath dbname rid cmd params)
(let* ((conn (rmt:get-connection remote apath dbname)))
(assert conn "FATAL: Unable to connect to db "apath"/"dbname)
(let* ((host (rmt:conn-ipaddr conn))
(port (rmt:conn-port conn))
(payload (sexpr->string params))
(res (with-input-from-request
(conc "http://"host":"port"/api")
`((params . ,payload)
(cmd . ,cmd)
(key . "nokey")
read-string))))
(string->sexpr res))))
(define (rmt:print-db-stats)
(let ((fmtstr "~40a~7-d~9-d~20,2-f")) ;; "~20,2-f"
(debug:print 18 *default-log-port* "DB Stats\n========")
(debug:print 18 *default-log-port* (format #f "~40a~8a~10a~10a" "Cmd" "Count" "TotTime" "Avg"))
(for-each (lambda (cmd)
(let ((cmd-dat (hash-table-ref *db-stats* cmd)))
(debug:print 18 *default-log-port* (format #f fmtstr cmd (vector-ref cmd-dat 0) (vector-ref cmd-dat 1) (/ (vector-ref cmd-dat 1)(vector-ref cmd-dat 0))))))
|