kicks 3.0.0.pre → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +3 -5
- data/ChangeLog.md +34 -2
- data/Gemfile +1 -1
- data/LICENSE.txt +2 -1
- data/README.md +15 -8
- data/kicks.gemspec +3 -0
- data/lib/active_job/queue_adapters/sneakers_adapter.rb +39 -0
- data/lib/sneakers/queue.rb +2 -1
- data/lib/sneakers/version.rb +1 -1
- data/lib/sneakers.rb +2 -0
- data/spec/fixtures/test_job.rb +13 -0
- data/spec/sneakers/active_job_integration_spec.rb +66 -0
- metadata +39 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b553911947a5b50df9d2576610c02c448873a359bf8641116c3bdaeb10539fd4
|
4
|
+
data.tar.gz: 8fd78e33555ba42a001781c204ca22e9e875a22d96eb53374dcc1a3d0af2ac06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf96bb1a274d3ad4da6f904c6395156541b750a78d20130226e3404f00f97853a71a0327db11b96193affe54a94217b909600ffb9c9e8527c3bcb5b88e51590b
|
7
|
+
data.tar.gz: 0244cdda5904875397992237239b67649c6c4ef2affb0962a040d8f06849549b816a371280ef870fb04e16db9c768b948c8b96196e75337c3303131b5c333122
|
data/.github/workflows/ci.yml
CHANGED
@@ -8,17 +8,15 @@ jobs:
|
|
8
8
|
runs-on: ubuntu-latest
|
9
9
|
strategy:
|
10
10
|
matrix:
|
11
|
-
ruby-version: [3.0, 3.1, 3.2]
|
11
|
+
ruby-version: [3.0, 3.1, 3.2, 3.3]
|
12
12
|
steps:
|
13
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v4
|
14
14
|
|
15
15
|
- name: Install Ruby ${{ matrix.ruby-version }}
|
16
16
|
uses: ruby/setup-ruby@v1
|
17
17
|
with:
|
18
18
|
ruby-version: ${{ matrix.ruby-version }}
|
19
|
-
|
20
|
-
- name: Install dependencies
|
21
|
-
run: bundle install
|
19
|
+
bundler-cache: true # 'bundle install', cache gems
|
22
20
|
|
23
21
|
- name: Run tests
|
24
22
|
run: bundle exec rake
|
data/ChangeLog.md
CHANGED
@@ -1,10 +1,41 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## Changes Between
|
3
|
+
## Changes Between 3.1.0 and 3.2.0 (in development)
|
4
|
+
|
5
|
+
No changes yet.
|
6
|
+
|
7
|
+
|
8
|
+
## Changes Between 3.0.0 and 3.1.0 (Oct 20, 2024)
|
9
|
+
|
10
|
+
### ActiveJob Adapter
|
11
|
+
|
12
|
+
Kicks now ships with an ActiveJob adapter for Ruby on Rails.
|
13
|
+
|
14
|
+
Contributed by dixpac.
|
15
|
+
|
16
|
+
GitHub issue: [#12](https://github.com/ruby-amqp/kicks/pull/12)
|
17
|
+
|
18
|
+
### Make Queue Binding Optional
|
19
|
+
|
20
|
+
It is now possible to opt out of binding of the Kicks-declared exchange and queue.
|
21
|
+
|
22
|
+
Contributed by @texpert.
|
23
|
+
|
24
|
+
GitHub issue: [#13](https://github.com/ruby-amqp/kicks/pull/13)
|
25
|
+
|
26
|
+
|
27
|
+
## Changes Between 2.12.0 and 3.0.0 (Oct 19, 2024)
|
28
|
+
|
29
|
+
### New Project Name and Major Version
|
30
|
+
|
31
|
+
Kicks was originally developed by @jondot under the [name of Sneakers](https://github.com/jondot/sneakers).
|
32
|
+
|
33
|
+
After a group of users and a RabbitMQ core team member have taken over maintenance, it was renamed
|
34
|
+
to Kicks and the version was bumped to 3.0 to clearly indicate the split.
|
4
35
|
|
5
36
|
### Minimum Required Ruby Version
|
6
37
|
|
7
|
-
|
38
|
+
Kicks now requires Ruby 2.5 or later.
|
8
39
|
|
9
40
|
### Content Encoding Support
|
10
41
|
|
@@ -14,6 +45,7 @@ Contributed by @ansoncat.
|
|
14
45
|
|
15
46
|
GitHub issue: [#449](https://github.com/jondot/sneakers/pull/449)
|
16
47
|
|
48
|
+
|
17
49
|
## Changes Between 2.10.0 and 2.11.0
|
18
50
|
|
19
51
|
This releases includes bug fixes, support for more queue-binding options, better
|
data/Gemfile
CHANGED
@@ -3,6 +3,6 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'ruby-prof', platforms: [:ruby_22, :ruby_23, :ruby_24]
|
4
4
|
|
5
5
|
gem 'rake', '>= 12.3', '< 14.0'
|
6
|
-
gem 'metric_fu',
|
6
|
+
gem 'metric_fu', git: 'https://github.com/metricfu/metric_fu', branch: 'main'
|
7
7
|
|
8
8
|
gemspec
|
data/LICENSE.txt
CHANGED
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
|
-
|
29
|
-
gem 'sneakers'
|
28
|
+
gem 'kicks'
|
30
29
|
```
|
31
30
|
|
32
31
|
And then execute:
|
33
32
|
|
34
33
|
```shell-session
|
35
|
-
|
34
|
+
bundle
|
36
35
|
```
|
37
36
|
|
38
37
|
Or install it yourself as:
|
39
38
|
|
40
39
|
```shell-session
|
41
|
-
|
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 '
|
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
|
-
*
|
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
|
@@ -204,6 +206,11 @@ Fork, implement, add tests, pull request, get my everlasting thanks and a respec
|
|
204
206
|
|
205
207
|
To all Sneakers [Contributors](https://github.com/jondot/sneakers/graphs/contributors) - you make this happen, thanks!
|
206
208
|
|
207
|
-
|
209
|
+
## License
|
208
210
|
|
209
|
-
|
211
|
+
See [LICENSE](LICENSE.txt) for further details.
|
212
|
+
|
213
|
+
## Copyright
|
214
|
+
|
215
|
+
Copyright (c) 2023-2024 Kicks contributors
|
216
|
+
Copyright (c) 2015-2023 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot).
|
data/kicks.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.description = %q( Fast background processing framework for Ruby and RabbitMQ )
|
14
14
|
gem.summary = %q( Fast background processing framework for Ruby and RabbitMQ )
|
15
15
|
gem.homepage = 'https://github.com/ruby-amqp/kicks'
|
16
|
+
gem.metadata = { "source_code_uri" => "https://github.com/ruby-amqp/kicks" }
|
16
17
|
gem.license = 'MIT'
|
17
18
|
gem.required_ruby_version = Gem::Requirement.new(">= 2.5")
|
18
19
|
|
@@ -30,6 +31,8 @@ Gem::Specification.new do |gem|
|
|
30
31
|
gem.add_dependency 'rake', '>= 12.3', '< 14.0'
|
31
32
|
|
32
33
|
# for integration environment (see .travis.yml and integration_spec)
|
34
|
+
gem.add_development_dependency 'activejob', '>= 7.1'
|
35
|
+
gem.add_development_dependency 'activesupport', '>= 7.1'
|
33
36
|
gem.add_development_dependency 'rabbitmq_http_api_client'
|
34
37
|
gem.add_development_dependency 'redis'
|
35
38
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ActiveJob
|
2
|
+
module QueueAdapters
|
3
|
+
# Explicitly remove the implementation existing in older rails'.
|
4
|
+
remove_const(:SneakersAdapter) if defined?(:SneakersAdapter)
|
5
|
+
|
6
|
+
# = Sneakers adapter for Active Job
|
7
|
+
#
|
8
|
+
# To use Sneakers set the queue_adapter config to +:sneakers+.
|
9
|
+
#
|
10
|
+
# Rails.application.config.active_job.queue_adapter = :sneakers
|
11
|
+
class SneakersAdapter < ::ActiveJob::QueueAdapters::AbstractAdapter
|
12
|
+
def initialize
|
13
|
+
@monitor = Monitor.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def enqueue(job)
|
17
|
+
@monitor.synchronize do
|
18
|
+
JobWrapper.from_queue job.queue_name
|
19
|
+
JobWrapper.enqueue ActiveSupport::JSON.encode(job.serialize)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def enqueue_at(job, timestamp)
|
24
|
+
raise NotImplementedError, 'This queueing backend does not support scheduling jobs.'
|
25
|
+
end
|
26
|
+
|
27
|
+
class JobWrapper
|
28
|
+
include Sneakers::Worker
|
29
|
+
from_queue 'default'
|
30
|
+
|
31
|
+
def work(msg)
|
32
|
+
job_data = ActiveSupport::JSON.decode(msg)
|
33
|
+
Base.execute job_data
|
34
|
+
ack!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/sneakers/queue.rb
CHANGED
@@ -39,7 +39,8 @@ class Sneakers::Queue
|
|
39
39
|
|
40
40
|
queue = @channel.queue(@name, **@opts[:queue_options])
|
41
41
|
|
42
|
-
|
42
|
+
should_bind = @opts.fetch(:bind, true)
|
43
|
+
if should_bind && exchange_name.length > 0
|
43
44
|
routing_keys.each do |key|
|
44
45
|
if @opts[:bind_arguments]
|
45
46
|
queue.bind(@exchange, routing_key: key, arguments: @opts[:bind_arguments])
|
data/lib/sneakers/version.rb
CHANGED
data/lib/sneakers.rb
CHANGED
@@ -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.
|
4
|
+
version: 3.1.0
|
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-
|
12
|
+
date: 2024-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: serverengine
|
@@ -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.1'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '7.1'
|
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.1'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '7.1'
|
90
118
|
- !ruby/object:Gem::Dependency
|
91
119
|
name: rabbitmq_http_api_client
|
92
120
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +263,7 @@ executables:
|
|
235
263
|
extensions: []
|
236
264
|
extra_rdoc_files: []
|
237
265
|
files:
|
266
|
+
- ".github/dependabot.yml"
|
238
267
|
- ".github/workflows/ci.yml"
|
239
268
|
- ".gitignore"
|
240
269
|
- ChangeLog.md
|
@@ -257,6 +286,7 @@ files:
|
|
257
286
|
- examples/title_scraper.rb
|
258
287
|
- examples/workflow_worker.rb
|
259
288
|
- kicks.gemspec
|
289
|
+
- lib/active_job/queue_adapters/sneakers_adapter.rb
|
260
290
|
- lib/sneakers.rb
|
261
291
|
- lib/sneakers/cli.rb
|
262
292
|
- lib/sneakers/concerns/logging.rb
|
@@ -288,7 +318,9 @@ files:
|
|
288
318
|
- scripts/local_worker
|
289
319
|
- spec/fixtures/integration_worker.rb
|
290
320
|
- spec/fixtures/require_worker.rb
|
321
|
+
- spec/fixtures/test_job.rb
|
291
322
|
- spec/gzip_helper.rb
|
323
|
+
- spec/sneakers/active_job_integration_spec.rb
|
292
324
|
- spec/sneakers/cli_spec.rb
|
293
325
|
- spec/sneakers/concerns/logging_spec.rb
|
294
326
|
- spec/sneakers/concerns/metrics_spec.rb
|
@@ -309,7 +341,8 @@ files:
|
|
309
341
|
homepage: https://github.com/ruby-amqp/kicks
|
310
342
|
licenses:
|
311
343
|
- MIT
|
312
|
-
metadata:
|
344
|
+
metadata:
|
345
|
+
source_code_uri: https://github.com/ruby-amqp/kicks
|
313
346
|
post_install_message:
|
314
347
|
rdoc_options: []
|
315
348
|
require_paths:
|
@@ -325,14 +358,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
325
358
|
- !ruby/object:Gem::Version
|
326
359
|
version: '0'
|
327
360
|
requirements: []
|
328
|
-
rubygems_version: 3.5.
|
361
|
+
rubygems_version: 3.5.22
|
329
362
|
signing_key:
|
330
363
|
specification_version: 4
|
331
364
|
summary: Fast background processing framework for Ruby and RabbitMQ
|
332
365
|
test_files:
|
333
366
|
- spec/fixtures/integration_worker.rb
|
334
367
|
- spec/fixtures/require_worker.rb
|
368
|
+
- spec/fixtures/test_job.rb
|
335
369
|
- spec/gzip_helper.rb
|
370
|
+
- spec/sneakers/active_job_integration_spec.rb
|
336
371
|
- spec/sneakers/cli_spec.rb
|
337
372
|
- spec/sneakers/concerns/logging_spec.rb
|
338
373
|
- spec/sneakers/concerns/metrics_spec.rb
|