barbeque_client 0.9.1 → 0.10.0

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
- SHA1:
3
- metadata.gz: 6d6d90f5591143367ca2599bbdd7be7aba7b778e
4
- data.tar.gz: bba82d410d8a01c60d6fe38ec5958e61cb72d497
2
+ SHA256:
3
+ metadata.gz: d48cc489c84d703adcc61ce78a13d4bc965ca7cffe29ae75596f8e25147671f6
4
+ data.tar.gz: 6e3d9e47c80f061eb14fde4c135a490da9e859b593a0016293f69aa97d0c6e91
5
5
  SHA512:
6
- metadata.gz: 16195a2a5f380e24448f63045372fdf2cfd1d21749fee2231f83f54b53eec74002bbabff50118169cbf970ad6cd7bfe74597d0cb015b4133136607a3a17cdba1
7
- data.tar.gz: 1ce68df8f09245e83d5f6c40ff2afa115d903d4581586a95943cf9bacf8556ffdec9f7ec50b592b1d557e33509dca5ebfafc517f90df450fefe836f41c94a88f
6
+ metadata.gz: 46d4e41a1148c6baa7348b2aa5c897d4ca3d91c0c8b45ce2efd5850f5946907feb705db8aed9a33c2d6ab5a4222af3eb9ab015eac45cd21cb07f95dfcbff7a32
7
+ data.tar.gz: 1508a6d730ed77f8c4825a97b6f3619e824d410b911ad693033e83849a8d96aec90c6e9e0adbc9c381821c0e1c31e5a57a478f6ef9ebbf67383a93bebb9d853d
@@ -8,7 +8,6 @@ rvm:
8
8
  - 2.4.0
9
9
  - 2.3.1
10
10
  - 2.2.5
11
- - 2.1.10
12
11
  script:
13
12
  - bundle exec rake
14
13
  matrix:
@@ -0,0 +1,22 @@
1
+ ## v0.10.0 (2018-08-24)
2
+ - Add documentation for ActiveJob adapter
3
+ - Drop support for Ruby 2.1
4
+ - Support delay_seconds parameter
5
+ - Also supports ActiveJob's enqueue_at method
6
+ - Requires Barbeque >= v2.5.0
7
+
8
+ ## v0.9.1 (2017-06-19)
9
+ - Fix NoMethodError in distributed tracing
10
+
11
+ ## v0.9.0 (2017-05-30)
12
+ - Support distributed tracing
13
+ - See https://github.com/cookpad/barbeque_client#distributed-tracing for details.
14
+
15
+ ## v0.8.2 (2017-03-17)
16
+ - Add `fields` option to Client#execution
17
+
18
+ ## v0.8.1 (2017-03-14)
19
+ - Add naive status management in barbeque:runner
20
+
21
+ ## v0.8.0 (2016-09-01)
22
+ - Initial release
data/README.md CHANGED
@@ -28,6 +28,7 @@ execution = BarbequeClient.enqueue(
28
28
  job: 'NotifyAuthor', # @param [String] job - Job name to enqueue.
29
29
  message: { user_id: 7553989 }, # @param [Object] message - An object which is serializable as JSON.
30
30
  queue: 'default', # @param optional [String] queue - A queue name to enqueue a job.
31
+ delay_seconds: 0, # @param optional [Integer] delay_seconds - Message timer of SQS.
31
32
  )
32
33
  execution.message_id #=> "a3c653c1-335e-4d4d-a6f9-eb91c0253d02"
33
34
  execution.status #=> "pending"
@@ -40,6 +41,21 @@ message_id = "a3c653c1-335e-4d4d-a6f9-eb91c0253d02"
40
41
  BarbequeClient.status(message_id: message_id) #=> "success"
41
42
  ```
42
43
 
44
+ ### With Rails
45
+
46
+ Barbeque client has adapter for ActiveJob.
47
+
48
+ ```rb
49
+ # config/environments/some_environment.rb
50
+ Rails.application.config.active_job.queue_adapter = :barbeque
51
+ ```
52
+
53
+ And everything will be ok. Don't forget to setup `config.application` and `config.endpoint` in somewhere.
54
+ One more thing, `config.default_queue` option is meaningless with Rails.
55
+ `default_queue` is the fallback option for enqueueing without specified queue name.
56
+ However, ActiveJob always set default queue as 'default' internally,
57
+ there is no place to work on. So please use [`queue_as`](http://api.rubyonrails.org/classes/ActiveJob/QueueName/ClassMethods.html#method-i-queue_as) when you want to use different queue name.
58
+
43
59
  ### Distributed tracing
44
60
  Configure `tracing` option. Pick one of supported tracers.
45
61
  See more detail in https://github.com/cookpad/garage_client#tracing.
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'garage_client'
23
23
  spec.add_development_dependency 'bundler', '~> 1.11'
24
24
  spec.add_development_dependency 'pry'
25
- spec.add_development_dependency 'rails', '~> 4.2'
25
+ spec.add_development_dependency 'rails', '~> 5.1'
26
26
  spec.add_development_dependency 'rake', '~> 10.0'
27
27
  spec.add_development_dependency 'rspec', '~> 3.0'
28
28
  spec.add_development_dependency 'rspec-rails'
@@ -6,6 +6,10 @@ module ActiveJob
6
6
  BarbequeAdapter.enqueue(job)
7
7
  end
8
8
 
9
+ def enqueue_at(job, timestamp)
10
+ BarbequeAdapter.enqueue_at(job, timestamp)
11
+ end
12
+
9
13
  class << self
10
14
  # Interface for ActiveJob 4.2
11
15
  def enqueue(job)
@@ -18,9 +22,14 @@ module ActiveJob
18
22
  end
19
23
 
20
24
  def enqueue_at(job, timestamp)
21
- raise NotImplementedError.new(
22
- 'Currently setting timestamp is not supported'
25
+ delay_seconds = (timestamp - Time.now.to_f).round
26
+ execution = BarbequeClient.enqueue(
27
+ job: job.class.to_s,
28
+ message: ActiveJob::Arguments.serialize(job.arguments),
29
+ queue: job.queue_name,
30
+ delay_seconds: delay_seconds,
23
31
  )
32
+ job.job_id = execution.message_id
24
33
  end
25
34
  end
26
35
  end
@@ -23,12 +23,14 @@ module BarbequeClient
23
23
  # @param [String] job - Job name to enqueue.
24
24
  # @param [Object] message - An object which is serializable as JSON.
25
25
  # @param optional [String] queue - A queue name to enqueue a job.
26
+ # @param optional [Integer] delay_seconds - Message timer of SQS.
26
27
  # @return [Hashie::Mash] resonse - { message_id: String, status: String }
27
- def enqueue(job:, message:, queue: nil)
28
+ def enqueue(job:, message:, queue: nil, delay_seconds: nil)
28
29
  response = client.create_execution(
29
30
  job: job,
30
31
  message: message,
31
32
  queue: queue,
33
+ delay_seconds: delay_seconds,
32
34
  )
33
35
  response.body
34
36
  end
@@ -13,13 +13,15 @@ module BarbequeClient
13
13
  # @param [String] job - Job name to enqueue.
14
14
  # @param [Object] message - An object which is serializable as JSON.
15
15
  # @param optional [String] queue - A queue name to enqueue a job.
16
+ # @param optional [Integer] delay_seconds - Message timer of SQS.
16
17
  # @return [Faraday::Response]
17
- def create_execution(job:, message:, queue: nil)
18
+ def create_execution(job:, message:, queue: nil, delay_seconds: nil)
18
19
  params = {
19
20
  application: @application,
20
21
  job: job,
21
22
  message: message,
22
23
  queue: queue || @default_queue,
24
+ delay_seconds: delay_seconds,
23
25
  }
24
26
  result = garage_client.post('/v2/job_executions', params)
25
27
  result.response
@@ -1,3 +1,3 @@
1
1
  module BarbequeClient
2
- VERSION = '0.9.1'
2
+ VERSION = '0.10.0'
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.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-19 00:00:00.000000000 Z
11
+ date: 2018-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: garage_client
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.2'
61
+ version: '5.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.2'
68
+ version: '5.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +118,7 @@ files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
120
  - ".travis.yml"
121
+ - CHANGELOG.md
121
122
  - Gemfile
122
123
  - LICENSE.txt
123
124
  - README.md
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  version: '0'
157
158
  requirements: []
158
159
  rubyforge_project:
159
- rubygems_version: 2.6.11
160
+ rubygems_version: 2.7.6
160
161
  signing_key:
161
162
  specification_version: 4
162
163
  summary: Barbeque client for Ruby