Skip to content

Commit 74219af

Browse files
committed
Make auto reconnect duration configurable. Fixes #109 [David Chelimsky]
1 parent 4acafd5 commit 74219af

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
* 3.1.0 *
33

4+
* Make auto reconnect duration configurable. Fixes #109 [David Chelimsky]
5+
46
* Quote most time objects to use ISO8601 format to be multi-language dateformat compatible. The [datetime] data type is
57
automatically limited to milliseconds while [time] & [datetimeoffset] have full support. Even included a Date/Time
68
ActiveSupport formatter that is used per the language settings of the connection.

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class SQLServerAdapter < AbstractAdapter
167167

168168
cattr_accessor :native_text_database_type, :native_binary_database_type, :native_string_database_type,
169169
:log_info_schema_queries, :enable_default_unicode_types, :auto_connect,
170-
:cs_equality_operator, :lowercase_schema_reflection
170+
:cs_equality_operator, :lowercase_schema_reflection, :auto_connect_duration
171171

172172
self.enable_default_unicode_types = true
173173

@@ -310,6 +310,10 @@ def auto_connect
310310
@@auto_connect.is_a?(FalseClass) ? false : true
311311
end
312312

313+
def auto_connect_duration
314+
@@auto_connect_duration ||= 10
315+
end
316+
313317
def native_string_database_type
314318
@@native_string_database_type || (enable_default_unicode_types ? 'nvarchar' : 'varchar')
315319
end
@@ -443,7 +447,7 @@ def auto_reconnected?
443447
return false unless auto_connect
444448
@auto_connecting = true
445449
count = 0
446-
while count <= 5
450+
while count <= (auto_connect_duration / 2)
447451
sleep 2** count
448452
ActiveRecord::Base.did_retry_sqlserver_connection(self,count)
449453
return true if reconnect!

0 commit comments

Comments
 (0)