activerecord-sharding 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +8 -0
- data/CHANGELOG.md +24 -0
- data/ar50.gemfile +6 -0
- data/lib/active_record/sharding/cluster_config.rb +2 -2
- data/lib/active_record/sharding/errors.rb +6 -0
- data/lib/active_record/sharding/model.rb +1 -0
- data/lib/active_record/sharding/modulo_router.rb +1 -1
- data/lib/active_record/sharding/sequencer.rb +3 -1
- data/lib/active_record/sharding/version.rb +1 -1
- data/spec/active_record/sharding/cluster_config_spec.rb +4 -4
- data/spec/active_record/sharding/model_spec.rb +4 -0
- data/spec/active_record/sharding/sequencer_spec.rb +20 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b1c1c0941e4e769d5689da33ed7d59408829357
|
4
|
+
data.tar.gz: 6b936f7d049b8f3df778f1ed34b90670001c67ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6c7d5d9c02a929e6d4304270fd2c4138ae327bc977d089f857b5b2f43493bd5786a3b64d72564252e80cf15d25548f54427bfbb9ee41b6074b1c1fa538deda
|
7
|
+
data.tar.gz: f77ac90250d835bdfba156867ad14e118fd7b3ee806a5f805505b79e2d42ce023a92a505a0925acdc9b056ef16cbbe12c516db245eac32e461371dba1f408c93
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/.travis.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
install: bundle install --jobs=3 --retry=3
|
3
3
|
rvm:
|
4
|
+
- 2.3.0
|
4
5
|
- 2.2.4
|
5
6
|
- 2.1.8
|
6
7
|
- 2.0.0-p648
|
@@ -8,7 +9,14 @@ gemfile:
|
|
8
9
|
- Gemfile
|
9
10
|
- ar41.gemfile
|
10
11
|
- ar416.gemfile
|
12
|
+
- ar50.gemfile
|
11
13
|
services:
|
12
14
|
- mysql
|
13
15
|
script:
|
14
16
|
- bundle exec rake spec
|
17
|
+
matrix:
|
18
|
+
exclude:
|
19
|
+
- rvm: 2.1.8
|
20
|
+
gemfile: ar50.gemfile
|
21
|
+
- rvm: 2.0.0-p648
|
22
|
+
gemfile: ar50.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.3.0](https://github.com/hirocaster/activerecord-sharding/tree/v0.3.0) (2016-02-03)
|
4
|
+
[Full Changelog](https://github.com/hirocaster/activerecord-sharding/compare/v0.2.0...v0.3.0)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Add parallel query to all shards [\#20](https://github.com/hirocaster/activerecord-sharding/pull/20) ([hirocaster](https://github.com/hirocaster))
|
9
|
+
|
10
|
+
## [v0.2.0](https://github.com/hirocaster/activerecord-sharding/tree/v0.2.0) (2016-01-15)
|
11
|
+
[Full Changelog](https://github.com/hirocaster/activerecord-sharding/compare/v0.1.0...v0.2.0)
|
12
|
+
|
13
|
+
**Merged pull requests:**
|
14
|
+
|
15
|
+
- Add offset error [\#19](https://github.com/hirocaster/activerecord-sharding/pull/19) ([hirocaster](https://github.com/hirocaster))
|
16
|
+
- add default args 'offset' at next\_sequence\_id method [\#18](https://github.com/hirocaster/activerecord-sharding/pull/18) ([myoan](https://github.com/myoan))
|
17
|
+
- Version up ruby 2.2.4 [\#17](https://github.com/hirocaster/activerecord-sharding/pull/17) ([hirocaster](https://github.com/hirocaster))
|
18
|
+
- Add MissingPrimaryKey Error [\#16](https://github.com/hirocaster/activerecord-sharding/pull/16) ([hirocaster](https://github.com/hirocaster))
|
19
|
+
- Out put sequencer class name to log [\#15](https://github.com/hirocaster/activerecord-sharding/pull/15) ([hirocaster](https://github.com/hirocaster))
|
20
|
+
- Add transaction spec [\#14](https://github.com/hirocaster/activerecord-sharding/pull/14) ([hirocaster](https://github.com/hirocaster))
|
21
|
+
- Put transaction block [\#13](https://github.com/hirocaster/activerecord-sharding/pull/13) ([hirocaster](https://github.com/hirocaster))
|
22
|
+
- Add count\_up\_sequence\_id method [\#12](https://github.com/hirocaster/activerecord-sharding/pull/12) ([hirocaster](https://github.com/hirocaster))
|
23
|
+
- Fix duplicate sequencer record [\#11](https://github.com/hirocaster/activerecord-sharding/pull/11) ([hirocaster](https://github.com/hirocaster))
|
24
|
+
- Add multi activerecord version tests [\#9](https://github.com/hirocaster/activerecord-sharding/pull/9) ([hirocaster](https://github.com/hirocaster))
|
25
|
+
- Fix coveraills badge [\#8](https://github.com/hirocaster/activerecord-sharding/pull/8) ([hirocaster](https://github.com/hirocaster))
|
26
|
+
|
3
27
|
## [v0.1.0](https://github.com/hirocaster/activerecord-sharding/tree/v0.1.0) (2015-08-27)
|
4
28
|
**Merged pull requests:**
|
5
29
|
|
data/ar50.gemfile
ADDED
@@ -16,12 +16,12 @@ module ActiveRecord
|
|
16
16
|
@connection_registry[modulo_key]
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def registered_connection_count
|
20
20
|
@connection_registry.count
|
21
21
|
end
|
22
22
|
|
23
23
|
def validate_config!
|
24
|
-
raise "Nothing
|
24
|
+
raise "Nothing registered connections." if registered_connection_count == 0
|
25
25
|
end
|
26
26
|
|
27
27
|
def connections
|
@@ -32,7 +32,9 @@ module ActiveRecord
|
|
32
32
|
|
33
33
|
def next_sequence_id(offset = 1)
|
34
34
|
raise NegativeNumberOffsetError if offset < 1
|
35
|
-
execute_sql "id +#{offset}"
|
35
|
+
sequence_id = execute_sql "id +#{offset}"
|
36
|
+
raise ActiveRecord::Sharding::InvalidSequenceId if sequence_id.zero?
|
37
|
+
sequence_id
|
36
38
|
end
|
37
39
|
|
38
40
|
def execute_sql(last_insert_id_args)
|
@@ -16,9 +16,9 @@ describe ActiveRecord::Sharding::ClusterConfig do
|
|
16
16
|
config.register_connection :db_connection_003
|
17
17
|
end
|
18
18
|
|
19
|
-
describe '#
|
20
|
-
it "returns
|
21
|
-
expect(config.
|
19
|
+
describe '#registered_connection_count' do
|
20
|
+
it "returns registered total connection count" do
|
21
|
+
expect(config.registered_connection_count).to eq 3
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -34,7 +34,7 @@ describe ActiveRecord::Sharding::ClusterConfig do
|
|
34
34
|
describe '#validate_config!' do
|
35
35
|
context "Nothing register connection" do
|
36
36
|
it "returns raise" do
|
37
|
-
expect { config.validate_config! }.to raise_error "Nothing
|
37
|
+
expect { config.validate_config! }.to raise_error "Nothing registered connections."
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -42,6 +42,10 @@ describe ActiveRecord::Sharding::Model do
|
|
42
42
|
expect(alice.class.name).to match(/User::ShardFor/)
|
43
43
|
end
|
44
44
|
|
45
|
+
it "raise InvalidPrimaryKey" do
|
46
|
+
expect { model.put! id: 0, name: "invalid_id" }.to raise_error ActiveRecord::Sharding::InvalidPrimaryKey
|
47
|
+
end
|
48
|
+
|
45
49
|
context "in transaction" do
|
46
50
|
it "when rollback" do
|
47
51
|
before_record_count = model.all_shards.map(&:count).reduce(:+)
|
@@ -10,6 +10,26 @@ describe ActiveRecord::Sharding::Model do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
let(:sequencer_args) do
|
14
|
+
{ sequencer_name: "user" }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "forget insert sequencer record" do
|
18
|
+
before do
|
19
|
+
ActiveRecord::Sharding::DatabaseTasks.drop_sequencer_database sequencer_args
|
20
|
+
ActiveRecord::Sharding::DatabaseTasks.create_sequencer_database sequencer_args
|
21
|
+
ActiveRecord::Sharding::DatabaseTasks.create_table_sequencer_database sequencer_args
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
ActiveRecord::Sharding::DatabaseTasks.insert_initial_record_sequencer_database sequencer_args # forget this in setup
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raise ActiveRecord::Sharding::InvalidSequenceId" do
|
29
|
+
expect { model.next_sequence_id }.to raise_error ActiveRecord::Sharding::InvalidSequenceId
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
13
33
|
describe '#current_sequence_id' do
|
14
34
|
it "returns current sequence id" do
|
15
35
|
current_id = model.current_sequence_id
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-sharding
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirocaster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expeditor
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- activerecord-sharding.gemspec
|
188
188
|
- ar41.gemfile
|
189
189
|
- ar416.gemfile
|
190
|
+
- ar50.gemfile
|
190
191
|
- bin/benchmark_sequencer.rb
|
191
192
|
- bin/console
|
192
193
|
- bin/setup
|
@@ -240,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
241
|
version: '0'
|
241
242
|
requirements: []
|
242
243
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.
|
244
|
+
rubygems_version: 2.5.1
|
244
245
|
signing_key:
|
245
246
|
specification_version: 4
|
246
247
|
summary: Sharding library for ActiveRecord(MySQL)
|