diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1c15c7c..16ebf04 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,6 +2,11 @@ = rufus-tokyo CHANGELOG.txt +== rufus-tokyo - 1.0.4 not yet released + +- todo : Rufus::Tokyo::Tyrant and TyrantTable now reconnets (120 seconds) + + == rufus-tokyo - 1.0.3 released 2009/11/16 - bug : newer versions of FFI have [undocumented] bool type. Adapted. diff --git a/lib/rufus/tokyo/tyrant/abstract.rb b/lib/rufus/tokyo/tyrant/abstract.rb index ecfcd06..c135fa5 100644 --- a/lib/rufus/tokyo/tyrant/abstract.rb +++ b/lib/rufus/tokyo/tyrant/abstract.rb @@ -114,6 +114,14 @@ def initialize (host, port=0, params={}) self.default = params[:default] @default_proc ||= params[:default_proc] + + # + # timeout and reconnect + + # defaults to two minutes + + timeout = params[:timeout] || 120.0 + lib.tcrdbtune(@db, timeout, 1) end # Using the tyrant lib diff --git a/lib/rufus/tokyo/tyrant/lib.rb b/lib/rufus/tokyo/tyrant/lib.rb index efc5821..751b259 100644 --- a/lib/rufus/tokyo/tyrant/lib.rb +++ b/lib/rufus/tokyo/tyrant/lib.rb @@ -63,6 +63,8 @@ class << self attfunc :tcrdbstat, [ :pointer ], :string + attfunc :tcrdbtune, [ :pointer, :double, :int ], :bool + attfunc :tcrdbopen, [ :pointer, :string, :int ], :bool attfunc :abs_close, :tcrdbclose, [ :pointer ], :bool diff --git a/lib/rufus/tokyo/tyrant/table.rb b/lib/rufus/tokyo/tyrant/table.rb index ff88739..f5db02f 100644 --- a/lib/rufus/tokyo/tyrant/table.rb +++ b/lib/rufus/tokyo/tyrant/table.rb @@ -75,7 +75,7 @@ class TyrantTable < Table # t['client0'] = { 'name' => 'Theodore Roosevelt', 'country' => 'usa' } # t.close # - def initialize (host, port=0) + def initialize (host, port=0, params={}) @db = lib.tcrdbnew @@ -95,6 +95,14 @@ def initialize (host, port=0) end @default_proc = nil + + # + # timeout and reconnect + + # defaults to two minutes + + timeout = params[:timeout] || 120.0 + lib.tcrdbtune(@db, timeout, 1) end #