lib/sequel/extensions/arbitrary_servers.rb in sequel-4.49.0 vs lib/sequel/extensions/arbitrary_servers.rb in sequel-5.0.0

- old
+ new

@@ -7,48 +7,48 @@ # DB.extension :arbitrary_servers # # Then you can pass arbitrary connection options for the server/shard # to use as a hash: # -# DB[:table].server(:host=>'...', :database=>'...').all +# DB[:table].server(host: '...', database: '...').all # # Because Sequel can never be sure that the connection will be reused, # arbitrary connections are disconnected as soon as the outermost block # that uses them exits. So this example uses the same connection: # -# DB.transaction(:server=>{:host=>'...', :database=>'...'}) do |c| -# DB.transaction(:server=>{:host=>'...', :database=>'...'}) do |c2| +# DB.transaction(server: {host: '...', database: '...'}) do |c| +# DB.transaction(server: {host: '...', database: '...'}) do |c2| # # c == c2 # end # end # # But this example does not: # -# DB.transaction(:server=>{:host=>'...', :database=>'...'}) do |c| +# DB.transaction(server: {host: '...', database: '...'}) do |c| # end -# DB.transaction(:server=>{:host=>'...', :database=>'...'}) do |c2| +# DB.transaction(server: {host: '...', database: '...'}) do |c2| # # c != c2 # end # # You can use this extension in conjunction with the server_block # extension: # -# DB.with_server(:host=>'...', :database=>'...') do +# DB.with_server(host: '...', database: '...') do # DB.synchronize do # # All of these use the host/database given to with_server -# DB[:table].insert(:c=>1) -# DB[:table].update(:c=>2) +# DB[:table].insert(c: 1) +# DB[:table].update(c: 2) # DB.tables # DB[:table].all # end # end # # Anyone using this extension in conjunction with the server_block # extension may want to do the following to so that you don't need # to call synchronize separately: # -# def DB.with_server(*) -# super{synchronize{yield}} +# def DB.with_server(*a) +# super(*a){synchronize{yield}} # end # # Note that this extension only works with the sharded threaded connection # pool. If you are using the sharded single connection pool, you need # to switch to the sharded threaded connection pool before using this