aboutsummaryrefslogtreecommitdiff
#lang typed/racket

(provide current-connection
         get-connection
         set-connection!
         connect)

(require typed/db)

(: current-connection (Parameterof (Option Connection)))
(define current-connection (make-parameter #f))

(define (get-connection)
  (cond
    [(current-connection) => identity]
    [else (error "set-connection! でコネクションを設定してください")]))

(: set-connection! (-> Connection Void))
(define (set-connection! c)
  (current-connection c))

(module untyped racket
  (provide (rename-out [postgresql-connect connect]))
  (require db))

(require/typed/provide (submod "." untyped)
  [connect (->* (#:user String #:database String)
                (#:server (Option String)
                 #:port Exact-Positive-Integer
                 #:socket (U 'guess Path-String False)
                 #:password (U String (List 'hash String) False)
                 #:allow-cleartext-password? (U 'local Boolean))
                Connection)])