sengiri 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -3
- data/lib/sengiri/generators/migration_generator.rb +0 -1
- data/lib/sengiri/railties/sharding.rake +0 -1
- data/lib/sengiri/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cf2b0a2d6136b98587fdc922d0af979bc5615dc
|
4
|
+
data.tar.gz: 11669c7daa1637126d51e6688d399bd4b9dc1e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d32f1573dfa4cd9ca730a4c1007af735996f1290416dba0233b6ad1f67cbeee604e63a9b64bfa34adf169fdb4d0b0ace2f9a46610ad6ebc290b9ce80e6ff8e
|
7
|
+
data.tar.gz: 3bb32d54a802c7ba3f7d76cb5c7c16291af7969496322dffec9fed8935bf7d906cae272f11d8854e07536e7b1cf8dfbac4823b34c329a14594136493af6f5f25
|
data/README.md
CHANGED
@@ -17,15 +17,15 @@ Flexible sharding access for Ruby on Rails with ActiveRecord
|
|
17
17
|
password:
|
18
18
|
host: localhost
|
19
19
|
|
20
|
-
|
20
|
+
mygroup_shards_first: # define shard as 'first'
|
21
21
|
<<: *mysql
|
22
22
|
database: mygroup_1
|
23
23
|
host: hosta
|
24
|
-
|
24
|
+
mygroup_shards_second: # define shard as 'second'
|
25
25
|
<<: *mysql
|
26
26
|
database: mygroup_2
|
27
27
|
host: hostb
|
28
|
-
|
28
|
+
mygroup_shards_third: # define shard as 'third'
|
29
29
|
<<: *mysql
|
30
30
|
database: mygroup_3
|
31
31
|
host: hostc
|
@@ -38,5 +38,39 @@ Flexible sharding access for Ruby on Rails with ActiveRecord
|
|
38
38
|
rake sengiri:mygroup:db:create
|
39
39
|
rake sengiri:mygroup:db:migrate
|
40
40
|
|
41
|
+
|
42
|
+
## Sharding access
|
43
|
+
|
44
|
+
User.shard('second') do |shard|
|
45
|
+
shard.all.limit(10) # query on db 'mygroup_1'
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
User.shards do |shard|
|
50
|
+
shard.all.limit(10) # query on all db 'mygroup_1', 'mygroup_2', 'mygroup_3'
|
51
|
+
end
|
52
|
+
|
53
|
+
## Transaction
|
54
|
+
|
55
|
+
User.shard('second').transaction do
|
56
|
+
# in mygroup_2 transaction
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
User.transaction do
|
61
|
+
# in mygroup_1, mygroup_2 and mygroup_3 transaction
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# This is same as below
|
66
|
+
|
67
|
+
|
68
|
+
User.shard('first').transaction do
|
69
|
+
User.shard('second').transaction do
|
70
|
+
User.shard('third').transaction do
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
41
75
|
|
42
76
|
This project rocks and uses MIT-LICENSE.
|
data/lib/sengiri/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sengiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mewlist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|