tarantool 0.4.3.3 → 0.4.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/tarantool.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'eventmachine'
2
1
  require "iproto"
3
2
  require "tarantool/version"
4
3
  require "tarantool/exceptions"
@@ -33,7 +32,7 @@ module Tarantool
33
32
  if %w{round_robin master_first}.include?(replica_strategy)
34
33
  replica_strategy = replica_strategy.to_sym
35
34
  end
36
- unless [:round_robin, :master_first].include?(replica_strategy)
35
+ unless [:round_robin, :master_first, :prefer_slave].include?(replica_strategy)
37
36
  raise ArgumentError, "Shard strategy could be :round_robin or :master_first, got #{replica_strategy.inspect}"
38
37
  end
39
38
 
@@ -23,7 +23,12 @@ module Tarantool
23
23
  if (replicas = _shard(shard_number)).size == 1
24
24
  _parse_iproto(replicas[0].send_request(response.request_type, response.body))
25
25
  elsif read_write == :read
26
- replicas = replicas.shuffle if @replica_strategy == :round_robin
26
+ case @replica_strategy
27
+ when :round_robin
28
+ replicas = replicas.shuffle
29
+ when :prefer_slave
30
+ replicas = replicas[1..-1].shuffle << replicas[0]
31
+ end
27
32
  _one_shard_read(replicas, response.request_type, response.body)
28
33
  else
29
34
  _one_shard_write(replicas, response.request_type, response.body)
@@ -1,3 +1,4 @@
1
+ require 'eventmachine'
1
2
  module Tarantool
2
3
  class EMDB < DB
3
4
  IPROTO_CONNECTION_TYPE = :em_callback
@@ -42,7 +43,12 @@ module Tarantool
42
43
  if (replicas = _shard(shard_number)).size == 1
43
44
  replicas[0].send_request(response.request_type, response.body, OneReplica.new(response, feed))
44
45
  elsif read_write == :read
45
- replicas = replicas.shuffle if @replica_strategy == :round_robin
46
+ case @replica_strategy
47
+ when :round_robin
48
+ replicas = replicas.shuffle
49
+ when :prefer_slave
50
+ replicas = replicas[1..-1].shuffle << replicas[0]
51
+ end
46
52
  EM.next_tick OneShardRead.new(replicas, response, feed)
47
53
  else
48
54
  EM.next_tick OneShardWrite.new(replicas, response, feed)
@@ -1,4 +1,4 @@
1
1
  module Tarantool
2
- VERSION = "0.4.3.3"
2
+ VERSION = "0.4.3.5"
3
3
  RECORD_VERSION = "0.4.2"
4
4
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarantool
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.4.3.5
4
5
  prerelease:
5
- version: 0.4.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Rudenko
@@ -10,71 +10,71 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-29 00:00:00.000000000 Z
13
+ date: 2013-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  type: :runtime
17
17
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
18
  requirements:
20
19
  - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
21
  version: 0.3.8
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
22
  none: false
23
+ version_requirements: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - ! '>='
28
26
  - !ruby/object:Gem::Version
29
27
  version: 0.3.8
28
+ none: false
29
+ prerelease: false
30
30
  name: iproto
31
31
  - !ruby/object:Gem::Dependency
32
32
  type: :runtime
33
33
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
34
  requirements:
36
35
  - - ! '>='
37
36
  - !ruby/object:Gem::Version
38
37
  version: 0.1.1
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
38
  none: false
39
+ version_requirements: !ruby/object:Gem::Requirement
42
40
  requirements:
43
41
  - - ! '>='
44
42
  - !ruby/object:Gem::Version
45
43
  version: 0.1.1
44
+ none: false
45
+ prerelease: false
46
46
  name: murmurhash3
47
47
  - !ruby/object:Gem::Dependency
48
48
  type: :runtime
49
49
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
50
  requirements:
52
51
  - - ! '>='
53
52
  - !ruby/object:Gem::Version
54
53
  version: 0.0.2
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
54
  none: false
55
+ version_requirements: !ruby/object:Gem::Requirement
58
56
  requirements:
59
57
  - - ! '>='
60
58
  - !ruby/object:Gem::Version
61
59
  version: 0.0.2
60
+ none: false
61
+ prerelease: false
62
62
  name: sumbur
63
63
  - !ruby/object:Gem::Dependency
64
64
  type: :runtime
65
65
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
66
  requirements:
68
- - - ! '>='
67
+ - - ~>
69
68
  - !ruby/object:Gem::Version
70
69
  version: 0.0.3
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
70
  none: false
71
+ version_requirements: !ruby/object:Gem::Requirement
74
72
  requirements:
75
- - - ! '>='
73
+ - - ~>
76
74
  - !ruby/object:Gem::Version
77
75
  version: 0.0.3
76
+ none: false
77
+ prerelease: false
78
78
  name: bin_utils
79
79
  description: Tarantool KV-storage client.
80
80
  email:
@@ -86,53 +86,52 @@ extra_rdoc_files:
86
86
  - README.md
87
87
  - LICENSE
88
88
  files:
89
- - lib/tarantool/request.rb
89
+ - lib/tarantool/block_db.rb
90
+ - lib/tarantool/space_array.rb
90
91
  - lib/tarantool/em_db.rb
91
- - lib/tarantool/record/select.rb
92
- - lib/tarantool/response.rb
93
- - lib/tarantool/base_record.rb
94
- - lib/tarantool/util.rb
95
- - lib/tarantool/light_record.rb
96
- - lib/tarantool/version.rb
92
+ - lib/tarantool/query.rb
97
93
  - lib/tarantool/shards_support.rb
98
- - lib/tarantool/core-ext.rb
99
94
  - lib/tarantool/serializers/ber_array.rb
100
95
  - lib/tarantool/serializers/bson.rb
101
- - lib/tarantool/version.rb.orig
102
- - lib/tarantool/callback_db.rb
103
- - lib/tarantool/exceptions.rb
96
+ - lib/tarantool/version.rb
104
97
  - lib/tarantool/space_hash.rb
98
+ - lib/tarantool/request.rb
105
99
  - lib/tarantool/fiber_db.rb
106
- - lib/tarantool/query.rb
107
- - lib/tarantool/block_db.rb
108
100
  - lib/tarantool/serializers.rb
109
- - lib/tarantool/space_array.rb
101
+ - lib/tarantool/callback_db.rb
102
+ - lib/tarantool/exceptions.rb
103
+ - lib/tarantool/light_record.rb
104
+ - lib/tarantool/record/select.rb
105
+ - lib/tarantool/util.rb
106
+ - lib/tarantool/core-ext.rb
107
+ - lib/tarantool/base_record.rb
108
+ - lib/tarantool/response.rb
110
109
  - lib/tarantool.rb
111
- - test/test_light_record.rb
112
- - test/shared_record.rb
113
- - test/shared_replicated_shard.rb
114
- - test/shared_space_array.rb
115
- - test/test_shard_replication_fiber.rb
116
- - test/test_space_hash_block.rb
117
- - test/test_space_hash_fiber.rb
110
+ - test/shared_query.rb
118
111
  - test/test_reshard_block.rb
119
- - test/tarantool.cfg
120
- - test/helper.rb
121
- - test/test_query_fiber.rb
122
- - test/test_space_array_callback_nodef.rb
123
- - test/tarantool1.cfg
124
- - test/init.lua
125
- - test/run_all.rb
126
112
  - test/test_space_array_callback.rb
127
- - test/test_space_array_fiber.rb
128
113
  - test/test_reshard_fiber.rb
129
- - test/test_query_block.rb
130
- - test/tarantool.log
114
+ - test/tarantool1.cfg
115
+ - test/test_space_array_callback_nodef.rb
116
+ - test/test_shard_replication_fiber.rb
117
+ - test/run_all.rb
131
118
  - test/shared_reshard.rb
132
- - test/shared_query.rb
119
+ - test/init.lua
120
+ - test/helper.rb
133
121
  - test/test_shard_replication_block.rb
122
+ - test/tarantool.log
123
+ - test/tarantool.cfg
124
+ - test/shared_space_array.rb
125
+ - test/test_query_fiber.rb
126
+ - test/test_light_record.rb
127
+ - test/shared_record.rb
128
+ - test/test_space_hash_fiber.rb
129
+ - test/test_query_block.rb
134
130
  - test/test_space_array_block.rb
135
131
  - test/shared_space_hash.rb
132
+ - test/shared_replicated_shard.rb
133
+ - test/test_space_array_fiber.rb
134
+ - test/test_space_hash_block.rb
136
135
  - test/test_light_record_callback.rb
137
136
  - Gemfile
138
137
  - LICENSE
@@ -146,47 +145,47 @@ rdoc_options:
146
145
  require_paths:
147
146
  - lib
148
147
  required_ruby_version: !ruby/object:Gem::Requirement
149
- none: false
150
148
  requirements:
151
149
  - - ! '>='
152
150
  - !ruby/object:Gem::Version
153
151
  version: '0'
154
- required_rubygems_version: !ruby/object:Gem::Requirement
155
152
  none: false
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
154
  requirements:
157
155
  - - ! '>='
158
156
  - !ruby/object:Gem::Version
159
157
  version: '0'
158
+ none: false
160
159
  requirements: []
161
160
  rubyforge_project:
162
- rubygems_version: 1.8.24
161
+ rubygems_version: 1.8.25
163
162
  signing_key:
164
163
  specification_version: 3
165
164
  summary: Tarantool KV-storage client.
166
165
  test_files:
167
- - test/test_light_record.rb
168
- - test/shared_record.rb
169
- - test/shared_replicated_shard.rb
170
- - test/shared_space_array.rb
171
- - test/test_shard_replication_fiber.rb
172
- - test/test_space_hash_block.rb
173
- - test/test_space_hash_fiber.rb
166
+ - test/shared_query.rb
174
167
  - test/test_reshard_block.rb
175
- - test/tarantool.cfg
176
- - test/helper.rb
177
- - test/test_query_fiber.rb
178
- - test/test_space_array_callback_nodef.rb
179
- - test/tarantool1.cfg
180
- - test/init.lua
181
- - test/run_all.rb
182
168
  - test/test_space_array_callback.rb
183
- - test/test_space_array_fiber.rb
184
169
  - test/test_reshard_fiber.rb
185
- - test/test_query_block.rb
186
- - test/tarantool.log
170
+ - test/tarantool1.cfg
171
+ - test/test_space_array_callback_nodef.rb
172
+ - test/test_shard_replication_fiber.rb
173
+ - test/run_all.rb
187
174
  - test/shared_reshard.rb
188
- - test/shared_query.rb
175
+ - test/init.lua
176
+ - test/helper.rb
189
177
  - test/test_shard_replication_block.rb
178
+ - test/tarantool.log
179
+ - test/tarantool.cfg
180
+ - test/shared_space_array.rb
181
+ - test/test_query_fiber.rb
182
+ - test/test_light_record.rb
183
+ - test/shared_record.rb
184
+ - test/test_space_hash_fiber.rb
185
+ - test/test_query_block.rb
190
186
  - test/test_space_array_block.rb
191
187
  - test/shared_space_hash.rb
188
+ - test/shared_replicated_shard.rb
189
+ - test/test_space_array_fiber.rb
190
+ - test/test_space_hash_block.rb
192
191
  - test/test_light_record_callback.rb
@@ -1,9 +0,0 @@
1
- module Tarantool
2
- <<<<<<< HEAD
3
- VERSION = "0.4.3.2"
4
- RECORD_VERSION = "0.4.2"
5
- =======
6
- VERSION = "0.4.3.3"
7
- RECORD_VERSION = "0.4.1.2"
8
- >>>>>>> 90ffab2... fix exception for secondary port
9
- end