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
#:once-each
[("--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)]
[("--db") spec "Specification of database" (the-db spec)])
; Setup the queue to receive push information
@ -38,9 +38,9 @@
; Add it to the queue
(pqueue-enqueue! pushes push-info)
; 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
(db-set! db "monitor" "last-push" new)))
(db-set! db new "monitor" "last-push")))
; Wait
(sleep (monitoring-interval))
(loop))

View File

@ -1,18 +1,24 @@
#lang racket/base
(require racket/match)
(require racket/match
racket/contract)
(struct db ())
(define (db-connect spec)
#f)
(db))
(define (db-ref db . path)
#f)
(define db-set!
(match-lambda*
[(list db path ... value)
#f]))
(define (db-set! db value . path)
#f)
(define (db-close! db)
#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)])