barbeque 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +24 -0
- data/app/assets/config/barbeque_manifest.js +2 -0
- data/app/assets/javascripts/barbeque/application.js +13 -0
- data/app/assets/stylesheets/barbeque/application.css +15 -0
- data/app/controllers/barbeque/application_controller.rb +5 -0
- data/app/helpers/barbeque/application_helper.rb +4 -0
- data/app/jobs/barbeque/application_job.rb +4 -0
- data/app/mailers/barbeque/application_mailer.rb +6 -0
- data/app/models/api/application_resource.rb +10 -0
- data/app/models/api/job_execution_resource.rb +7 -0
- data/app/models/api/job_retry_resource.rb +7 -0
- data/app/models/app.rb +8 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/barbeque/application_record.rb +5 -0
- data/app/models/job_definition.rb +14 -0
- data/app/models/job_execution.rb +22 -0
- data/app/models/job_queue.rb +19 -0
- data/app/models/job_retry.rb +17 -0
- data/app/models/slack_notification.rb +5 -0
- data/app/views/layouts/barbeque/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20160217020910_create_job_queues.rb +12 -0
- data/db/migrate/20160219010912_create_job_executions.rb +11 -0
- data/db/migrate/20160223060807_create_apps.rb +12 -0
- data/db/migrate/20160223183348_create_job_definitions.rb +13 -0
- data/db/migrate/20160225020801_add_job_definition_id_to_job_executions.rb +6 -0
- data/db/migrate/20160412083604_add_finished_at_to_job_executions.rb +5 -0
- data/db/migrate/20160415043427_create_slack_notifications.rb +12 -0
- data/db/migrate/20160509041452_add_job_queue_id_to_job_executions.rb +5 -0
- data/db/migrate/20160516041710_create_job_retries.rb +13 -0
- data/lib/barbeque.rb +5 -0
- data/lib/barbeque/engine.rb +5 -0
- data/lib/barbeque/version.rb +3 -0
- data/lib/tasks/barbeque_tasks.rake +4 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e46d5b56b2da9d6dd1f8a969884b89d9279e45c6
|
4
|
+
data.tar.gz: 7cd2c731b320400a63b45b709599b73c8801199b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43b4573b33bdfc1178a034fa6e88e3ad016db86cd360d6789095579716641bceb5cac6703de07ac3ad521fa9fb34df579d15381b877bc0d166dfafd213ed96e7
|
7
|
+
data.tar.gz: 7e5f93abd4464bfbac2d6c52051c9ca38eefb89d9ea2e1f83f8b13e4ddde596b1bc77ff8c5838a8131a540c7f281b6010ed3a16808fdd662ea826b7ecfbc6618
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Takashi Kokubun
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Barbeque
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'barbeque'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install barbeque
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Barbeque'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
load 'rails/tasks/statistics.rake'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
require 'bundler/gem_tasks'
|
24
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
data/app/models/app.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class JobDefinition < ApplicationRecord
|
2
|
+
belongs_to :app
|
3
|
+
has_many :job_executions, dependent: :destroy
|
4
|
+
has_one :slack_notification, dependent: :destroy
|
5
|
+
|
6
|
+
validates :job, uniqueness: { scope: :app_id }
|
7
|
+
|
8
|
+
attr_readonly :app_id
|
9
|
+
attr_readonly :job
|
10
|
+
|
11
|
+
serialize :command, Array
|
12
|
+
|
13
|
+
accepts_nested_attributes_for :slack_notification, allow_destroy: true
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'job_executor/storage'
|
2
|
+
|
3
|
+
class JobExecution < ApplicationRecord
|
4
|
+
belongs_to :job_definition
|
5
|
+
belongs_to :job_queue
|
6
|
+
has_one :slack_notification, through: :job_definition
|
7
|
+
has_one :app, through: :job_definition
|
8
|
+
has_many :job_retries
|
9
|
+
|
10
|
+
enum status: {
|
11
|
+
pending: 0,
|
12
|
+
success: 1,
|
13
|
+
failed: 2,
|
14
|
+
retried: 3,
|
15
|
+
}
|
16
|
+
|
17
|
+
paginates_per 15
|
18
|
+
|
19
|
+
def to_resource
|
20
|
+
Api::JobExecutionResource.new(self)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class JobQueue < ApplicationRecord
|
2
|
+
SQS_NAME_PREFIX = ENV['BARBEQUE_SQS_NAME_PREFIX'] || 'Barbeque-'
|
3
|
+
SQS_NAME_MAX_LENGTH = 80
|
4
|
+
|
5
|
+
# All SQS queues' "ReceiveMessageWaitTimeSeconds" are configured to be 20s (maximum).
|
6
|
+
# This should be as large as possible to reduce API-calling cost by long polling.
|
7
|
+
# http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html#API_CreateQueue_RequestParameters
|
8
|
+
SQS_RECEIVE_MESSAGE_WAIT_TIME = 20
|
9
|
+
|
10
|
+
# SQS queue allows [a-zA-Z0-9_-]+ as queue name. Its maximum length is 80.
|
11
|
+
validates :name, presence: true, uniqueness: true, format: /\A[a-zA-Z0-9_-]+\z/,
|
12
|
+
length: { maximum: SQS_NAME_MAX_LENGTH - SQS_NAME_PREFIX.length }
|
13
|
+
|
14
|
+
attr_readonly :name
|
15
|
+
|
16
|
+
def sqs_queue_name
|
17
|
+
SQS_NAME_PREFIX + name
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class JobRetry < ApplicationRecord
|
2
|
+
belongs_to :job_execution
|
3
|
+
has_one :job_definition, through: :job_execution
|
4
|
+
has_one :app, through: :job_definition
|
5
|
+
has_one :slack_notification, through: :job_execution
|
6
|
+
|
7
|
+
enum status: {
|
8
|
+
pending: 0,
|
9
|
+
success: 1,
|
10
|
+
failed: 2,
|
11
|
+
retried: 3,
|
12
|
+
}
|
13
|
+
|
14
|
+
def to_resource
|
15
|
+
Api::JobRetryResource.new(self)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Barbeque</title>
|
5
|
+
<%= stylesheet_link_tag "barbeque/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "barbeque/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateJobQueues < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :job_queues, options: 'ENGINE=InnoDB ROW_FORMAT=dynamic DEFAULT CHARSET=utf8mb4' do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.text :description
|
6
|
+
t.string :queue_url, null: false
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :job_queues, [:name], unique: true
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateJobExecutions < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :job_executions, options: 'ENGINE=InnoDB ROW_FORMAT=dynamic DEFAULT CHARSET=utf8mb4' do |t|
|
4
|
+
t.string :message_id, null: false
|
5
|
+
t.integer :status, null: false, default: 0
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :job_executions, [:message_id], unique: true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateApps < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :apps, options: 'ENGINE=InnoDB ROW_FORMAT=dynamic DEFAULT CHARSET=utf8mb4' do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :docker_image, null: false
|
6
|
+
t.text :description
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :apps, [:name], unique: true
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateJobDefinitions < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :job_definitions, options: 'ENGINE=InnoDB ROW_FORMAT=dynamic DEFAULT CHARSET=utf8mb4' do |t|
|
4
|
+
t.string :job, null: false
|
5
|
+
t.integer :app_id, null: false
|
6
|
+
t.string :command, null: false
|
7
|
+
t.text :description
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :job_definitions, [:job, :app_id], unique: true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateSlackNotifications < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :slack_notifications, options: 'ENGINE=InnoDB ROW_FORMAT=dynamic DEFAULT CHARSET=utf8mb4' do |t|
|
4
|
+
t.integer :job_definition_id
|
5
|
+
t.string :channel, null: false
|
6
|
+
t.boolean :notify_success, default: false, null: false
|
7
|
+
t.string :failure_notification_text
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateJobRetries < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :job_retries, options: 'ENGINE=InnoDB ROW_FORMAT=dynamic DEFAULT CHARSET=utf8mb4' do |t|
|
4
|
+
t.string :message_id, null: false
|
5
|
+
t.integer :job_execution_id, null: false
|
6
|
+
t.integer :status, null: false, default: 0
|
7
|
+
t.datetime :finished_at
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :job_retries, [:message_id], unique: true
|
12
|
+
end
|
13
|
+
end
|
data/lib/barbeque.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: barbeque
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takashi Kokubun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: the_garage
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mysql2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: barbeque engine
|
56
|
+
email:
|
57
|
+
- takashi-kokubun@cookpad.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/assets/config/barbeque_manifest.js
|
66
|
+
- app/assets/javascripts/barbeque/application.js
|
67
|
+
- app/assets/stylesheets/barbeque/application.css
|
68
|
+
- app/controllers/barbeque/application_controller.rb
|
69
|
+
- app/helpers/barbeque/application_helper.rb
|
70
|
+
- app/jobs/barbeque/application_job.rb
|
71
|
+
- app/mailers/barbeque/application_mailer.rb
|
72
|
+
- app/models/api/application_resource.rb
|
73
|
+
- app/models/api/job_execution_resource.rb
|
74
|
+
- app/models/api/job_retry_resource.rb
|
75
|
+
- app/models/app.rb
|
76
|
+
- app/models/application_record.rb
|
77
|
+
- app/models/barbeque/application_record.rb
|
78
|
+
- app/models/job_definition.rb
|
79
|
+
- app/models/job_execution.rb
|
80
|
+
- app/models/job_queue.rb
|
81
|
+
- app/models/job_retry.rb
|
82
|
+
- app/models/slack_notification.rb
|
83
|
+
- app/views/layouts/barbeque/application.html.erb
|
84
|
+
- config/routes.rb
|
85
|
+
- db/migrate/20160217020910_create_job_queues.rb
|
86
|
+
- db/migrate/20160219010912_create_job_executions.rb
|
87
|
+
- db/migrate/20160223060807_create_apps.rb
|
88
|
+
- db/migrate/20160223183348_create_job_definitions.rb
|
89
|
+
- db/migrate/20160225020801_add_job_definition_id_to_job_executions.rb
|
90
|
+
- db/migrate/20160412083604_add_finished_at_to_job_executions.rb
|
91
|
+
- db/migrate/20160415043427_create_slack_notifications.rb
|
92
|
+
- db/migrate/20160509041452_add_job_queue_id_to_job_executions.rb
|
93
|
+
- db/migrate/20160516041710_create_job_retries.rb
|
94
|
+
- lib/barbeque.rb
|
95
|
+
- lib/barbeque/engine.rb
|
96
|
+
- lib/barbeque/version.rb
|
97
|
+
- lib/tasks/barbeque_tasks.rake
|
98
|
+
homepage:
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.5.1
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: barbeque engine
|
122
|
+
test_files: []
|
123
|
+
has_rdoc:
|