pika_que 0.1.0 → 0.1.1
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/README.md +61 -8
- data/lib/active_job/queue_adapters/pika_que_adapter.rb +26 -2
- data/lib/pika_que.rb +2 -0
- data/lib/pika_que/rails.rb +2 -1
- data/lib/pika_que/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39faa9df72e909b96bdc74876b9a68b87d26634c
|
4
|
+
data.tar.gz: edb0a973f47f8b872e1815cd162f42cffd6a9f8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3f5b73288368228458ad5aef2002640447a037fa336866aecd6ff8f5637064b1acca53a6df86ab721601052c8010c0195c908642b5de6c62ab79772561baf4
|
7
|
+
data.tar.gz: 16438758d34dc710056d6c04139d8d68f602ee262495a43b3b20cf0479154c1f1d73ec3cd775e16fdf010fd46d49a9d54381a438924d00a2702b251cf81b3976
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# PikaQue
|
2
2
|
|
3
|
-
|
3
|
+
A RabbitMQ background processing framework for Ruby with built-in support for Rails integration.
|
4
4
|
|
5
|
-
|
5
|
+
PikaQue is inspired by Sneakers, Hutch, and Sidekiq. It is intended to implement more support for Rails a la Sidekiq.
|
6
|
+
It supports retry (both constant and exponential backoffs) and delayed/scheduled execution.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -12,17 +13,69 @@ Add this line to your application's Gemfile:
|
|
12
13
|
gem 'pika_que'
|
13
14
|
```
|
14
15
|
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
16
|
Or install it yourself as:
|
20
17
|
|
21
18
|
$ gem install pika_que
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
To create a worker:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
class PokeWorker
|
26
|
+
include PikaQue::Worker
|
27
|
+
from_queue "rocket"
|
28
|
+
|
29
|
+
def perform(msg)
|
30
|
+
# do something with msg["greeting"]
|
31
|
+
# or below for active job
|
32
|
+
ActiveJob::Base.execute msg
|
33
|
+
ack!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
To enqueue a job:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
PokeWorker.enqueue({ greeting: "I Challenge You!" })
|
42
|
+
```
|
43
|
+
|
44
|
+
To run server:
|
45
|
+
|
46
|
+
$ bundle exec pika_que
|
47
|
+
|
48
|
+
### Rails and ActiveJob
|
49
|
+
|
50
|
+
Create workers in:
|
51
|
+
|
52
|
+
app/workers
|
53
|
+
|
54
|
+
Create a initializer file `pika_que.rb` in:
|
55
|
+
|
56
|
+
config/initializers
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# pika_que.rb
|
60
|
+
|
61
|
+
require 'active_job/queue_adapters/pika_que_adapter'
|
62
|
+
|
63
|
+
# override default queue_name for ActiveJob::Base and ActionMailer::DeliveryJob here if necessary
|
64
|
+
|
65
|
+
# setup workers here or with config/pika_que.yml
|
66
|
+
PikaQue.config.add_processor(workers: [PokeWorker])
|
67
|
+
PikaQue.config[:codec] = PikaQue::Codecs::RAILS
|
68
|
+
```
|
69
|
+
|
70
|
+
Set the backend for active job in `config/application.rb`:
|
71
|
+
|
72
|
+
config.active_job.queue_adapter = :pika_que
|
73
|
+
|
74
|
+
Then run the server.
|
75
|
+
|
76
|
+
## Specs
|
77
|
+
|
78
|
+
Coming soon. See examples for reference.
|
26
79
|
|
27
80
|
## Development
|
28
81
|
|
@@ -32,7 +85,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
85
|
|
33
86
|
## Contributing
|
34
87
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
88
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dwkoogt/pika_que. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
89
|
|
37
90
|
|
38
91
|
## License
|
@@ -14,7 +14,7 @@ module ActiveJob
|
|
14
14
|
#
|
15
15
|
# Rails.application.config.active_job.queue_adapter = :pika_que
|
16
16
|
#
|
17
|
-
class
|
17
|
+
class PikaQueRails4
|
18
18
|
@monitor = Monitor.new
|
19
19
|
|
20
20
|
class << self
|
@@ -37,6 +37,30 @@ module ActiveJob
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
class PikaQueRails5
|
41
|
+
def initialize
|
42
|
+
@monitor = Monitor.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def enqueue(job) #:nodoc:
|
46
|
+
@monitor.synchronize do
|
47
|
+
JobWrapper.enqueue job.serialize, to_queue: job.queue_name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def enqueue_at(job, timestamp) #:nodoc:
|
52
|
+
@monitor.synchronize do
|
53
|
+
JobWrapper.enqueue_at job.serialize, timestamp, routing_key: job.queue_name
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class JobWrapper #:nodoc:
|
58
|
+
extend PikaQue::Worker::ClassMethods
|
59
|
+
config codec: PikaQue::Codecs::RAILS
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
PikaQueAdapter = (::Rails::VERSION::MAJOR < 5) ? PikaQueRails4 : PikaQueRails5
|
64
|
+
|
41
65
|
end
|
42
66
|
end
|
data/lib/pika_que.rb
CHANGED
data/lib/pika_que/rails.rb
CHANGED
@@ -22,7 +22,8 @@ module PikaQue
|
|
22
22
|
if File.exist? config_file
|
23
23
|
PIKA_QUE_CONFIG = YAML.load_file(config_file)
|
24
24
|
else
|
25
|
-
|
25
|
+
mailer_queue = (::Rails::VERSION::MAJOR < 5) ? ActionMailer::DeliveryJob.queue_name : ActionMailer::Base.deliver_later_queue_name
|
26
|
+
PIKA_QUE_CONFIG = { "processors" => [{ "workers" => [{ "queue" => ActiveJob::Base.queue_name }, { "queue" => mailer_queue.to_s }] }] }
|
26
27
|
end
|
27
28
|
|
28
29
|
workers_dir = Rails.root.join('app').join('workers')
|
data/lib/pika_que/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pika_que
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dong Wook Koo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.5.2.2
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Ruby background processor for RabbitMQ.
|