ar-octopus 0.8.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/.rubocop.yml +46 -0
- data/.rubocop_todo.yml +56 -0
- data/.travis.yml +7 -12
- data/Appraisals +11 -4
- data/Gemfile +1 -1
- data/README.mkdn +138 -63
- data/Rakefile +23 -16
- data/ar-octopus.gemspec +23 -20
- data/gemfiles/rails42.gemfile +7 -0
- data/gemfiles/{rails32.gemfile → rails5.gemfile} +2 -2
- data/gemfiles/{rails4.gemfile → rails51.gemfile} +2 -2
- data/gemfiles/rails52.gemfile +7 -0
- data/lib/ar-octopus.rb +1 -1
- data/lib/octopus/{rails3/abstract_adapter.rb → abstract_adapter.rb} +4 -15
- data/lib/octopus/association.rb +8 -99
- data/lib/octopus/association_shard_tracking.rb +74 -0
- data/lib/octopus/collection_association.rb +17 -0
- data/lib/octopus/collection_proxy.rb +16 -0
- data/lib/octopus/exception.rb +4 -0
- data/lib/octopus/finder_methods.rb +8 -0
- data/lib/octopus/load_balancing/round_robin.rb +20 -0
- data/lib/octopus/load_balancing.rb +4 -0
- data/lib/octopus/{rails3/log_subscriber.rb → log_subscriber.rb} +6 -2
- data/lib/octopus/migration.rb +187 -110
- data/lib/octopus/model.rb +151 -131
- data/lib/octopus/persistence.rb +45 -0
- data/lib/octopus/proxy.rb +297 -232
- data/lib/octopus/proxy_config.rb +251 -0
- data/lib/octopus/query_cache_for_shards.rb +24 -0
- data/lib/octopus/railtie.rb +1 -3
- data/lib/octopus/relation_proxy.rb +70 -0
- data/lib/octopus/result_patch.rb +19 -0
- data/lib/octopus/scope_proxy.rb +54 -36
- data/lib/octopus/shard_tracking/attribute.rb +22 -0
- data/lib/octopus/shard_tracking/dynamic.rb +11 -0
- data/lib/octopus/shard_tracking.rb +46 -0
- data/lib/octopus/singular_association.rb +9 -0
- data/lib/octopus/slave_group.rb +13 -0
- data/lib/octopus/version.rb +1 -1
- data/lib/octopus.rb +125 -33
- data/lib/tasks/octopus.rake +2 -2
- data/sample_app/Gemfile +3 -3
- data/sample_app/autotest/discover.rb +2 -2
- data/sample_app/config/application.rb +1 -1
- data/sample_app/config/boot.rb +1 -1
- data/sample_app/config/environments/test.rb +1 -1
- data/sample_app/config/initializers/session_store.rb +1 -1
- data/sample_app/config/initializers/wrap_parameters.rb +1 -1
- data/sample_app/config/routes.rb +1 -1
- data/sample_app/db/migrate/20100720210335_create_sample_users.rb +2 -2
- data/sample_app/db/schema.rb +10 -10
- data/sample_app/db/seeds.rb +3 -3
- data/sample_app/features/step_definitions/seeds_steps.rb +4 -4
- data/sample_app/features/step_definitions/web_steps.rb +3 -4
- data/sample_app/features/support/env.rb +3 -4
- data/sample_app/features/support/paths.rb +4 -4
- data/sample_app/lib/tasks/cucumber.rake +43 -44
- data/sample_app/spec/spec_helper.rb +3 -3
- data/spec/config/shards.yml +78 -0
- data/spec/migrations/10_create_users_using_replication.rb +4 -4
- data/spec/migrations/11_add_field_in_all_slaves.rb +4 -4
- data/spec/migrations/12_create_users_using_block.rb +8 -8
- data/spec/migrations/13_create_users_using_block_and_using.rb +5 -5
- data/spec/migrations/14_create_users_on_shards_of_a_group_with_versions.rb +3 -3
- data/spec/migrations/15_create_user_on_shards_of_default_group_with_versions.rb +3 -3
- data/spec/migrations/1_create_users_on_master.rb +4 -4
- data/spec/migrations/2_create_users_on_canada.rb +4 -4
- data/spec/migrations/3_create_users_on_both_shards.rb +4 -4
- data/spec/migrations/4_create_users_on_shards_of_a_group.rb +4 -4
- data/spec/migrations/5_create_users_on_multiples_groups.rb +3 -3
- data/spec/migrations/6_raise_exception_with_invalid_shard_name.rb +4 -4
- data/spec/migrations/7_raise_exception_with_invalid_multiple_shard_names.rb +4 -4
- data/spec/migrations/8_raise_exception_with_invalid_group_name.rb +4 -4
- data/spec/migrations/9_raise_exception_with_multiple_invalid_group_names.rb +5 -5
- data/spec/octopus/association_shard_tracking_spec.rb +1036 -0
- data/spec/octopus/collection_proxy_spec.rb +16 -0
- data/spec/octopus/load_balancing/round_robin_spec.rb +15 -0
- data/spec/octopus/log_subscriber_spec.rb +5 -5
- data/spec/octopus/migration_spec.rb +83 -49
- data/spec/octopus/model_spec.rb +544 -292
- data/spec/octopus/octopus_spec.rb +64 -31
- data/spec/octopus/proxy_spec.rb +145 -141
- data/spec/octopus/query_cache_for_shards_spec.rb +40 -0
- data/spec/octopus/relation_proxy_spec.rb +132 -0
- data/spec/octopus/replicated_slave_grouped_spec.rb +91 -0
- data/spec/octopus/replication_spec.rb +140 -65
- data/spec/octopus/scope_proxy_spec.rb +90 -10
- data/spec/octopus/sharded_replicated_slave_grouped_spec.rb +55 -0
- data/spec/octopus/sharded_spec.rb +10 -10
- data/spec/spec_helper.rb +8 -6
- data/spec/support/active_record/connection_adapters/modify_config_adapter.rb +1 -3
- data/spec/support/database_connection.rb +2 -2
- data/spec/support/database_models.rb +18 -17
- data/spec/support/octopus_helper.rb +32 -25
- data/spec/support/query_count.rb +1 -3
- data/spec/support/shared_contexts.rb +3 -3
- data/spec/tasks/octopus.rake_spec.rb +10 -10
- metadata +112 -70
- data/.ruby-version +0 -1
- data/init.rb +0 -1
- data/lib/octopus/association_collection.rb +0 -49
- data/lib/octopus/has_and_belongs_to_many_association.rb +0 -17
- data/lib/octopus/rails3/persistence.rb +0 -39
- data/lib/octopus/rails3/singular_association.rb +0 -34
- data/rails/init.rb +0 -1
- data/spec/octopus/association_spec.rb +0 -712
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-octopus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Pradi
|
@@ -10,134 +10,154 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 4.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 4.2.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: activesupport
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 4.2.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 4.2.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
44
|
+
name: appraisal
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.8
|
49
|
+
version: 0.3.8
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.8
|
56
|
+
version: 0.3.8
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: mysql2
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.3.18
|
64
|
+
- - "<"
|
62
65
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
66
|
+
version: '0.5'
|
64
67
|
type: :development
|
65
68
|
prerelease: false
|
66
69
|
version_requirements: !ruby/object:Gem::Requirement
|
67
70
|
requirements:
|
68
|
-
- -
|
71
|
+
- - ">="
|
69
72
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
73
|
+
version: 0.3.18
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.5'
|
71
77
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
78
|
+
name: pg
|
73
79
|
requirement: !ruby/object:Gem::Requirement
|
74
80
|
requirements:
|
75
|
-
- -
|
81
|
+
- - "~>"
|
76
82
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0.
|
83
|
+
version: '0.18'
|
78
84
|
type: :development
|
79
85
|
prerelease: false
|
80
86
|
version_requirements: !ruby/object:Gem::Requirement
|
81
87
|
requirements:
|
82
|
-
- -
|
88
|
+
- - "~>"
|
83
89
|
- !ruby/object:Gem::Version
|
84
|
-
version: '0.
|
90
|
+
version: '0.18'
|
85
91
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
92
|
+
name: rake
|
87
93
|
requirement: !ruby/object:Gem::Requirement
|
88
94
|
requirements:
|
89
|
-
- -
|
95
|
+
- - ">="
|
90
96
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0
|
97
|
+
version: '0'
|
92
98
|
type: :development
|
93
99
|
prerelease: false
|
94
100
|
version_requirements: !ruby/object:Gem::Requirement
|
95
101
|
requirements:
|
96
|
-
- -
|
102
|
+
- - ">="
|
97
103
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0
|
104
|
+
version: '0'
|
99
105
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
106
|
+
name: rspec
|
101
107
|
requirement: !ruby/object:Gem::Requirement
|
102
108
|
requirements:
|
103
|
-
- -
|
109
|
+
- - ">="
|
104
110
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
111
|
+
version: '3'
|
106
112
|
type: :development
|
107
113
|
prerelease: false
|
108
114
|
version_requirements: !ruby/object:Gem::Requirement
|
109
115
|
requirements:
|
110
|
-
- -
|
116
|
+
- - ">="
|
111
117
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
118
|
+
version: '3'
|
113
119
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
120
|
+
name: rubocop
|
115
121
|
requirement: !ruby/object:Gem::Requirement
|
116
122
|
requirements:
|
117
|
-
- -
|
123
|
+
- - ">="
|
118
124
|
- !ruby/object:Gem::Version
|
119
125
|
version: '0'
|
120
126
|
type: :development
|
121
127
|
prerelease: false
|
122
128
|
version_requirements: !ruby/object:Gem::Requirement
|
123
129
|
requirements:
|
124
|
-
- -
|
130
|
+
- - ">="
|
125
131
|
- !ruby/object:Gem::Version
|
126
132
|
version: '0'
|
127
133
|
- !ruby/object:Gem::Dependency
|
128
|
-
name:
|
134
|
+
name: sqlite3
|
129
135
|
requirement: !ruby/object:Gem::Requirement
|
130
136
|
requirements:
|
131
|
-
- -
|
137
|
+
- - "~>"
|
132
138
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
139
|
+
version: 1.3.6
|
134
140
|
type: :development
|
135
141
|
prerelease: false
|
136
142
|
version_requirements: !ruby/object:Gem::Requirement
|
137
143
|
requirements:
|
138
|
-
- -
|
144
|
+
- - "~>"
|
139
145
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
146
|
+
version: 1.3.6
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: pry-byebug
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
141
161
|
description: This gem allows you to use sharded databases with ActiveRecord. This
|
142
162
|
also provides a interface for replication and for running migrations with multiples
|
143
163
|
shards.
|
@@ -149,36 +169,50 @@ executables: []
|
|
149
169
|
extensions: []
|
150
170
|
extra_rdoc_files: []
|
151
171
|
files:
|
152
|
-
- .gitignore
|
153
|
-
- .rspec
|
154
|
-
- .
|
155
|
-
- .
|
172
|
+
- ".gitignore"
|
173
|
+
- ".rspec"
|
174
|
+
- ".rubocop.yml"
|
175
|
+
- ".rubocop_todo.yml"
|
176
|
+
- ".travis.yml"
|
156
177
|
- Appraisals
|
157
178
|
- Gemfile
|
158
179
|
- README.mkdn
|
159
180
|
- Rakefile
|
160
181
|
- TODO.txt
|
161
182
|
- ar-octopus.gemspec
|
162
|
-
- gemfiles/
|
163
|
-
- gemfiles/
|
164
|
-
-
|
183
|
+
- gemfiles/rails42.gemfile
|
184
|
+
- gemfiles/rails5.gemfile
|
185
|
+
- gemfiles/rails51.gemfile
|
186
|
+
- gemfiles/rails52.gemfile
|
165
187
|
- lib/ar-octopus.rb
|
166
188
|
- lib/octopus.rb
|
189
|
+
- lib/octopus/abstract_adapter.rb
|
167
190
|
- lib/octopus/association.rb
|
168
|
-
- lib/octopus/
|
169
|
-
- lib/octopus/
|
191
|
+
- lib/octopus/association_shard_tracking.rb
|
192
|
+
- lib/octopus/collection_association.rb
|
193
|
+
- lib/octopus/collection_proxy.rb
|
194
|
+
- lib/octopus/exception.rb
|
195
|
+
- lib/octopus/finder_methods.rb
|
196
|
+
- lib/octopus/load_balancing.rb
|
197
|
+
- lib/octopus/load_balancing/round_robin.rb
|
198
|
+
- lib/octopus/log_subscriber.rb
|
170
199
|
- lib/octopus/migration.rb
|
171
200
|
- lib/octopus/model.rb
|
201
|
+
- lib/octopus/persistence.rb
|
172
202
|
- lib/octopus/proxy.rb
|
173
|
-
- lib/octopus/
|
174
|
-
- lib/octopus/
|
175
|
-
- lib/octopus/rails3/persistence.rb
|
176
|
-
- lib/octopus/rails3/singular_association.rb
|
203
|
+
- lib/octopus/proxy_config.rb
|
204
|
+
- lib/octopus/query_cache_for_shards.rb
|
177
205
|
- lib/octopus/railtie.rb
|
206
|
+
- lib/octopus/relation_proxy.rb
|
207
|
+
- lib/octopus/result_patch.rb
|
178
208
|
- lib/octopus/scope_proxy.rb
|
209
|
+
- lib/octopus/shard_tracking.rb
|
210
|
+
- lib/octopus/shard_tracking/attribute.rb
|
211
|
+
- lib/octopus/shard_tracking/dynamic.rb
|
212
|
+
- lib/octopus/singular_association.rb
|
213
|
+
- lib/octopus/slave_group.rb
|
179
214
|
- lib/octopus/version.rb
|
180
215
|
- lib/tasks/octopus.rake
|
181
|
-
- rails/init.rb
|
182
216
|
- sample_app/.gitignore
|
183
217
|
- sample_app/.rspec
|
184
218
|
- sample_app/Gemfile
|
@@ -270,14 +304,20 @@ files:
|
|
270
304
|
- spec/migrations/7_raise_exception_with_invalid_multiple_shard_names.rb
|
271
305
|
- spec/migrations/8_raise_exception_with_invalid_group_name.rb
|
272
306
|
- spec/migrations/9_raise_exception_with_multiple_invalid_group_names.rb
|
273
|
-
- spec/octopus/
|
307
|
+
- spec/octopus/association_shard_tracking_spec.rb
|
308
|
+
- spec/octopus/collection_proxy_spec.rb
|
309
|
+
- spec/octopus/load_balancing/round_robin_spec.rb
|
274
310
|
- spec/octopus/log_subscriber_spec.rb
|
275
311
|
- spec/octopus/migration_spec.rb
|
276
312
|
- spec/octopus/model_spec.rb
|
277
313
|
- spec/octopus/octopus_spec.rb
|
278
314
|
- spec/octopus/proxy_spec.rb
|
315
|
+
- spec/octopus/query_cache_for_shards_spec.rb
|
316
|
+
- spec/octopus/relation_proxy_spec.rb
|
317
|
+
- spec/octopus/replicated_slave_grouped_spec.rb
|
279
318
|
- spec/octopus/replication_spec.rb
|
280
319
|
- spec/octopus/scope_proxy_spec.rb
|
320
|
+
- spec/octopus/sharded_replicated_slave_grouped_spec.rb
|
281
321
|
- spec/octopus/sharded_spec.rb
|
282
322
|
- spec/spec_helper.rb
|
283
323
|
- spec/support/active_record/connection_adapters/modify_config_adapter.rb
|
@@ -291,30 +331,26 @@ homepage: https://github.com/tchandy/octopus
|
|
291
331
|
licenses:
|
292
332
|
- MIT
|
293
333
|
metadata: {}
|
294
|
-
post_install_message:
|
295
|
-
need to run:
|
296
|
-
|
334
|
+
post_install_message: |-
|
335
|
+
Important: If you are upgrading from < Octopus 0.5.0 you need to run:
|
297
336
|
$ rake octopus:copy_schema_versions
|
298
337
|
|
299
|
-
|
300
|
-
Octopus now stores schema version information in each shard and migrations will
|
301
|
-
not work properly unless this task is invoked.'
|
338
|
+
Octopus now stores schema version information in each shard and migrations will not work properly unless this task is invoked.
|
302
339
|
rdoc_options: []
|
303
340
|
require_paths:
|
304
341
|
- lib
|
305
342
|
required_ruby_version: !ruby/object:Gem::Requirement
|
306
343
|
requirements:
|
307
|
-
- -
|
344
|
+
- - ">="
|
308
345
|
- !ruby/object:Gem::Version
|
309
|
-
version:
|
346
|
+
version: 2.2.0
|
310
347
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
348
|
requirements:
|
312
|
-
- -
|
349
|
+
- - ">="
|
313
350
|
- !ruby/object:Gem::Version
|
314
351
|
version: '0'
|
315
352
|
requirements: []
|
316
|
-
|
317
|
-
rubygems_version: 2.0.10
|
353
|
+
rubygems_version: 3.0.1
|
318
354
|
signing_key:
|
319
355
|
specification_version: 4
|
320
356
|
summary: Easy Database Sharding for ActiveRecord
|
@@ -335,14 +371,20 @@ test_files:
|
|
335
371
|
- spec/migrations/7_raise_exception_with_invalid_multiple_shard_names.rb
|
336
372
|
- spec/migrations/8_raise_exception_with_invalid_group_name.rb
|
337
373
|
- spec/migrations/9_raise_exception_with_multiple_invalid_group_names.rb
|
338
|
-
- spec/octopus/
|
374
|
+
- spec/octopus/association_shard_tracking_spec.rb
|
375
|
+
- spec/octopus/collection_proxy_spec.rb
|
376
|
+
- spec/octopus/load_balancing/round_robin_spec.rb
|
339
377
|
- spec/octopus/log_subscriber_spec.rb
|
340
378
|
- spec/octopus/migration_spec.rb
|
341
379
|
- spec/octopus/model_spec.rb
|
342
380
|
- spec/octopus/octopus_spec.rb
|
343
381
|
- spec/octopus/proxy_spec.rb
|
382
|
+
- spec/octopus/query_cache_for_shards_spec.rb
|
383
|
+
- spec/octopus/relation_proxy_spec.rb
|
384
|
+
- spec/octopus/replicated_slave_grouped_spec.rb
|
344
385
|
- spec/octopus/replication_spec.rb
|
345
386
|
- spec/octopus/scope_proxy_spec.rb
|
387
|
+
- spec/octopus/sharded_replicated_slave_grouped_spec.rb
|
346
388
|
- spec/octopus/sharded_spec.rb
|
347
389
|
- spec/spec_helper.rb
|
348
390
|
- spec/support/active_record/connection_adapters/modify_config_adapter.rb
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'rails', 'init')
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Octopus::AssociationCollection
|
2
|
-
|
3
|
-
METHODS = %w[
|
4
|
-
reader
|
5
|
-
writer
|
6
|
-
ids_reader
|
7
|
-
ids_writer
|
8
|
-
create
|
9
|
-
create!
|
10
|
-
build
|
11
|
-
any?
|
12
|
-
count
|
13
|
-
empty?
|
14
|
-
first
|
15
|
-
include?
|
16
|
-
last
|
17
|
-
length
|
18
|
-
load_target
|
19
|
-
many?
|
20
|
-
size
|
21
|
-
select
|
22
|
-
uniq
|
23
|
-
]
|
24
|
-
|
25
|
-
def self.included(base)
|
26
|
-
base.instance_eval do
|
27
|
-
METHODS.each do |m|
|
28
|
-
alias_method_chain m.to_sym, :octopus
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
METHODS.each do |m|
|
34
|
-
m =~ /([^!?]+)([!?])?/
|
35
|
-
method, punctuation = [ $1, $2 ]
|
36
|
-
with = :"#{method}_with_octopus#{punctuation}"
|
37
|
-
without = :"#{method}_without_octopus#{punctuation}"
|
38
|
-
define_method with do |*args, &block|
|
39
|
-
@owner.run_on_shard { send(without, *args, &block) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def should_wrap_the_connection?
|
44
|
-
@owner.respond_to?(:current_shard) && @owner.current_shard != nil
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
ActiveRecord::Associations::CollectionAssociation.send(:include, Octopus::AssociationCollection)
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Octopus::HasAndBelongsToManyAssociation
|
2
|
-
def self.included(base)
|
3
|
-
base.instance_eval do
|
4
|
-
alias_method_chain :insert_record, :octopus
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
def insert_record_with_octopus(record, force = true, validate = true)
|
9
|
-
if should_wrap_the_connection?
|
10
|
-
Octopus.using(@owner.current_shard) { insert_record_without_octopus(record, force, validate) }
|
11
|
-
else
|
12
|
-
insert_record_without_octopus(record, force, validate)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
ActiveRecord::Associations::HasAndBelongsToManyAssociation.send(:include, Octopus::HasAndBelongsToManyAssociation)
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Octopus
|
2
|
-
module Rails3
|
3
|
-
module Persistence
|
4
|
-
def update_attribute(*args)
|
5
|
-
run_on_shard { super }
|
6
|
-
end
|
7
|
-
|
8
|
-
def update_attributes(*args)
|
9
|
-
run_on_shard { super }
|
10
|
-
end
|
11
|
-
|
12
|
-
def update_attributes!(*args)
|
13
|
-
run_on_shard { super }
|
14
|
-
end
|
15
|
-
|
16
|
-
def reload(*args)
|
17
|
-
run_on_shard { super }
|
18
|
-
end
|
19
|
-
|
20
|
-
def delete
|
21
|
-
run_on_shard { super }
|
22
|
-
end
|
23
|
-
|
24
|
-
def destroy
|
25
|
-
run_on_shard { super }
|
26
|
-
end
|
27
|
-
|
28
|
-
def touch(name=nil)
|
29
|
-
run_on_shard { super }
|
30
|
-
end
|
31
|
-
|
32
|
-
def update_column(*args)
|
33
|
-
run_on_shard { super }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
ActiveRecord::Base.send(:include, Octopus::Rails3::Persistence)
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Octopus::SingularAssociation
|
2
|
-
def self.included(base)
|
3
|
-
base.instance_eval do
|
4
|
-
alias_method_chain :reader, :octopus
|
5
|
-
alias_method_chain :writer, :octopus
|
6
|
-
alias_method_chain :create, :octopus
|
7
|
-
alias_method_chain :create!, :octopus
|
8
|
-
alias_method_chain :build, :octopus
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def reader_with_octopus(*args)
|
13
|
-
owner.run_on_shard { reader_without_octopus(*args) }
|
14
|
-
end
|
15
|
-
|
16
|
-
def writer_with_octopus(*args)
|
17
|
-
owner.run_on_shard { writer_without_octopus(*args) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def create_with_octopus(*args)
|
21
|
-
owner.run_on_shard { create_without_octopus(*args) }
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_with_octopus!(*args)
|
25
|
-
owner.run_on_shard { create_without_octopus!(*args) }
|
26
|
-
end
|
27
|
-
|
28
|
-
def build_with_octopus(*args)
|
29
|
-
owner.run_on_shard { build_without_octopus(*args) }
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
ActiveRecord::Associations::SingularAssociation.send(:include, Octopus::SingularAssociation)
|
data/rails/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "octopus"
|