switchman 1.5.21 → 1.6.0
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/lib/switchman/version.rb +1 -1
- data/lib/tasks/switchman.rake +10 -3
- 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: 5216239c0a0c3b84a975c7f5a7c63250a36c3960
|
4
|
+
data.tar.gz: 9eff38ae0cdfe742c47d25667dfa9bd5f807ad44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a8afa7d5bbedf8bf89d797cab7eab0285a36d01d7f1efada6fb6e7aabb459ee44abfb3f82bc9e043399cf943a95bb1bee6b2f932ea92e65b97d77d7c2510801
|
7
|
+
data.tar.gz: fa08be1de119479e4e9a0ad3ac6f5c6a6a18f8c3400d2d784bf30be78aaff3665875eafb2a621bd2e3a4f6181affe95a49a74b6d73e55244c0810c7409b318da
|
data/lib/switchman/version.rb
CHANGED
data/lib/tasks/switchman.rake
CHANGED
@@ -44,7 +44,11 @@ module Switchman
|
|
44
44
|
{ parallel: ENV['PARALLEL'].to_i, max_procs: ENV['MAX_PARALLEL_PROCS'] }
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
# categories - an array or proc, to activate as the current shard during the
|
48
|
+
# task. tasks which modify the schema may want to pass all categories in
|
49
|
+
# so that schema updates for non-default tables happen against all shards.
|
50
|
+
# this is handled automatically for the default migration tasks, below.
|
51
|
+
def self.shardify_task(task_name, categories: [:default])
|
48
52
|
old_task = ::Rake::Task[task_name]
|
49
53
|
old_actions = old_task.actions.dup
|
50
54
|
old_task.actions.clear
|
@@ -57,7 +61,8 @@ module Switchman
|
|
57
61
|
|
58
62
|
::Shackles.activate(:deploy) do
|
59
63
|
begin
|
60
|
-
|
64
|
+
categories = categories.call if categories.respond_to?(:call)
|
65
|
+
Shard.with_each_shard(scope, categories, options) do
|
61
66
|
shard = Shard.current
|
62
67
|
puts "#{shard.id}: #{shard.description}"
|
63
68
|
::ActiveRecord::Base.connection_pool.spec.config[:shard_name] = Shard.current.name
|
@@ -75,7 +80,9 @@ module Switchman
|
|
75
80
|
end
|
76
81
|
end
|
77
82
|
|
78
|
-
%w{db:migrate db:migrate:up db:migrate:down db:rollback}.each
|
83
|
+
%w{db:migrate db:migrate:up db:migrate:down db:rollback}.each do |task_name|
|
84
|
+
shardify_task(task_name, categories: ->{ Shard.categories })
|
85
|
+
end
|
79
86
|
|
80
87
|
private
|
81
88
|
|
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.
|
4
|
+
version: 1.6.0
|
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: 2016-09-
|
13
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
228
|
rubyforge_project:
|
229
|
-
rubygems_version: 2.
|
229
|
+
rubygems_version: 2.4.5.1
|
230
230
|
signing_key:
|
231
231
|
specification_version: 4
|
232
232
|
summary: Rails 4 sharding magic
|