mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Delegate options parsing to driver
DRY parsing connection options for database
This commit is contained in:
parent
bc0200e178
commit
36f0a11d07
4 changed files with 13 additions and 6 deletions
|
@ -49,7 +49,7 @@ class FooDriver < DB::Driver
|
|||
|
||||
def connection_builder(uri : URI) : Proc(DB::Connection)
|
||||
params = HTTP::Params.parse(uri.query || "")
|
||||
options = DB::Connection::Options.from_http_params(params)
|
||||
options = connection_options(params)
|
||||
->{ FooConnection.new(options).as(DB::Connection) }
|
||||
end
|
||||
|
||||
|
@ -114,7 +114,7 @@ class BarDriver < DB::Driver
|
|||
|
||||
def connection_builder(uri : URI) : Proc(DB::Connection)
|
||||
params = HTTP::Params.parse(uri.query || "")
|
||||
options = DB::Connection::Options.from_http_params(params)
|
||||
options = connection_options(params)
|
||||
->{ BarConnection.new(options).as(DB::Connection) }
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ require "../src/db"
|
|||
class DummyDriver < DB::Driver
|
||||
def connection_builder(uri : URI) : Proc(DB::Connection)
|
||||
params = HTTP::Params.parse(uri.query || "")
|
||||
options = DB::Connection::Options.from_http_params(params)
|
||||
options = connection_options(params)
|
||||
->{ DummyConnection.new(options).as(DB::Connection) }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue