mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Introduce DB::ConnectionContext (#44)
* make Database a ConnectionContext. * introduce SingleConnectionContext for independant connections. * add `DB#connect` to create non pooled connections.
This commit is contained in:
parent
c63ea48748
commit
385cf70a8a
8 changed files with 115 additions and 23 deletions
|
@ -2,13 +2,13 @@ require "spec"
|
|||
require "../src/db"
|
||||
|
||||
class DummyDriver < DB::Driver
|
||||
def build_connection(db : DB::Database) : DB::Connection
|
||||
DummyConnection.new(db)
|
||||
def build_connection(context : DB::ConnectionContext) : DB::Connection
|
||||
DummyConnection.new(context)
|
||||
end
|
||||
|
||||
class DummyConnection < DB::Connection
|
||||
def initialize(db)
|
||||
super(db)
|
||||
def initialize(context)
|
||||
super(context)
|
||||
@connected = true
|
||||
@@connections ||= [] of DummyConnection
|
||||
@@connections.not_nil! << self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue