parallel_workforce 1.0.0 → 2.0.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 +5 -5
- data/.gitignore +1 -0
- data/.rubocop_parallel_workforce.yml +7 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/parallel_workforce.rb +9 -1
- data/lib/parallel_workforce/configuration.rb +1 -1
- data/lib/parallel_workforce/executor.rb +2 -2
- data/lib/parallel_workforce/requires.rb +1 -0
- data/lib/parallel_workforce/serializer/json_marshal.rb +17 -0
- data/lib/parallel_workforce/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9ef8716bb08d920fb76459016cdb615f50d89e5604066ff01ad723d2b4fb03b4
|
4
|
+
data.tar.gz: 6263caa320d791299cfe76e399f26c23d49414ca8536cef25358fc10dfc5f8a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb0c64bd4fa27720d5db3d174cee1d2954ffba8cbdcc7153c1f644eada79440a8340a49f703f3a32cabb12f6bfbd71f7b9a7a64d7667b9c69a75b54be035b6e
|
7
|
+
data.tar.gz: 2529e7806726359ecd5ca4c5c994863b57eb029576bd1e94577f2dbe658df0cccdccd3a45909384fd6551c2b0b59fb4fb11f1e5a8f3ebf619226a1a2fe2c9e12
|
data/.gitignore
CHANGED
@@ -135,7 +135,13 @@ Style/GuardClause:
|
|
135
135
|
Style/IfUnlessModifier:
|
136
136
|
Enabled: false
|
137
137
|
|
138
|
-
Layout/
|
138
|
+
Layout/IndentFirstArgument:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
Naming/RescuedExceptionsVariableName:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
Layout/IndentFirstArrayElement:
|
139
145
|
EnforcedStyle: consistent
|
140
146
|
|
141
147
|
Layout/MultilineOperationIndentation:
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.6.6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
|
3
|
+
* Ruby version tested is 2.6.6.
|
4
|
+
* Include result_values as part of TimeoutError to allow access to partial results that did not timeout.
|
5
|
+
* Default to using JsonMarshal serialization that serializes as a JSON string for Sidekiq compataibility.
|
6
|
+
|
7
|
+
## 1.0.0
|
8
|
+
|
9
|
+
* RubyGems version 1.
|
10
|
+
|
1
11
|
## 0.2.0
|
2
12
|
|
3
13
|
* Add optional execution block to `ParallelWorkforce.perform_all` that is evaluated in calling thread after jobs enqueued,
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Easily parallelize functionality by partitioning work in either a Sidekiq (preferred) or ActiveJob worker pool.
|
4
4
|
|
5
|
-
See more info at the EnjoyTech blog.
|
5
|
+
See more info on [why Enjoy created this Gem](https://medium.com/enjoy-engineering/ruby-and-rails-can-be-as-fast-as-you-need-if-you-execute-in-parallel-632f2dff5429) at the [EnjoyTech blog](https://medium.com/enjoy-engineering).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -92,7 +92,7 @@ end
|
|
92
92
|
* `logger` - Defaults to `Rails.logger` if `Rails` is loaded.
|
93
93
|
* `revision_builder` - Used to determine if the calling thread and worker have a different revision of code. Defaults to a class that builds a hash from the contents of all `.rb` files contained within the current working directory.
|
94
94
|
* `serial_mode_checker` - An object with an `execute_serially?` method that allows forcing Actors to execute in calling thread instead of in workers. This can be used to turn off parallel execution globally. Default is `nil`.
|
95
|
-
* `serializer` - An object with a `serialize(object)` method that returns a `String` and `deserialize(string)` method that returns an `Object`. Default imlementation uses `Marshal.dump` and `Marshal.load
|
95
|
+
* `serializer` - An object with a `serialize(object)` method that returns a `String` and `deserialize(string)` method that returns an `Object`. Default imlementation uses `Marshal.dump` and `Marshal.load` and serializes as a JSON string for Sidekiq compatibility.
|
96
96
|
* `redis_connector` - An object with a `with` method that yields a Redis connection. Defaults to `ParallelWorkforce::RedisConnector::RedisPool`. If using Sidekiq, it's best to use `ParallelWorkforce::RedisConnector::SidekiqRedisPool`.
|
97
97
|
* `job_timeout` - Time allowed to execte a job before timing out. Default is `10` seconds.
|
98
98
|
* `job_key_expiration` - Time allowed for result key in Redis to remain before it expires. This should be larger than `job_timeout`. Default is `20` seconds.
|
data/lib/parallel_workforce.rb
CHANGED
@@ -4,7 +4,15 @@ module ParallelWorkforce
|
|
4
4
|
Error = Class.new(StandardError)
|
5
5
|
ActorPerformError = Class.new(Error)
|
6
6
|
ActorNotFoundError = Class.new(Error)
|
7
|
-
TimeoutError = Class.new(Error)
|
7
|
+
TimeoutError = Class.new(Error) do
|
8
|
+
attr_reader :result_values
|
9
|
+
|
10
|
+
def initialize(message, result_values=nil)
|
11
|
+
@result_values = result_values
|
12
|
+
|
13
|
+
super(message)
|
14
|
+
end
|
15
|
+
end
|
8
16
|
SerializerError = Class.new(Error)
|
9
17
|
|
10
18
|
class << self
|
@@ -18,7 +18,7 @@ module ParallelWorkforce
|
|
18
18
|
@logger = defined?(Rails) && Rails.logger
|
19
19
|
@revision_builder = ParallelWorkforce::RevisionBuilder::FilesHash.new
|
20
20
|
@serial_mode_checker = nil
|
21
|
-
@serializer = ParallelWorkforce::Serializer::
|
21
|
+
@serializer = ParallelWorkforce::Serializer::JsonMarshal.new
|
22
22
|
@redis_connector = ParallelWorkforce::RedisConnector::RedisPool.new
|
23
23
|
@job_timeout = 10
|
24
24
|
@job_key_expiration = 20
|
@@ -180,7 +180,7 @@ module ParallelWorkforce
|
|
180
180
|
Timeout.timeout(configuration.job_timeout) do
|
181
181
|
until result_count == num_results
|
182
182
|
_key, response = redis.blpop(result_key, configuration.job_timeout)
|
183
|
-
raise ParallelWorkforce::TimeoutError.new("Timeout waiting for Redis#blpop") if response.nil?
|
183
|
+
raise ParallelWorkforce::TimeoutError.new("Timeout waiting for Redis#blpop", result_values) if response.nil?
|
184
184
|
|
185
185
|
result_count += 1
|
186
186
|
|
@@ -190,7 +190,7 @@ module ParallelWorkforce
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
rescue Timeout::Error
|
193
|
-
raise ParallelWorkforce::TimeoutError.new("Timeout from ParallelWorkforce job")
|
193
|
+
raise ParallelWorkforce::TimeoutError.new("Timeout from ParallelWorkforce job", result_values)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -5,6 +5,7 @@ require_relative "job/util/performer"
|
|
5
5
|
require_relative "redis_connector/redis_pool"
|
6
6
|
require_relative "revision_builder/files_hash"
|
7
7
|
require_relative "serializer/marshal"
|
8
|
+
require_relative "serializer/json_marshal"
|
8
9
|
|
9
10
|
# rubocop:disable Lint/HandleExceptions
|
10
11
|
begin
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ParallelWorkforce
|
2
|
+
module Serializer
|
3
|
+
class JsonMarshal < Marshal
|
4
|
+
def serialize(object)
|
5
|
+
JSON.dump(value: super(object)) # super always returns a String
|
6
|
+
end
|
7
|
+
|
8
|
+
def deserialize(string)
|
9
|
+
super(JSON.parse(string)['value'])
|
10
|
+
rescue JSON::ParserError => e
|
11
|
+
ParallelWorkforce.log(:warn, "#{self.class}: Unable to deserialize string: #{e}", e, *e.backtrace)
|
12
|
+
|
13
|
+
raise ParallelWorkforce::SerializerError.new("Unable to deserialize string: #{e}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_workforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Pearce
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/parallel_workforce/redis_connector/sidekiq_redis_pool.rb
|
169
169
|
- lib/parallel_workforce/requires.rb
|
170
170
|
- lib/parallel_workforce/revision_builder/files_hash.rb
|
171
|
+
- lib/parallel_workforce/serializer/json_marshal.rb
|
171
172
|
- lib/parallel_workforce/serializer/marshal.rb
|
172
173
|
- lib/parallel_workforce/version.rb
|
173
174
|
- parallel_workforce.gemspec
|
@@ -178,7 +179,7 @@ metadata:
|
|
178
179
|
homepage_uri: https://github.com/EnjoyTech/parallel_workforce
|
179
180
|
source_code_uri: https://github.com/EnjoyTech/parallel_workforce
|
180
181
|
changelog_uri: https://github.com/EnjoyTech/parallel_workforce/CHANGELOG.md
|
181
|
-
post_install_message:
|
182
|
+
post_install_message:
|
182
183
|
rdoc_options: []
|
183
184
|
require_paths:
|
184
185
|
- lib
|
@@ -193,9 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
194
|
- !ruby/object:Gem::Version
|
194
195
|
version: '0'
|
195
196
|
requirements: []
|
196
|
-
|
197
|
-
|
198
|
-
signing_key:
|
197
|
+
rubygems_version: 3.0.3
|
198
|
+
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Simplify parallel code execution into workers
|
201
201
|
test_files: []
|