multiple_man_sidekiq 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb72cba09743e8cd396a6cd6c3da033949ab0923
4
- data.tar.gz: efff996987f9d433a9d33d33cf9693c7a6b56e49
3
+ metadata.gz: f520d675d7ac188ff4388dc0be7f69af2db22321
4
+ data.tar.gz: 69cac6997fbc895958aaa2e790ee8f1bb989ad4b
5
5
  SHA512:
6
- metadata.gz: 908c63321f598482f312eb5de900848a33b888e301a1f4530b72bb9f74942554e1177f3e82b8d06bf5253c52a89ea59a05385be19dd818d26ebaad371a259d4a
7
- data.tar.gz: a637990898fb704ec83ddf104c2ef6c9dd293a9ca48586b2a1f81834f8db1ea52e80414f218f507455a4418540b3ed1add9267d5460f2fae57ab7bb4145bf7c7
6
+ metadata.gz: e03d4ce118de6eff69a26dc02ec7b2e5fd4507abd3ba5c62a47846e31e667b5ddb85af8b1674106ee6d8795c74a5268217f13351b6db7991ba3236cdf707bb95
7
+ data.tar.gz: a87b47ae2f4b4f930098a0a4016483de7c410a297ac76bae862d1e83284036192d2dbcf7412ba26e40bd12388d5fac17d8653afbaccf26fc0554aa5c4fb565b7
@@ -14,7 +14,10 @@ module MultipleMan
14
14
  klass = records.class.name
15
15
  end
16
16
 
17
- ModelPublisherJob.perform_async(klass, ids, options, operation)
17
+ # Split jobs into parts so sidekiq doesn't need to deal with enormous seed jobs.
18
+ ids.each_slice(1000) do |ids|
19
+ ModelPublisherJob.perform_async(klass, ids, options, operation)
20
+ end
18
21
  end
19
22
 
20
23
  end
@@ -0,0 +1,23 @@
1
+ module MultipleMan
2
+ class SidekiqMiddleware
3
+ def call(worker, job, queue)
4
+ establish_channel if is_middleman_job?
5
+ yield
6
+ ensure
7
+ close_channel if is_middleman_job?
8
+ end
9
+
10
+ def establish_channel
11
+ Thread.local[:multiple_man_connection] = MultipleMan::Connection.new
12
+ end
13
+
14
+ def close_channel
15
+ connection = Thread.local[:multiple_man_connection]
16
+ connection.close_channel if connection && connection.open_channel?
17
+ end
18
+
19
+ def is_middleman_job?
20
+ worker.kind_of? MultipleMan::ModelPublisherJob
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module MultipleManSidekiq
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiple_man_sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - Rakefile
82
82
  - lib/multiple_man_sidekiq.rb
83
83
  - lib/multiple_man_sidekiq/async_model_publisher.rb
84
+ - lib/multiple_man_sidekiq/middleware/sidekiq_middleware.rb
84
85
  - lib/multiple_man_sidekiq/mixins/async_publisher.rb
85
86
  - lib/multiple_man_sidekiq/version.rb
86
87
  - multiple_man_sidekiq.gemspec