switchman 1.2.32 → 1.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/switchman/shard.rb +6 -0
- data/lib/switchman/database_server.rb +7 -0
- data/lib/switchman/default_shard.rb +1 -0
- data/lib/switchman/version.rb +1 -1
- data/lib/tasks/switchman.rake +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a349637588bb7ed6a77000f7e289c69f1a4631d8
|
4
|
+
data.tar.gz: 495616221bc75fcd1921a736fe7fd6fbba32a3ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c5775a79605ae66621b26e907c90a99fb773134ad0248a4325000de2a7423e9cbff71c5f7272b9ee458495205752fa2c32bd584a9bfc93116b06d1ba3c85a8a
|
7
|
+
data.tar.gz: ae552414da6895cbc182124ce667f52a8b8652f1fce32b936b908a2186ab04858647ddbb0b7164fa4aa3483665ff7538a3414238cfb88c50ec024fa6cb9776d3
|
@@ -21,6 +21,8 @@ module Switchman
|
|
21
21
|
|
22
22
|
after_save :clear_cache
|
23
23
|
|
24
|
+
scope :primary, -> { where(name: nil).order(:database_server_id, :id).distinct_on(:database_server_id) }
|
25
|
+
|
24
26
|
class << self
|
25
27
|
def categories
|
26
28
|
CATEGORIES.keys
|
@@ -372,6 +374,10 @@ module Switchman
|
|
372
374
|
end
|
373
375
|
end
|
374
376
|
|
377
|
+
def primary?
|
378
|
+
self == database_server.primary_shard
|
379
|
+
end
|
380
|
+
|
375
381
|
# takes an id-ish, and returns an integral id relative to
|
376
382
|
# target_shard. returns any_id itself if it can't be interpreted
|
377
383
|
def relative_id_for(any_id, source_shard, target_shard)
|
@@ -265,6 +265,13 @@ module Switchman
|
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
+
def primary_shard
|
269
|
+
unless instance_variable_defined?(:@primary_shard)
|
270
|
+
@primary_shard = shards.where(name: nil).first
|
271
|
+
end
|
272
|
+
@primary_shard
|
273
|
+
end
|
274
|
+
|
268
275
|
private
|
269
276
|
def reset_column_information
|
270
277
|
::ActiveRecord::Base.connection_handler.switchman_connection_pool_proxies.each { |pool| pool.schema_cache.clear! }
|
@@ -6,6 +6,7 @@ module Switchman
|
|
6
6
|
def activate(*categories); yield; end
|
7
7
|
def activate!(*categories); end
|
8
8
|
def default?; true; end
|
9
|
+
def primary?; true; end
|
9
10
|
def relative_id_for(local_id, target = nil); local_id; end
|
10
11
|
def global_id_for(local_id); local_id; end
|
11
12
|
def database_server_id; nil; end
|
data/lib/switchman/version.rb
CHANGED
data/lib/tasks/switchman.rake
CHANGED
@@ -72,6 +72,10 @@ module Switchman
|
|
72
72
|
shard_ids << Shard.default.id
|
73
73
|
elsif id == '-default'
|
74
74
|
negative_shard_ids << Shard.default.id
|
75
|
+
elsif id == 'primary'
|
76
|
+
shard_ids.concat(Shard.primary.pluck(:id))
|
77
|
+
elsif id == '-primary'
|
78
|
+
negative_shard_ids.concat(Shard.primary.pluck(:id))
|
75
79
|
elsif id =~ /(-?)(\d+)?\.\.(\.)?(\d+)?/
|
76
80
|
negative, start, open, finish = $1.present?, $2, $3.present?, $4
|
77
81
|
raise "Invalid shard id or range: #{id}" unless start || finish
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-05-
|
13
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -511,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
511
511
|
version: '0'
|
512
512
|
requirements: []
|
513
513
|
rubyforge_project:
|
514
|
-
rubygems_version: 2.4.
|
514
|
+
rubygems_version: 2.4.5
|
515
515
|
signing_key:
|
516
516
|
specification_version: 4
|
517
517
|
summary: Rails 3 sharding magic
|