mixed_gauge 1.1.0 → 1.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -7
- data/Appraisals +4 -0
- data/bump +36 -0
- data/gemfiles/ar_5.0.gemfile +7 -0
- data/lib/mixed_gauge/all_shards_in_parallel.rb +5 -3
- data/lib/mixed_gauge/model.rb +11 -1
- data/lib/mixed_gauge/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 488697e190a7afe02458ee70c2a9ef24a9b2489ff4cb5c34963590a1c34053dc
|
4
|
+
data.tar.gz: 6c7216031832ceadee0f6f81bd863bf931d45a83848b3dc45c19d77c6b4d6f99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e99abf20bd5594fb4c568baedfd5263653740d353fe8261f84758bb45c82e373f7d11ffbd2acdadf3e12256e49a644f4f70d23e6a6eb02ee676b51418c42e42
|
7
|
+
data.tar.gz: 06142ae97b316aff0e63b68c9401322734e487f00d5f0128025ae5d78ae52cb35abc6e52419a4b622827ab2226658d517eeccad2b2448b1b86c9af832ea986f2
|
data/.travis.yml
CHANGED
@@ -4,21 +4,22 @@ branches:
|
|
4
4
|
only:
|
5
5
|
- master
|
6
6
|
rvm:
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
7
|
+
- 2.1.9
|
8
|
+
- 2.2.4
|
9
|
+
- 2.3.1
|
10
10
|
gemfile:
|
11
11
|
- gemfiles/ar_4.1.0.gemfile
|
12
12
|
- gemfiles/ar_4.1.7.gemfile
|
13
13
|
- gemfiles/ar_4.1.8.gemfile
|
14
14
|
- gemfiles/ar_4.2.gemfile
|
15
|
+
- gemfiles/ar_5.0.gemfile
|
15
16
|
- gemfiles/rails_edge.gemfile
|
16
17
|
matrix:
|
17
18
|
allow_failures:
|
18
19
|
- gemfile: gemfiles/rails_edge.gemfile
|
19
20
|
exclude:
|
20
|
-
# Rails 5
|
21
|
-
- rvm: 2.
|
22
|
-
gemfile: gemfiles/rails_edge.gemfile
|
23
|
-
- rvm: 2.1
|
21
|
+
# Rails 5 or later requires Ruby 2.2.0 or newer.
|
22
|
+
- rvm: 2.1.9
|
24
23
|
gemfile: gemfiles/rails_edge.gemfile
|
24
|
+
- rvm: 2.1.9
|
25
|
+
gemfile: gemfiles/ar_5.0.gemfile
|
data/Appraisals
CHANGED
data/bump
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
level = ARGV.first
|
3
|
+
if level.nil?
|
4
|
+
warn "Example: #{__FILE__} (tiny|minor|major)"
|
5
|
+
exit 1
|
6
|
+
end
|
7
|
+
|
8
|
+
path = 'lib/mixed_gauge/version.rb'
|
9
|
+
regexp = /VERSION = '(.+)'.freeze$/
|
10
|
+
version = File.read(path).scan(regexp)[0][0]
|
11
|
+
version_strs = version.split('.')
|
12
|
+
|
13
|
+
if version_strs.size > 3
|
14
|
+
warn "Current version includes a prelease suffix, drop it: #{version}"
|
15
|
+
version_strs = version_strs[0..2]
|
16
|
+
end
|
17
|
+
|
18
|
+
case level
|
19
|
+
when 'tiny'
|
20
|
+
version_strs[2] = version_strs[2].to_i + 1
|
21
|
+
when 'minor'
|
22
|
+
version_strs[1] = version_strs[1].to_i + 1
|
23
|
+
version_strs[2] = 0
|
24
|
+
when 'major'
|
25
|
+
version_strs[0] = version_strs[0].to_i + 1
|
26
|
+
version_strs[1] = 0
|
27
|
+
version_strs[2] = 0
|
28
|
+
else
|
29
|
+
warn "Example: #{__FILE__} (tiny|minor|major)"
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
next_version = version_strs.join('.')
|
34
|
+
File.write(path, File.read(path).gsub(regexp, "VERSION = '#{next_version}'.freeze"))
|
35
|
+
system('git', 'add', path)
|
36
|
+
system('git', 'commit', '-m', "v#{next_version}")
|
@@ -2,9 +2,11 @@ module MixedGauge
|
|
2
2
|
# Support parallel execution with each shard and deal with AR connection
|
3
3
|
# management in parallel execution.
|
4
4
|
class AllShardsInParallel
|
5
|
-
# @param [Array<Class>] An array of shard model class
|
6
|
-
|
5
|
+
# @param [Array<Class>] shards An array of shard model class
|
6
|
+
# @param [Expeditor::Service] service
|
7
|
+
def initialize(shards, service:)
|
7
8
|
@shards = shards
|
9
|
+
@service = service
|
8
10
|
end
|
9
11
|
|
10
12
|
# @yield [Class] A shard model class
|
@@ -13,7 +15,7 @@ module MixedGauge
|
|
13
15
|
# User.all_shards_in_parallel.map(&:count).reduce(&:+)
|
14
16
|
def map(&block)
|
15
17
|
commands = @shards.map do |m|
|
16
|
-
Expeditor::Command.new { m.connection_pool.with_connection { yield m } }
|
18
|
+
Expeditor::Command.new(service: @service) { m.connection_pool.with_connection { yield m } }
|
17
19
|
end
|
18
20
|
commands.each(&:start)
|
19
21
|
commands.map(&:get)
|
data/lib/mixed_gauge/model.rb
CHANGED
@@ -24,6 +24,7 @@ module MixedGauge
|
|
24
24
|
class_attribute :shard_repository, instance_writer: false
|
25
25
|
class_attribute :distkey, instance_writer: false
|
26
26
|
class_attribute :replication_mapping, instance_writer: false
|
27
|
+
class_attribute :service, instance_writer: false
|
27
28
|
end
|
28
29
|
|
29
30
|
module ClassMethods
|
@@ -33,6 +34,15 @@ module MixedGauge
|
|
33
34
|
config = MixedGauge.config.fetch_cluster_config(name)
|
34
35
|
self.cluster_routing = MixedGauge::Routing.new(config)
|
35
36
|
self.shard_repository = MixedGauge::ShardRepository.new(config, self)
|
37
|
+
thread_size = (shard_repository.all.size * 100)
|
38
|
+
self.service = Expeditor::Service.new(
|
39
|
+
executor: Concurrent::ThreadPoolExecutor.new(
|
40
|
+
min_threads: thread_size,
|
41
|
+
max_threads: thread_size,
|
42
|
+
max_queue: shard_repository.all.size,
|
43
|
+
fallback_policy: :abort,
|
44
|
+
)
|
45
|
+
)
|
36
46
|
self.abstract_class = true
|
37
47
|
end
|
38
48
|
|
@@ -122,7 +132,7 @@ module MixedGauge
|
|
122
132
|
# @example
|
123
133
|
# User.all_shards_in_parallel.map {|m| m.where.find_by(name: 'Alice') }.compact
|
124
134
|
def all_shards_in_parallel
|
125
|
-
AllShardsInParallel.new(all_shards)
|
135
|
+
AllShardsInParallel.new(all_shards, service: service)
|
126
136
|
end
|
127
137
|
alias_method :parallel, :all_shards_in_parallel
|
128
138
|
|
data/lib/mixed_gauge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixed_gauge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki Ono
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -185,10 +185,12 @@ files:
|
|
185
185
|
- Rakefile
|
186
186
|
- bin/console
|
187
187
|
- bin/setup
|
188
|
+
- bump
|
188
189
|
- gemfiles/ar_4.1.0.gemfile
|
189
190
|
- gemfiles/ar_4.1.7.gemfile
|
190
191
|
- gemfiles/ar_4.1.8.gemfile
|
191
192
|
- gemfiles/ar_4.2.gemfile
|
193
|
+
- gemfiles/ar_5.0.gemfile
|
192
194
|
- gemfiles/rails_edge.gemfile
|
193
195
|
- lib/mixed_gauge.rb
|
194
196
|
- lib/mixed_gauge/all_shards_in_parallel.rb
|
@@ -219,14 +221,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
221
|
version: '0'
|
220
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
223
|
requirements:
|
222
|
-
- - "
|
224
|
+
- - ">"
|
223
225
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
226
|
+
version: 1.3.1
|
225
227
|
requirements: []
|
226
228
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.
|
229
|
+
rubygems_version: 2.7.3
|
228
230
|
signing_key:
|
229
231
|
specification_version: 4
|
230
232
|
summary: A simple and robust ActiveRecord extension for database sharding.
|
231
233
|
test_files: []
|
232
|
-
has_rdoc:
|