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:
Brian J. Cardiff 2023-05-27 22:51:38 -03:00
parent 3828e17a40
commit 0328767b98
5 changed files with 14 additions and 9 deletions

View file

@ -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

View file

@ -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