mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Migrate to simpler/decoupled factory in driver
This allows more freedom on how the connection is created. It will no longer need to have an explicit reference to the connection URI
This commit is contained in:
parent
3828e17a40
commit
0328767b98
5 changed files with 14 additions and 9 deletions
|
@ -47,8 +47,8 @@ class FooDriver < DB::Driver
|
|||
@@row
|
||||
end
|
||||
|
||||
def build_connection(context : DB::ConnectionContext) : DB::Connection
|
||||
FooConnection.new
|
||||
def connection_builder(uri : URI) : Proc(DB::Connection)
|
||||
-> { FooConnection.new.as(DB::Connection) }
|
||||
end
|
||||
|
||||
class FooConnection < DB::Connection
|
||||
|
@ -110,8 +110,8 @@ class BarDriver < DB::Driver
|
|||
@@row
|
||||
end
|
||||
|
||||
def build_connection(context : DB::ConnectionContext) : DB::Connection
|
||||
BarConnection.new
|
||||
def connection_builder(uri : URI) : Proc(DB::Connection)
|
||||
-> { BarConnection.new.as(DB::Connection) }
|
||||
end
|
||||
|
||||
class BarConnection < DB::Connection
|
||||
|
|
|
@ -2,8 +2,8 @@ require "spec"
|
|||
require "../src/db"
|
||||
|
||||
class DummyDriver < DB::Driver
|
||||
def build_connection(context : DB::ConnectionContext) : DB::Connection
|
||||
DummyConnection.new
|
||||
def connection_builder(uri : URI) : Proc(DB::Connection)
|
||||
-> { DummyConnection.new.as(DB::Connection) }
|
||||
end
|
||||
|
||||
class DummyConnection < DB::Connection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue