shinq 0.6.0 → 0.7.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/shinq/cli.rb +4 -0
- data/lib/shinq/configuration.rb +12 -3
- data/lib/shinq/launcher.rb +13 -6
- data/shinq.gemspec +1 -1
- data/spec/shinq/configuration_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 655d145ff88397bca387abccd196c36888428e21
|
4
|
+
data.tar.gz: 41df3f27cc6b3af3fa50a5fa2d3d0ab0da24293d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10c3396b0201a6d678c8be2fb172c885e58ef13a14c56ffc7f5c4af37f95e9af579c60bda6a3236112bf3b95fd98d27ac4b07f88fc2250736a7b964113aa77c8
|
7
|
+
data.tar.gz: 6307bd0ce80f84e26b4e9cbfd11f2e463ba9f933bffa3149d9f275117bb5103ebf9174a7d632d6f83445516f10699ed91e2eef20accaefb2882e0df9e117e667
|
data/lib/shinq/cli.rb
CHANGED
data/lib/shinq/configuration.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
1
|
module Shinq
|
2
2
|
class ConfigurationError < StandardError; end
|
3
3
|
|
4
|
+
# @!attribute abort_on_error
|
5
|
+
# @return [Boolean] Whether do +queue_abort()+ on performing failure.
|
6
|
+
# @see Shinq::Launcher#run
|
7
|
+
#
|
8
|
+
# Defaults to +true+, which means that worker do +queue_end()+ AFTER it proceeds a job.
|
9
|
+
# If it is +false+, worker do +queue_end()+ BEFORE it proceeds a job.
|
10
|
+
# You may need to set it +false+ for jobs which take very long time to proceed.
|
11
|
+
# You may also need to handle performing error manually then.
|
4
12
|
class Configuration
|
5
|
-
attr_accessor :require, :worker_name, :db_config, :queue_db, :default_db, :process, :queue_timeout, :daemonize, :statistics, :lifecycle
|
13
|
+
attr_accessor :require, :worker_name, :db_config, :queue_db, :default_db, :process, :queue_timeout, :daemonize, :statistics, :lifecycle, :abort_on_error
|
6
14
|
|
7
15
|
DEFAULT = {
|
8
16
|
require: '.',
|
9
17
|
process: 1,
|
10
18
|
queue_timeout: 1,
|
11
|
-
daemonize: false
|
19
|
+
daemonize: false,
|
20
|
+
abort_on_error: true
|
12
21
|
}
|
13
22
|
|
14
23
|
def initialize(opts)
|
15
|
-
%i(require worker_name db_config queue_db default_db process queue_timeout daemonize statistics lifecycle).each do |k|
|
24
|
+
%i(require worker_name db_config queue_db default_db process queue_timeout daemonize statistics lifecycle abort_on_error).each do |k|
|
16
25
|
send(:"#{k}=", opts[k] || DEFAULT[k])
|
17
26
|
end
|
18
27
|
end
|
data/lib/shinq/launcher.rb
CHANGED
@@ -3,6 +3,8 @@ require 'active_support/inflector'
|
|
3
3
|
|
4
4
|
module Shinq
|
5
5
|
module Launcher
|
6
|
+
# Wait configured queue and proceed each of them until stop.
|
7
|
+
# @see Shinq::Configuration#abort_on_error
|
6
8
|
def run
|
7
9
|
worker_name = Shinq.configuration.worker_name
|
8
10
|
worker_class = worker_name.camelize.constantize
|
@@ -13,15 +15,20 @@ module Shinq
|
|
13
15
|
queue = Shinq::Client.dequeue(table_name: worker_name.pluralize)
|
14
16
|
next Shinq.logger.info("Queue is empty (#{Time.now})") unless queue
|
15
17
|
|
16
|
-
|
18
|
+
if Shinq.configuration.abort_on_error
|
19
|
+
begin
|
20
|
+
worker_class.new.perform(queue)
|
21
|
+
rescue => e
|
22
|
+
Shinq::Client.abort
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
|
26
|
+
Shinq::Client.done
|
27
|
+
else
|
28
|
+
Shinq::Client.done
|
17
29
|
worker_class.new.perform(queue)
|
18
|
-
rescue => e
|
19
|
-
Shinq::Client.abort
|
20
|
-
raise e
|
21
30
|
end
|
22
31
|
|
23
|
-
Shinq::Client.done
|
24
|
-
|
25
32
|
@loop_count += 1
|
26
33
|
|
27
34
|
if lifecycle_limit?
|
data/shinq.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "shinq"
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.7.0'
|
8
8
|
spec.authors = ["Ryoichi SEKIGUCHI"]
|
9
9
|
spec.email = ["ryopeko@gmail.com"]
|
10
10
|
spec.summary = %q{Worker and enqueuer for Q4M using the interface of ActiveJob.}
|
@@ -15,6 +15,7 @@ describe Shinq::Configuration do
|
|
15
15
|
it { is_expected.to respond_to(:daemonize) }
|
16
16
|
it { is_expected.to respond_to(:statistics) }
|
17
17
|
it { is_expected.to respond_to(:lifecycle) }
|
18
|
+
it { is_expected.to respond_to(:abort_on_error) }
|
18
19
|
end
|
19
20
|
|
20
21
|
describe ".new" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shinq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryoichi SEKIGUCHI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|