barbeque 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/barbeque/job_queue.rb +1 -0
- data/lib/barbeque/execution_poller.rb +4 -2
- data/lib/barbeque/message_queue.rb +2 -2
- data/lib/barbeque/retry_poller.rb +10 -2
- data/lib/barbeque/runner.rb +4 -6
- data/lib/barbeque/version.rb +1 -1
- data/lib/barbeque/worker.rb +8 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a27e1555a662fc67cff6d20504bff8e7649f761c4c7500e14f8200347a822ee
|
4
|
+
data.tar.gz: 535818478a8701f4c1e00f9600328b9e0e2d6c7ccd45ca16e3851319ac8a4676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768ca47dc94d8479804de1a4c9ddbb3f989732eddbb9c8eb2bbc9778503c076d965929a8a5990e663209ea78e87ca61a62cbd874f2d42876018ba339f15031a9
|
7
|
+
data.tar.gz: d916df13c88917745c35e1e32c09b1e0c5d2ad1c2801abee8ec35ec2004d07f9048d1372bdf182652e89966c0249608bf2dabc7d0389d9eecac8708aa78cbcf3
|
@@ -2,6 +2,7 @@ class Barbeque::JobQueue < Barbeque::ApplicationRecord
|
|
2
2
|
SQS_NAME_PREFIX = ENV['BARBEQUE_SQS_NAME_PREFIX'] || 'Barbeque-'
|
3
3
|
SQS_NAME_MAX_LENGTH = 80
|
4
4
|
|
5
|
+
has_many :job_executions, dependent: :destroy
|
5
6
|
has_many :sns_subscriptions, class_name: 'SNSSubscription', dependent: :destroy
|
6
7
|
|
7
8
|
# SQS queue allows [a-zA-Z0-9_-]+ as queue name. Its maximum length is 80.
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'barbeque/exception_handler'
|
2
|
+
require 'barbeque/executor'
|
2
3
|
|
3
4
|
module Barbeque
|
4
5
|
class ExecutionPoller
|
5
|
-
def initialize
|
6
|
+
def initialize(job_queue)
|
7
|
+
@job_queue = job_queue
|
6
8
|
@stop_requested = false
|
7
9
|
end
|
8
10
|
|
9
11
|
def run
|
10
|
-
|
12
|
+
@job_queue.job_executions.running.find_in_batches do |job_executions|
|
11
13
|
job_executions.shuffle.each do |job_execution|
|
12
14
|
if @stop_requested
|
13
15
|
return
|
@@ -1,11 +1,19 @@
|
|
1
|
+
require 'barbeque/exception_handler'
|
2
|
+
require 'barbeque/executor'
|
3
|
+
|
1
4
|
module Barbeque
|
2
5
|
class RetryPoller
|
3
|
-
def initialize
|
6
|
+
def initialize(job_queue)
|
7
|
+
@job_queue = job_queue
|
4
8
|
@stop_requested = false
|
5
9
|
end
|
6
10
|
|
7
11
|
def run
|
8
|
-
Barbeque::JobRetry
|
12
|
+
Barbeque::JobRetry
|
13
|
+
.joins(:job_execution)
|
14
|
+
.running
|
15
|
+
.merge(Barbeque::JobExecution.where(job_queue: @job_queue))
|
16
|
+
.find_in_batches do |job_retries|
|
9
17
|
job_retries.shuffle.each do |job_retry|
|
10
18
|
if @stop_requested
|
11
19
|
return
|
data/lib/barbeque/runner.rb
CHANGED
@@ -10,10 +10,8 @@ module Barbeque
|
|
10
10
|
# it to message handler.
|
11
11
|
|
12
12
|
class Runner
|
13
|
-
|
14
|
-
|
15
|
-
def initialize(queue_name: ENV['BARBEQUE_QUEUE'] || DEFAULT_QUEUE)
|
16
|
-
@queue_name = queue_name
|
13
|
+
def initialize(job_queue)
|
14
|
+
@job_queue = job_queue
|
17
15
|
end
|
18
16
|
|
19
17
|
def run
|
@@ -34,7 +32,7 @@ module Barbeque
|
|
34
32
|
private
|
35
33
|
|
36
34
|
def message_queue
|
37
|
-
@message_queue ||= MessageQueue.new(@
|
35
|
+
@message_queue ||= MessageQueue.new(@job_queue)
|
38
36
|
end
|
39
37
|
|
40
38
|
def keep_maximum_concurrent_executions
|
@@ -45,7 +43,7 @@ module Barbeque
|
|
45
43
|
end
|
46
44
|
|
47
45
|
loop do
|
48
|
-
current_num =
|
46
|
+
current_num = @job_queue.job_executions.where(status: [:running, :retried]).count
|
49
47
|
if current_num < max_num
|
50
48
|
return
|
51
49
|
end
|
data/lib/barbeque/version.rb
CHANGED
data/lib/barbeque/worker.rb
CHANGED
@@ -6,6 +6,8 @@ require 'serverengine'
|
|
6
6
|
|
7
7
|
module Barbeque
|
8
8
|
module Worker
|
9
|
+
DEFAULT_QUEUE = ENV['BARBEQUE_DEFAULT_QUEUE'] || 'default'
|
10
|
+
|
9
11
|
class UnexpectedMessageType < StandardError; end
|
10
12
|
|
11
13
|
def self.run(
|
@@ -32,14 +34,17 @@ module Barbeque
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def initialize
|
37
|
+
queue_name = ENV['BARBEQUE_QUEUE'] || DEFAULT_QUEUE
|
38
|
+
queue = Barbeque::JobQueue.find_by!(name: queue_name)
|
39
|
+
|
35
40
|
@command =
|
36
41
|
case worker_id
|
37
42
|
when 0
|
38
|
-
ExecutionPoller.new
|
43
|
+
ExecutionPoller.new(queue)
|
39
44
|
when 1
|
40
|
-
RetryPoller.new
|
45
|
+
RetryPoller.new(queue)
|
41
46
|
else
|
42
|
-
Runner.new
|
47
|
+
Runner.new(queue)
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barbeque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adminlte2-rails
|
@@ -263,7 +263,7 @@ dependencies:
|
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
|
-
name:
|
266
|
+
name: factory_bot_rails
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
269
|
- - ">="
|
@@ -470,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
470
470
|
version: '0'
|
471
471
|
requirements: []
|
472
472
|
rubyforge_project:
|
473
|
-
rubygems_version: 2.7.
|
473
|
+
rubygems_version: 2.7.6
|
474
474
|
signing_key:
|
475
475
|
specification_version: 4
|
476
476
|
summary: Job queue system to run job with Docker
|