barbeque_client 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6af93b3528723f585a7877985325b6767ebf6924
4
- data.tar.gz: cfa14afd2152039fecc9d8c82b60a37b67efca3d
3
+ metadata.gz: 3c21ee3226f87115866285b97b0fb1c5a73531a3
4
+ data.tar.gz: ed2455539ef02b004efbb67c83f8f189da3483af
5
5
  SHA512:
6
- metadata.gz: ac6983702e340af395f84936868183abbd8ea0c4b947ee44f04533215a833bafed0038d7bbe582ca8ff5b7ca137b9d773478108655701281ef850a2746411c2d
7
- data.tar.gz: 407c2073c7d61819028ffd0a1db5ce20a59c2b613e65a8bcc6a4076d35f0f3fc93ce91bd34fae65c711a65c278ad7c54f23a679162bbc3208e682787f4099be0
6
+ metadata.gz: bbb35487c1688529afc76152c163dadd175e5112ce581f9875de509edf0356c81bf6c3b2f4544f22a4a95fc031763a49f3383707929dc67d875e18bcfa559be8
7
+ data.tar.gz: c0f93a5b37c4a3ab1ed2d3e58d4218db3afdc6c5841c04d07f728ecd62c67e67d2a86349c42dbd8c952bb4ef9c28304b9d4f164d9f3778de6b8ec3dc344e068d
data/.travis.yml CHANGED
@@ -1,4 +1,16 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ branches:
4
+ only:
5
+ - master
2
6
  rvm:
3
- - 2.2.3
4
- before_install: gem install bundler -v 1.11.2
7
+ - ruby-head
8
+ - 2.4.0
9
+ - 2.3.1
10
+ - 2.2.5
11
+ - 2.1.10
12
+ script:
13
+ - bundle exec rake
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: ruby-head
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in barbeque.gemspec
3
+ # Specify your gem's dependencies in barbeque_client.gemspec
4
4
  gemspec
5
5
 
6
6
  gem 'pry-byebug'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # BarbequeClient
1
+ # BarbequeClient [![Build Status](https://travis-ci.org/cookpad/barbeque_client.svg?branch=master)](https://travis-ci.org/cookpad/barbeque_client)
2
2
 
3
- BarbequeClient client for Ruby.
3
+ Barbeque client for Ruby.
4
4
 
5
5
  ## Installation
6
6
 
File without changes
@@ -7,28 +7,63 @@ module BarbequeClient
7
7
  class Runner < Sinatra::Base
8
8
  set :port, ENV['PORT'] || 3003
9
9
 
10
+ class << self
11
+ # global variable
12
+ def messages
13
+ @messages ||= {}
14
+ end
15
+ end
16
+
10
17
  post '/v1/job_executions' do
11
18
  params = JSON.parse(request.body.read)
12
- spawn(
19
+ message_id = SecureRandom.uuid
20
+ pid = spawn(
13
21
  'bundle', 'exec', 'rake', 'barbeque:execute',
22
+ "BARBEQUE_MESSAGE_ID=#{message_id}",
14
23
  "BARBEQUE_JOB=#{params['job']}", "BARBEQUE_MESSAGE=#{params['message']}",
15
24
  "BARBEQUE_RETRY_COUNT=0",
25
+ in: :close
16
26
  )
27
+ Runner.messages[message_id] = Process.detach(pid)
17
28
 
18
29
  content_type :json
19
- { status: 'pending', message_id: SecureRandom.uuid }.to_json
30
+ { status: 'pending', message_id: message_id }.to_json
20
31
  end
21
32
 
22
33
  post '/v2/job_executions' do
23
34
  params = JSON.parse(request.body.read)
24
- spawn(
35
+ message_id = SecureRandom.uuid
36
+ pid = spawn(
25
37
  'bundle', 'exec', 'rake', 'barbeque:execute',
38
+ "BARBEQUE_MESSAGE_ID=#{message_id}",
26
39
  "BARBEQUE_JOB=#{params['job']}", "BARBEQUE_MESSAGE=#{params['message'].to_json}",
27
40
  "BARBEQUE_RETRY_COUNT=0",
41
+ in: :close
28
42
  )
43
+ Runner.messages[message_id] = Process.detach(pid)
29
44
 
30
45
  content_type :json
31
- { status: 'pending', message_id: SecureRandom.uuid }.to_json
46
+ { status: 'pending', message_id: message_id }.to_json
47
+ end
48
+
49
+ get '/v1/job_executions/:message_id' do
50
+ message_id = params['message_id']
51
+ wait_thr = Runner.messages[message_id]
52
+
53
+ status = if wait_thr.nil?
54
+ 'pending'
55
+ elsif wait_thr.alive?
56
+ 'working'
57
+ else
58
+ if wait_thr.value.exitstatus == 0
59
+ 'success'
60
+ else
61
+ 'failed'
62
+ end
63
+ end
64
+
65
+ content_type :json
66
+ { status: status, message_id: message_id }.to_json
32
67
  end
33
68
 
34
69
  post '/v1/job_executions/:message_id/retries' do
@@ -1,3 +1,3 @@
1
1
  module BarbequeClient
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barbeque_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: garage_client
@@ -122,7 +122,7 @@ files:
122
122
  - LICENSE.txt
123
123
  - README.md
124
124
  - Rakefile
125
- - barbeque.gemspec
125
+ - barbeque_client.gemspec
126
126
  - bin/console
127
127
  - bin/setup
128
128
  - lib/active_job/queue_adapters/barbeque_adapter.rb
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.5.1
159
+ rubygems_version: 2.6.8
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: Barbeque client for Ruby