totoro 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/generators/totoro/templates/totoro.yml +12 -11
- data/lib/totoro/base_worker.rb +13 -0
- data/lib/totoro/config.rb +10 -2
- data/lib/totoro/services/subscribe_service.rb +4 -2
- data/lib/totoro/version.rb +1 -1
- data/pkg/totoro-1.0.4.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5eec7c12e6dde49a945a21c48be6db1a773b28e1a1cceb5bc1dd8f63c741d15
|
4
|
+
data.tar.gz: 44c24808e0603cecdf0883a9df55681487830d48aecbc38ac8c8db6fac93666d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c8e432b961bc807045d60587983aae53e663ec8e9b78d0e92f8c3c1aa09dc583574a06a3b14c220eb573971145010940bb90e521dacd0b17bd35004738f22d
|
7
|
+
data.tar.gz: 067b6429ee06870dc084f4671c7581c81223d9219b6e46359e68b11545329a78a154d6b62402db99ad1e8f2bf5f386736686a010c033244f0663404dbc35c28a
|
data/README.md
CHANGED
@@ -28,6 +28,11 @@ This command will generate two files
|
|
28
28
|
2. `initilizers/totoro.rb` (Rails initializer)
|
29
29
|
3. `db/migrate/[tiemstamp]_create_totoro_failed_messages.rb` (DB migration to create messages caching table)
|
30
30
|
|
31
|
+
#### if you havn't install gem delayed_jobs, then run initialization scripts
|
32
|
+
```
|
33
|
+
rails g delayed_job:active_record
|
34
|
+
```
|
35
|
+
|
31
36
|
#### Run DB migraion
|
32
37
|
`rake db:migrate`
|
33
38
|
|
@@ -1,15 +1,16 @@
|
|
1
1
|
default: &default
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
connect:
|
3
|
+
host: rabbitmq
|
4
|
+
port: 5672
|
5
|
+
user: app
|
6
|
+
pass: app
|
7
|
+
queue:
|
8
|
+
example_queue:
|
9
|
+
name: real.queue.name
|
10
|
+
durable: true
|
11
|
+
clean_start: false
|
12
|
+
manual_ack: true
|
13
|
+
force_ack: true
|
13
14
|
|
14
15
|
custom:
|
15
16
|
connect:
|
data/lib/totoro/base_worker.rb
CHANGED
@@ -26,6 +26,9 @@ module Totoro
|
|
26
26
|
payload_hash = JSON.parse(payload).with_indifferent_access
|
27
27
|
process(payload_hash, metadata, delivery_info)
|
28
28
|
end
|
29
|
+
|
30
|
+
handle_usr1_n_usr2
|
31
|
+
|
29
32
|
subscribe_service.channel.work_pool.join
|
30
33
|
rescue SignalException
|
31
34
|
puts 'Terminating process ..'
|
@@ -37,6 +40,16 @@ module Totoro
|
|
37
40
|
|
38
41
|
private
|
39
42
|
|
43
|
+
def handle_usr1_n_usr2
|
44
|
+
%w[USR1 USR2].each do |signal|
|
45
|
+
Signal.trap(signal) do
|
46
|
+
puts "#{signal} received."
|
47
|
+
handler = "on_#{signal.downcase}"
|
48
|
+
send handler if respond_to?(handler)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
40
53
|
def config
|
41
54
|
@config ||= Totoro::Config.new(@prefix)
|
42
55
|
end
|
data/lib/totoro/config.rb
CHANGED
@@ -23,8 +23,16 @@ module Totoro
|
|
23
23
|
@data[:queue][queue_id][:exchange]
|
24
24
|
end
|
25
25
|
|
26
|
-
def clean_start?
|
27
|
-
|
26
|
+
def clean_start?(id)
|
27
|
+
!!@data[:queue][id][:clean_start]
|
28
|
+
end
|
29
|
+
|
30
|
+
def manual_ack?(id)
|
31
|
+
!!@data[:queue][id][:manual_ack]
|
32
|
+
end
|
33
|
+
|
34
|
+
def force_ack?(id)
|
35
|
+
manual_ack?(id) && !!@data[:queue][id][:force_ack]
|
28
36
|
end
|
29
37
|
|
30
38
|
def queue(id)
|
@@ -8,9 +8,11 @@ module Totoro
|
|
8
8
|
|
9
9
|
def subscribe(id)
|
10
10
|
queue = bind_queue(id)
|
11
|
-
queue.purge if @config.clean_start?
|
12
|
-
queue.subscribe do |delivery_info, metadata, payload|
|
11
|
+
queue.purge if @config.clean_start?(id)
|
12
|
+
queue.subscribe(manual_ack: @config.manual_ack?(id)) do |delivery_info, metadata, payload|
|
13
13
|
yield(delivery_info, metadata, payload)
|
14
|
+
ensure
|
15
|
+
channel.ack(delivery_info.delivery_tag) if @config.force_ack?(id)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
data/lib/totoro/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: totoro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BlockchainTech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/totoro/tasks/resend_message.rake
|
140
140
|
- lib/totoro/utils.rb
|
141
141
|
- lib/totoro/version.rb
|
142
|
+
- pkg/totoro-1.0.4.gem
|
142
143
|
- spec/spec_helper.rb
|
143
144
|
- spec/totoro_spec.rb
|
144
145
|
- test/rabbitmq_commands.txt
|