DELETED bin/.11/lib/libpangox-1.0.so Index: bin/.11/lib/libpangox-1.0.so ================================================================== --- bin/.11/lib/libpangox-1.0.so +++ /dev/null cannot compute difference between binary files DELETED bin/.11/lib/libpangox-1.0.so.0 Index: bin/.11/lib/libpangox-1.0.so.0 ================================================================== --- bin/.11/lib/libpangox-1.0.so.0 +++ /dev/null cannot compute difference between binary files DELETED bin/.11/lib/libxcb-xlib.so.0 Index: bin/.11/lib/libxcb-xlib.so.0 ================================================================== --- bin/.11/lib/libxcb-xlib.so.0 +++ /dev/null cannot compute difference between binary files DELETED pktsmod.scm Index: pktsmod.scm ================================================================== --- pktsmod.scm +++ /dev/null @@ -1,23 +0,0 @@ -;;====================================================================== -;; Copyright 2019, Matthew Welland. -;; -;; This file is part of Megatest. -;; -;; Megatest is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; Megatest is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with Megatest. If not, see . - -;;====================================================================== - -(declare (unit pkts)) - -(include "pkts/pkts.scm") Index: servermod.scm ================================================================== --- servermod.scm +++ servermod.scm @@ -21,10 +21,11 @@ (declare (unit servermod)) (declare (uses commonmod)) (declare (uses debugprint)) (declare (uses configfmod)) (declare (uses http-transportmod)) +(declare (uses pkts)) (module servermod * (import scheme @@ -52,12 +53,91 @@ commonmod debugprint configfmod http-transportmod + pkts ) + +;;====================================================================== +;; NEW SERVER METHOD +;;====================================================================== + +(define *srvpktspec* + `((server (host . h) + (port . p) + (servkey . k) + (pid . i) + (ipaddr . a) + (dbpath . d)))) + +(define (register-server pkts-dir pkt-spec host port servkey ipaddr dbpath) + (let* ((pkt-dat `((host . ,host) + (port . ,port) + (servkey . ,servkey) + (pid . ,(current-process-id)) + (ipaddr . ,ipaddr) + (dbpath . ,dbpath)))) + (write-alist->pkt + pkts-dir + pkt-dat + pktspec: pkt-spec + ptype: 'server))) + +;; given a pkts dir read +;; +(define (get-all-server-pkts pktsdir-in pktspec) + (let* ((pktsdir (if (file-exists? pktsdir-in) + pktsdir-in + (begin + (create-directory pktsdir-in #t) + pktsdir-in))) + (all-pkt-files (glob (conc pktsdir "/*.pkt")))) + (map (lambda (pkt-file) + (read-pkt->alist pkt-file pktspec: pktspec)) + all-pkt-files))) + +(define (server-address srv-pkt) + (conc (alist-ref 'host srv-pkt) ":" + (alist-ref 'port srv-pkt))) + +(define (server-ready? server-address) + ;; ping the server and ask it + ;; if it ready + #f) + +;; from the pkts return servers associated with dbpath +;; NOTE: Only one can be alive - have to check on each +;; in the list of pkts returned +;; +(define (get-viable-servers serv-pkts dbpath) + (let loop ((tail serv-pkts) + (res '())) + (if (null? tail) + res ;; NOTE: sort by age so oldest is considered first + (let* ((spkt (car tail))) + (loop (cdr tail) + (if (equal? dbpath (alist-ref 'dbpath spkt)) + (cons spkt res) + res)))))) + +;; from viable servers get one that is alive and ready +;; +(define (get-the-server serv-pkts dbpath) + (let loop ((tail serv-pkts)) + (if (null? tail) + #f + (let* ((spkt (car tail)) + (addr (server-address spkt))) + (if (server-ready? addr) + spkt + (loop (cdr tail))))))) + +;;====================================================================== +;; END NEW SERVER METHOD +;;====================================================================== (define (server:make-server-url hostport) (if (not hostport) #f (conc "http://" (car hostport) ":" (cadr hostport))))