tsukasaoishi-miyazakiresistance 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/lib/miyazaki_resistance/base.rb +2 -3
- data/lib/miyazaki_resistance/tokyo_connection.rb +12 -3
- data/lib/miyazakiresistance.rb +6 -3
- metadata +3 -2
data/Manifest.txt
CHANGED
@@ -6,7 +6,7 @@ module MiyazakiResistance
|
|
6
6
|
args ||= {}
|
7
7
|
self.id = nil
|
8
8
|
args.each do |key, value|
|
9
|
-
if key.empty?
|
9
|
+
if key.is_a?(String) && key.empty?
|
10
10
|
key = :id
|
11
11
|
value = value.to_i
|
12
12
|
else
|
@@ -92,7 +92,6 @@ module MiyazakiResistance
|
|
92
92
|
query = make_order(query, args[:order])
|
93
93
|
query = make_conditions(query, args[:conditions])
|
94
94
|
|
95
|
-
now = Time.now
|
96
95
|
results = kaeru_timeout{query.searchget}.map{|r| self.new(r)}
|
97
96
|
limit.to_i == 1 ? results.first : results
|
98
97
|
rescue TimeoutError
|
@@ -131,7 +130,7 @@ module MiyazakiResistance
|
|
131
130
|
hash = {}
|
132
131
|
self.class.all_columns.each do |col, type|
|
133
132
|
value = self.__send__(col)
|
134
|
-
value = self.class.
|
133
|
+
value = self.class.plastic_data(value, type)
|
135
134
|
hash.update(col.to_s => value)
|
136
135
|
end
|
137
136
|
hash
|
@@ -18,7 +18,7 @@ module MiyazakiResistance
|
|
18
18
|
|
19
19
|
self.connection_pool ||= {:read => [], :write => nil, :standby => nil}
|
20
20
|
rdb = TokyoTyrant::RDBTBL.new
|
21
|
-
unless rdb.open(host, port)
|
21
|
+
unless rdb.open(host.to_s, port)
|
22
22
|
logger.error "TokyoTyrantConnectError host : #{host} port : #{port} target : #{target}"
|
23
23
|
raise TokyoTyrantConnectError
|
24
24
|
end
|
@@ -53,8 +53,17 @@ module MiyazakiResistance
|
|
53
53
|
|
54
54
|
def remove_pool(rdb)
|
55
55
|
self.connection_pool[:read].delete_if{|pool| pool == rdb}
|
56
|
-
|
57
|
-
|
56
|
+
|
57
|
+
host, port = rdb.host, rdb.port
|
58
|
+
new_rdb = TokyoTyrant::RDBTBL.new
|
59
|
+
if new_rdb.open(host, port)
|
60
|
+
self.connection_pool[:read] << new_rdb
|
61
|
+
self.connection_pool[:write] = new_rdb if rdb == self.connection_pool[:write]
|
62
|
+
else
|
63
|
+
check_pool
|
64
|
+
fail_over if rdb == self.connection_pool[:write]
|
65
|
+
end
|
66
|
+
rdb.close
|
58
67
|
end
|
59
68
|
|
60
69
|
def kaeru_timeout(&block)
|
data/lib/miyazakiresistance.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
-
require 'tokyotyrant'
|
5
|
-
require 'timeout'
|
6
4
|
require 'logger'
|
5
|
+
require 'timeout'
|
6
|
+
require 'tokyotyrant'
|
7
|
+
|
8
|
+
Dir.glob("#{File.join(File.dirname(__FILE__), "../initializers")}/*.rb").each{|path| require path}
|
9
|
+
|
7
10
|
require 'miyazaki_resistance/tokyo_connection'
|
8
11
|
require 'miyazaki_resistance/miyazaki_logger'
|
9
12
|
require 'miyazaki_resistance/base'
|
10
13
|
require 'miyazaki_resistance/error'
|
11
14
|
|
12
15
|
module MiyazakiResistance
|
13
|
-
VERSION = '0.0.
|
16
|
+
VERSION = '0.0.4'
|
14
17
|
end
|
15
18
|
|
16
19
|
MiyazakiResistance::Base.class_eval do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsukasaoishi-miyazakiresistance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tsukasa OISHI
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/miyazaki_resistance/error.rb
|
54
54
|
- lib/miyazaki_resistance/miyazaki_logger.rb
|
55
55
|
- lib/miyazaki_resistance/tokyo_connection.rb
|
56
|
+
- initializers/rdb.rb
|
56
57
|
has_rdoc: true
|
57
58
|
homepage: http://www.kaeruspoon.net/keywords/MiyazakiResistance
|
58
59
|
post_install_message: PostInstall.txt
|