kicks 3.0.0 → 3.1.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
  SHA256:
3
- metadata.gz: 62b5aae734e0e7237bed20813f45ab770136c2f1a4f5f0c137fabbb7daadacd9
4
- data.tar.gz: 2ca16ea532e55ac103d746d13be9a47584f4eecbfbd0c06b4d00e98c52cf3fad
3
+ metadata.gz: 5ccc9ea63784a73fbeddcce04080502702a7313867998bd41ef1322654a97a88
4
+ data.tar.gz: f986416420a86a75817fa8ae44750543349b19d1cce5db162d68da9c7d261f8f
5
5
  SHA512:
6
- metadata.gz: 290d6959875e848c3020237cb0bfc6a0c5da65ee031b25425f1f628f4c9059ae5a2d72e340cc9d6682416ff5c2dbf47d3174c58ecedae82fbdde6c50e80804df
7
- data.tar.gz: 8637779203b7f44d6ec0b506c9fba2de3d8ac6419d2772635a6f81044ba925a2d0acbbbd8103b58c090735b86cea8a92608d73550b4d07c862eb1f7916953c7c
6
+ metadata.gz: ff97a24291dde8fb237d6e54318de1dfdf53a40361dc4172ec117a93027ffc49082e5c041a46617c628073004367985cfc866be356e7592e6fd5913e57ac2a1c
7
+ data.tar.gz: 819e52775f26c55fede5697467cd7154db41e5ce86f7e00eddeb260e8b1f0e922688bb241b4c71e08fb0a17f98541989fa23963867fd4cbaab6d8f7f2a20339c
data/ChangeLog.md CHANGED
@@ -1,10 +1,45 @@
1
1
  # Change Log
2
2
 
3
- ## Changes Between 2.12.0 and 2.13.0 (unreleased)
3
+ ## Changes Between 3.1.0 and 3.1.1 (Nov 1, 2024)
4
+
5
+ ### ActiveJob Adapter Compatibility with Ruby on Rails Older Than 7.2
6
+
7
+ Contributed by @dixpac.
8
+
9
+ GitHub issue: [#19](https://github.com/ruby-amqp/kicks/pull/19)
10
+
11
+
12
+ ## Changes Between 3.0.0 and 3.1.0 (Oct 20, 2024)
13
+
14
+ ### ActiveJob Adapter
15
+
16
+ Kicks now ships with an ActiveJob adapter for Ruby on Rails.
17
+
18
+ Contributed by @dixpac.
19
+
20
+ GitHub issue: [#12](https://github.com/ruby-amqp/kicks/pull/12)
21
+
22
+ ### Make Queue Binding Optional
23
+
24
+ It is now possible to opt out of binding of the Kicks-declared exchange and queue.
25
+
26
+ Contributed by @texpert.
27
+
28
+ GitHub issue: [#13](https://github.com/ruby-amqp/kicks/pull/13)
29
+
30
+
31
+ ## Changes Between 2.12.0 and 3.0.0 (Oct 19, 2024)
32
+
33
+ ### New Project Name and Major Version
34
+
35
+ Kicks was originally developed by @jondot under the [name of Sneakers](https://github.com/jondot/sneakers).
36
+
37
+ After a group of users and a RabbitMQ core team member have taken over maintenance, it was renamed
38
+ to Kicks and the version was bumped to 3.0 to clearly indicate the split.
4
39
 
5
40
  ### Minimum Required Ruby Version
6
41
 
7
- Sneakers now requires Ruby 2.5 or later.
42
+ Kicks now requires Ruby 2.5 or later.
8
43
 
9
44
  ### Content Encoding Support
10
45
 
@@ -14,6 +49,7 @@ Contributed by @ansoncat.
14
49
 
15
50
  GitHub issue: [#449](https://github.com/jondot/sneakers/pull/449)
16
51
 
52
+
17
53
  ## Changes Between 2.10.0 and 2.11.0
18
54
 
19
55
  This releases includes bug fixes, support for more queue-binding options, better
data/LICENSE.txt CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2013-2016 Dotan Nahum
1
+ Copyright (c) 2013-2023 Dotan Nahum
2
+ Copyright (c) 2023-2024 Kicks Contributors
2
3
 
3
4
  MIT License
4
5
 
data/README.md CHANGED
@@ -25,20 +25,19 @@ By virtue of its Sneakers lineage, Kicks is a mature project that has been aroun
25
25
  Add this line to your application's Gemfile:
26
26
 
27
27
  ```ruby
28
- # Important: this name will change once Kicks 3.0.0 (the initial release) is published
29
- gem 'sneakers'
28
+ gem 'kicks'
30
29
  ```
31
30
 
32
31
  And then execute:
33
32
 
34
33
  ```shell-session
35
- $ bundle
34
+ bundle
36
35
  ```
37
36
 
38
37
  Or install it yourself as:
39
38
 
40
39
  ```shell-session
41
- $ gem install sneakers
40
+ gem install kicks
42
41
  ```
43
42
 
44
43
  ## Documentation
@@ -57,7 +56,7 @@ Set up a Gemfile
57
56
 
58
57
  ```ruby
59
58
  source 'https://rubygems.org'
60
- gem 'sneakers'
59
+ gem 'kicks'
61
60
  gem 'json'
62
61
  gem 'redis'
63
62
  ```
@@ -68,6 +67,7 @@ then create a worker named as `Processor`.
68
67
  > touch boot.rb
69
68
 
70
69
  ```ruby
70
+ # Note: the files still use "sneakers" for the name
71
71
  require 'sneakers'
72
72
  require 'redis'
73
73
  require 'json'
@@ -191,7 +191,9 @@ environment needed locally on your development box.
191
191
 
192
192
  # Compatibility
193
193
 
194
- * Sneakers main branch: Ruby 3.0+
194
+ * Kicks main branch: Ruby 3.0+
195
+ * Kicks 3.1.x branch: Ruby 3.0+
196
+ * Kicks 3.0.x: Ruby 2.5+
195
197
  * Sneakers 2.7.x and later (using Bunny 2.9): Ruby 2.2.x
196
198
  * Sneakers 1.1.x and later (using Bunny 2.x): Ruby 2.x
197
199
  * Sneakers 1.x.x and earlier: Ruby 1.9.x, 2.x
data/kicks.gemspec CHANGED
@@ -25,12 +25,14 @@ Gem::Specification.new do |gem|
25
25
  gem.require_paths = ['lib']
26
26
 
27
27
  gem.add_dependency 'serverengine', '~> 2.1'
28
- gem.add_dependency 'bunny', '~> 2.23'
28
+ gem.add_dependency 'bunny', '~> 2.19'
29
29
  gem.add_dependency 'concurrent-ruby', '~> 1.0'
30
30
  gem.add_dependency 'thor'
31
31
  gem.add_dependency 'rake', '>= 12.3', '< 14.0'
32
32
 
33
33
  # for integration environment (see .travis.yml and integration_spec)
34
+ gem.add_development_dependency 'activejob', '>= 7.2'
35
+ gem.add_development_dependency 'activesupport', '>= 7.2'
34
36
  gem.add_development_dependency 'rabbitmq_http_api_client'
35
37
  gem.add_development_dependency 'redis'
36
38
 
@@ -0,0 +1,41 @@
1
+ if defined?(ActiveJob) && ActiveJob.version >= "7.2"
2
+ module ActiveJob
3
+ module QueueAdapters
4
+ # Explicitly remove the implementation existing in older Rails versions'.
5
+ remove_const(:SneakersAdapter) if defined?("::#{name}::SneakersAdapter")
6
+
7
+ # = Sneakers adapter for Active Job
8
+ #
9
+ # To use Sneakers set the queue_adapter config to +:sneakers+.
10
+ #
11
+ # Rails.application.config.active_job.queue_adapter = :sneakers
12
+ class SneakersAdapter < ::ActiveJob::QueueAdapters::AbstractAdapter
13
+ def initialize
14
+ @monitor = Monitor.new
15
+ end
16
+
17
+ def enqueue(job)
18
+ @monitor.synchronize do
19
+ JobWrapper.from_queue job.queue_name
20
+ JobWrapper.enqueue ActiveSupport::JSON.encode(job.serialize)
21
+ end
22
+ end
23
+
24
+ def enqueue_at(job, timestamp)
25
+ raise NotImplementedError, 'This queueing backend does not support scheduling jobs.'
26
+ end
27
+
28
+ class JobWrapper
29
+ include Sneakers::Worker
30
+ from_queue 'default'
31
+
32
+ def work(msg)
33
+ job_data = ActiveSupport::JSON.decode(msg)
34
+ Base.execute job_data
35
+ ack!
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Sneakers
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.1"
3
3
  end
data/lib/sneakers.rb CHANGED
@@ -22,6 +22,8 @@ require 'sneakers/content_encoding'
22
22
  require 'sneakers/middleware/config'
23
23
  require 'sneakers/worker'
24
24
  require 'sneakers/publisher'
25
+ require 'active_job/queue_adapters/sneakers_adapter' if defined?(ActiveJob)
26
+
25
27
 
26
28
  module Sneakers
27
29
  extend self
@@ -0,0 +1,13 @@
1
+ require 'sneakers'
2
+ require 'redis'
3
+
4
+ redis_addr = compose_or_localhost('redis')
5
+ puts "REDIS is at #{redis_addr}"
6
+ $redis = Redis.new(host: redis_addr)
7
+
8
+
9
+ class TestJob < ActiveJob::Base
10
+ def perform(message)
11
+ $redis.incr('rails_active_job')
12
+ end
13
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'sneakers'
3
+ require 'sneakers/runner'
4
+ require 'rabbitmq/http/client'
5
+ require 'active_job'
6
+ require 'active_job/queue_adapters/sneakers_adapter'
7
+ require 'fixtures/test_job'
8
+
9
+ describe 'ActiveJob integration' do
10
+ before :each do
11
+ skip unless ENV['INTEGRATION']
12
+ prepare
13
+ end
14
+
15
+ def integration_log(msg)
16
+ puts msg if ENV['INTEGRATION_LOG']
17
+ end
18
+
19
+ def rmq_addr
20
+ @rmq_addr ||= compose_or_localhost('rabbitmq')
21
+ end
22
+
23
+ def prepare
24
+ ActiveJob::Base.queue_adapter = :sneakers
25
+
26
+ Sneakers.clear!
27
+ Sneakers.configure(amqp: "amqp://guest:guest@#{rmq_addr}:5672")
28
+ Sneakers.logger.level = Logger::ERROR
29
+
30
+ redis_addr = compose_or_localhost('redis')
31
+ @redis = Redis.new(host: redis_addr)
32
+ @redis.del('rails_active_job')
33
+ end
34
+
35
+ def wait_for_jobs_to_finish
36
+ sleep 5
37
+ end
38
+
39
+ def start_active_job_workers
40
+ integration_log 'starting ActiveJob workers.'
41
+ runner = Sneakers::Runner.new([ActiveJob::QueueAdapters::SneakersAdapter::JobWrapper], {})
42
+
43
+ pid = fork { runner.run }
44
+
45
+ integration_log 'waiting for workers to stabilize (5s).'
46
+ sleep 5
47
+
48
+ yield if block_given?
49
+ ensure
50
+ Process.kill('TERM', pid) rescue nil
51
+ end
52
+
53
+ it 'runs jobs enqueued on a listening queue' do
54
+ start_active_job_workers do
55
+ TestJob.perform_later('Hello Rails!')
56
+ wait_for_jobs_to_finish
57
+ assert_equal @redis.get('rails_active_job').to_i, 1
58
+ end
59
+ end
60
+
61
+ it 'scheduling jobs are not supported' do
62
+ assert_raises NotImplementedError, 'This queueing backend does not support scheduling jobs.' do
63
+ TestJob.set(wait: 1.second).perform_later('Say Hello to Rails later!')
64
+ end
65
+ end
66
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kicks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dotan Nahum
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-19 00:00:00.000000000 Z
12
+ date: 2024-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: serverengine
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.23'
34
+ version: '2.19'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.23'
41
+ version: '2.19'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: concurrent-ruby
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +87,34 @@ dependencies:
87
87
  - - "<"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '14.0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: activejob
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '7.2'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '7.2'
104
+ - !ruby/object:Gem::Dependency
105
+ name: activesupport
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '7.2'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '7.2'
90
118
  - !ruby/object:Gem::Dependency
91
119
  name: rabbitmq_http_api_client
92
120
  requirement: !ruby/object:Gem::Requirement
@@ -258,6 +286,7 @@ files:
258
286
  - examples/title_scraper.rb
259
287
  - examples/workflow_worker.rb
260
288
  - kicks.gemspec
289
+ - lib/active_job/queue_adapters/sneakers_adapter.rb
261
290
  - lib/sneakers.rb
262
291
  - lib/sneakers/cli.rb
263
292
  - lib/sneakers/concerns/logging.rb
@@ -289,7 +318,9 @@ files:
289
318
  - scripts/local_worker
290
319
  - spec/fixtures/integration_worker.rb
291
320
  - spec/fixtures/require_worker.rb
321
+ - spec/fixtures/test_job.rb
292
322
  - spec/gzip_helper.rb
323
+ - spec/sneakers/active_job_integration_spec.rb
293
324
  - spec/sneakers/cli_spec.rb
294
325
  - spec/sneakers/concerns/logging_spec.rb
295
326
  - spec/sneakers/concerns/metrics_spec.rb
@@ -334,7 +365,9 @@ summary: Fast background processing framework for Ruby and RabbitMQ
334
365
  test_files:
335
366
  - spec/fixtures/integration_worker.rb
336
367
  - spec/fixtures/require_worker.rb
368
+ - spec/fixtures/test_job.rb
337
369
  - spec/gzip_helper.rb
370
+ - spec/sneakers/active_job_integration_spec.rb
338
371
  - spec/sneakers/cli_spec.rb
339
372
  - spec/sneakers/concerns/logging_spec.rb
340
373
  - spec/sneakers/concerns/metrics_spec.rb