TinyTDS connection pool
Hi All,
My question is if there is any configuration for the TinyTDS SQL connection pool? What I mean is that I am initializing a new TinyTDS instance once in my controller (and for each future SQL query, i check if the connection is up or down, in case down, I reinitialize it). but our DBA determined that there is only 1 connection meaning 1 request at a time (and all the rest of the SQL requests are queued).
note that i'm not using the ActiveRecord standards (SQL query wise) but i wrote my queries in SQL format.
additionally i'm using Puma web-server which is multi-threaded (is that a guarantee for multiple TinyTDS connections?)
my DBlayer.rb sample code:
begin
if @@client != nil && !@@client.closed?
#puts 'DbLayer.reinitialize: TinyTds client is not nil and is not closed. Returning...'
return
else
Rails.logger.info "%s: DbLayer.reinitialize: TinyTds client is nil or closed. Reinitializing... User: %s. Host: %s" % [function_name, @@username, @@host]
@@client = TinyTds::Client.new(:username => @@username, :password => @@password, :host => @@host, :timeout => 20)
#for Windows authentication use: (:username => 'DOMAIN_NAME\Administrator', :password => 'pass', :host => 'HOST_IP', :timeout => 20)
end
if @@client.active? == true
Rails.logger.info " TinyTds client is active: "
else
Rails.logger.info " DB Conneciton troubles..."
end
'''
Thanks you all!
If you want a connection pool you have two options. First, use ActiveRecord with the SQLServerAdapter and you get one for free. Note, pools are only needed during multi-threaded applications. Likewise, same should go for Sequel too. Lastly if needed you can use an abstract connection pool gem. A quick Google search shows this project.
Please do not use github issues for discussion. That is what the Google group is for or forums like stackoverflow. Thanks.