Database template and basic testing

This commit is contained in:
Jay McCarthy 2010-10-19 14:51:34 -07:00
parent 52ee8af48e
commit 83bcba48a8
2 changed files with 16 additions and 10 deletions

View File

@ -16,7 +16,7 @@
#:argv argv #:argv argv
#:once-each #:once-each
[("--interval") num "Monitoring interval" (monitoring-interval (string->number num))] [("--interval") num "Monitoring interval" (monitoring-interval (string->number num))]
[("--repo") dir "Local Git repository" (repo dir)] [("--repo") dir "Local Git repository" (repo (string->path dir))]
[("--pushes") dir "Persistent queue of pushes" (push-queue dir)] [("--pushes") dir "Persistent queue of pushes" (push-queue dir)]
[("--db") spec "Specification of database" (the-db spec)]) [("--db") spec "Specification of database" (the-db spec)])
; Setup the queue to receive push information ; Setup the queue to receive push information
@ -38,9 +38,9 @@
; Add it to the queue ; Add it to the queue
(pqueue-enqueue! pushes push-info) (pqueue-enqueue! pushes push-info)
; Add it to the long term database ; Add it to the long term database
(db-set! db "push-info" new push-info) (db-set! db push-info "push-info" new)
; Update the latest push in the short term database ; Update the latest push in the short term database
(db-set! db "monitor" "last-push" new))) (db-set! db new "monitor" "last-push")))
; Wait ; Wait
(sleep (monitoring-interval)) (sleep (monitoring-interval))
(loop)) (loop))

View File

@ -1,18 +1,24 @@
#lang racket/base #lang racket/base
(require racket/match) (require racket/match
racket/contract)
(struct db ())
(define (db-connect spec) (define (db-connect spec)
#f) (db))
(define (db-ref db . path) (define (db-ref db . path)
#f) #f)
(define db-set! (define (db-set! db value . path)
(match-lambda* #f)
[(list db path ... value)
#f]))
(define (db-close! db) (define (db-close! db)
#f) #f)
(provide (all-defined-out)) (provide/contract
[db? (any/c . -> . boolean?)]
[db-connect (string? . -> . db?)]
[db-ref ((db?) () #:rest (listof string?) . ->* . any/c)]
[db-set! ((db? any/c) () #:rest (listof string?) . ->* . void)]
[db-close! (db? . -> . void)])