From 83bcba48a89a513caa805abce10baf5ec238db6c Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 19 Oct 2010 14:51:34 -0700 Subject: [PATCH] Database template and basic testing --- collects/meta/drdr2/git-monitor/monitor.rkt | 6 +++--- collects/meta/drdr2/lib/db.rkt | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/collects/meta/drdr2/git-monitor/monitor.rkt b/collects/meta/drdr2/git-monitor/monitor.rkt index a493612ee3..75419b1e0a 100644 --- a/collects/meta/drdr2/git-monitor/monitor.rkt +++ b/collects/meta/drdr2/git-monitor/monitor.rkt @@ -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)) diff --git a/collects/meta/drdr2/lib/db.rkt b/collects/meta/drdr2/lib/db.rkt index d5892ebc4b..fd69a37b81 100644 --- a/collects/meta/drdr2/lib/db.rkt +++ b/collects/meta/drdr2/lib/db.rkt @@ -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)) \ No newline at end of file +(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)]) \ No newline at end of file