emque-consuming 1.9.0 → 1.9.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/lib/emque/consuming/generators/application.rb +3 -3
- data/lib/emque/consuming/pidfile.rb +2 -2
- data/lib/emque/consuming/transmitter.rb +2 -2
- data/lib/emque/consuming/version.rb +1 -1
- data/spec/pidfile_spec.rb +7 -7
- metadata +14 -33
- data/.github/workflows/ci.yml +0 -27
- data/.gitignore +0 -41
- data/CHANGELOG.md +0 -29
- data/Gemfile +0 -7
- data/LICENSE.txt +0 -22
- data/README.md +0 -223
- data/Rakefile +0 -14
- data/bin/emque +0 -5
- data/emque-consuming.gemspec +0 -36
- data/lib/templates/.gitignore.tt +0 -25
- data/lib/templates/Gemfile.tt +0 -6
- data/lib/templates/Rakefile.tt +0 -7
- data/lib/templates/config/application.rb.tt +0 -42
- data/lib/templates/config/environments/development.rb.tt +0 -2
- data/lib/templates/config/environments/production.rb.tt +0 -2
- data/lib/templates/config/environments/staging.rb.tt +0 -2
- data/lib/templates/config/environments/test.rb.tt +0 -2
- data/lib/templates/config/routes.rb.tt +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259c7b22f2046972a4dc8d74895a876f7b510eeca07ba8ba88c686330070dafa
|
4
|
+
data.tar.gz: ada2575a2efcdbbd39c286bbe0567b14664b8075d62b107a2e3725dac38e1b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96688d19a2253cb72ba318efaa063aaa8a6b0d344d6e494b41378989469e1abfe4eabfa9e53646bb899ce3b3f6b05b325c8828ed432b2f86f14e652acd1ae70
|
7
|
+
data.tar.gz: 5b97bffee37917327ae6e9e48c723099fb734d6afd5c3a1f44c602776b9b1058d2d86c0a564c9fc62cea85d34df025f34448d273bc9ab111b3e8aa7ea23d24fc
|
@@ -54,11 +54,11 @@ module Emque
|
|
54
54
|
unless IGNORE.include?(e)
|
55
55
|
loc = File.join(path, e)
|
56
56
|
|
57
|
-
if Dir.
|
57
|
+
if Dir.exist?(loc)
|
58
58
|
new_nest = nesting + [e]
|
59
59
|
create_path = File.join(*new_nest)
|
60
60
|
|
61
|
-
unless Dir.
|
61
|
+
unless Dir.exist?(create_path)
|
62
62
|
FileUtils.mkdir_p(create_path)
|
63
63
|
puts "created directory #{relative_path(create_path)}"
|
64
64
|
end
|
@@ -72,7 +72,7 @@ module Emque
|
|
72
72
|
display = relative_path(filename)
|
73
73
|
overwrite = "Y"
|
74
74
|
|
75
|
-
if File.
|
75
|
+
if File.exist?(filename)
|
76
76
|
print "#{display} exists, overwrite? (yN) "
|
77
77
|
overwrite = $stdin.gets
|
78
78
|
end
|
@@ -12,7 +12,7 @@ module Emque
|
|
12
12
|
def initialize(path)
|
13
13
|
self.path = path
|
14
14
|
ensure_dir_exists
|
15
|
-
self.pid = File.read(path).to_i if File.
|
15
|
+
self.pid = File.read(path).to_i if File.exist?(path)
|
16
16
|
end
|
17
17
|
|
18
18
|
def running?
|
@@ -47,7 +47,7 @@ module Emque
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def rm_file
|
50
|
-
FileUtils.rm_f(path) if File.
|
50
|
+
FileUtils.rm_f(path) if File.exist?(path)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -6,7 +6,7 @@ module Emque
|
|
6
6
|
module Consuming
|
7
7
|
module Transmitter
|
8
8
|
def self.send(command:, socket_path: "tmp/emque.sock", args: [])
|
9
|
-
if File.
|
9
|
+
if File.exist?(socket_path)
|
10
10
|
socket = UNIXSocket.new(socket_path)
|
11
11
|
socket.send(Oj.dump({
|
12
12
|
:command => command,
|
@@ -19,7 +19,7 @@ module Emque
|
|
19
19
|
"Socket not found at #{socket_path}"
|
20
20
|
end
|
21
21
|
rescue Errno::ECONNREFUSED
|
22
|
-
FileUtils.rm_f(socket_path) if File.
|
22
|
+
FileUtils.rm_f(socket_path) if File.exist?(socket_path)
|
23
23
|
"The UNIX Socket found at #{socket_path} was dead"
|
24
24
|
end
|
25
25
|
|
data/spec/pidfile_spec.rb
CHANGED
@@ -5,9 +5,9 @@ describe Emque::Consuming::Pidfile do
|
|
5
5
|
it "creates a directory to hold the pidfile if it doesn't exist" do
|
6
6
|
path = "spec/dummy/tmp/testingpidpath"
|
7
7
|
pidfile = File.join(path, "pidfile.pid")
|
8
|
-
expect(Dir.
|
8
|
+
expect(Dir.exist?(path)).to eq(false)
|
9
9
|
Emque::Consuming::Pidfile.new(pidfile)
|
10
|
-
expect(Dir.
|
10
|
+
expect(Dir.exist?(path)).to eq(true)
|
11
11
|
FileUtils.rm_rf(path)
|
12
12
|
end
|
13
13
|
|
@@ -35,9 +35,9 @@ describe Emque::Consuming::Pidfile do
|
|
35
35
|
f.write("10000000")
|
36
36
|
end
|
37
37
|
pf = Emque::Consuming::Pidfile.new(pidfile)
|
38
|
-
expect(File.
|
38
|
+
expect(File.exist?(pidfile)).to eq(true)
|
39
39
|
expect(pf.running?).to eq(false)
|
40
|
-
expect(File.
|
40
|
+
expect(File.exist?(pidfile)).to eq(false)
|
41
41
|
FileUtils.rm_rf(path)
|
42
42
|
end
|
43
43
|
end
|
@@ -51,7 +51,7 @@ describe Emque::Consuming::Pidfile do
|
|
51
51
|
f.write(Process.pid)
|
52
52
|
end
|
53
53
|
pf = Emque::Consuming::Pidfile.new(pidfile)
|
54
|
-
expect(File.
|
54
|
+
expect(File.exist?(pidfile)).to eq(true)
|
55
55
|
expect(pf.running?).to eq(true)
|
56
56
|
FileUtils.rm_rf(path)
|
57
57
|
end
|
@@ -64,9 +64,9 @@ describe Emque::Consuming::Pidfile do
|
|
64
64
|
path = "spec/dummy/tmp/testingpidpath"
|
65
65
|
pidfile = File.join(path, "pidfile.pid")
|
66
66
|
pf = Emque::Consuming::Pidfile.new(pidfile)
|
67
|
-
expect(File.
|
67
|
+
expect(File.exist?(pidfile)).to eq(false)
|
68
68
|
pf.write
|
69
|
-
expect(File.
|
69
|
+
expect(File.exist?(pidfile)).to eq(true)
|
70
70
|
expect(File.read(pidfile).chomp).to eq(Process.pid.to_s)
|
71
71
|
FileUtils.rm_rf(path)
|
72
72
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emque-consuming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Williams
|
8
8
|
- Dan Matthews
|
9
9
|
- Paul Hanyzewski
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-09-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: celluloid
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: '3.13'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: '3.13'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: virtus
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,14 +88,14 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
91
|
+
version: 1.0.2
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
98
|
+
version: 1.0.2
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: inflecto
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,14 +172,14 @@ dependencies:
|
|
172
172
|
requirements:
|
173
173
|
- - "~>"
|
174
174
|
- !ruby/object:Gem::Version
|
175
|
-
version: 0.7
|
175
|
+
version: '0.7'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
178
|
version_requirements: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
180
|
- - "~>"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 0.7
|
182
|
+
version: '0.7'
|
183
183
|
- !ruby/object:Gem::Dependency
|
184
184
|
name: daemon_controller
|
185
185
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,23 +194,13 @@ dependencies:
|
|
194
194
|
- - "~>"
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: 1.2.0
|
197
|
-
description:
|
197
|
+
description:
|
198
198
|
email:
|
199
199
|
- oss@teamsnap.com
|
200
|
-
executables:
|
201
|
-
- emque
|
200
|
+
executables: []
|
202
201
|
extensions: []
|
203
202
|
extra_rdoc_files: []
|
204
203
|
files:
|
205
|
-
- ".github/workflows/ci.yml"
|
206
|
-
- ".gitignore"
|
207
|
-
- CHANGELOG.md
|
208
|
-
- Gemfile
|
209
|
-
- LICENSE.txt
|
210
|
-
- README.md
|
211
|
-
- Rakefile
|
212
|
-
- bin/emque
|
213
|
-
- emque-consuming.gemspec
|
214
204
|
- lib/emque-consuming.rb
|
215
205
|
- lib/emque/consuming.rb
|
216
206
|
- lib/emque/consuming/actor.rb
|
@@ -246,15 +236,6 @@ files:
|
|
246
236
|
- lib/emque/consuming/tasks.rb
|
247
237
|
- lib/emque/consuming/transmitter.rb
|
248
238
|
- lib/emque/consuming/version.rb
|
249
|
-
- lib/templates/.gitignore.tt
|
250
|
-
- lib/templates/Gemfile.tt
|
251
|
-
- lib/templates/Rakefile.tt
|
252
|
-
- lib/templates/config/application.rb.tt
|
253
|
-
- lib/templates/config/environments/development.rb.tt
|
254
|
-
- lib/templates/config/environments/production.rb.tt
|
255
|
-
- lib/templates/config/environments/staging.rb.tt
|
256
|
-
- lib/templates/config/environments/test.rb.tt
|
257
|
-
- lib/templates/config/routes.rb.tt
|
258
239
|
- spec/application_spec.rb
|
259
240
|
- spec/cli_spec.rb
|
260
241
|
- spec/configuration_spec.rb
|
@@ -275,7 +256,7 @@ homepage: https://github.com/teamsnap/emque-consuming
|
|
275
256
|
licenses:
|
276
257
|
- MIT
|
277
258
|
metadata: {}
|
278
|
-
post_install_message:
|
259
|
+
post_install_message:
|
279
260
|
rdoc_options: []
|
280
261
|
require_paths:
|
281
262
|
- lib
|
@@ -290,8 +271,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
271
|
- !ruby/object:Gem::Version
|
291
272
|
version: '0'
|
292
273
|
requirements: []
|
293
|
-
rubygems_version: 3.
|
294
|
-
signing_key:
|
274
|
+
rubygems_version: 3.2.22
|
275
|
+
signing_key:
|
295
276
|
specification_version: 4
|
296
277
|
summary: Microservices framework for Ruby
|
297
278
|
test_files:
|
data/.github/workflows/ci.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
name: CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ main ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ main ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
test:
|
11
|
-
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
|
14
|
-
strategy:
|
15
|
-
matrix:
|
16
|
-
ruby: [ '2.3.8', '2.4.10', '2.5.9', '2.6.7', '2.7.3' ]
|
17
|
-
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v2
|
20
|
-
- name: Set up Ruby
|
21
|
-
uses: ruby/setup-ruby@v1
|
22
|
-
with:
|
23
|
-
ruby-version: ${{ matrix.ruby }}
|
24
|
-
- name: Install dependencies
|
25
|
-
run: bundle install
|
26
|
-
- name: Run tests
|
27
|
-
run: bundle exec rake
|
data/.gitignore
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.project
|
4
|
-
/.config
|
5
|
-
/coverage/
|
6
|
-
/InstalledFiles
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
kafka_*/
|
13
|
-
/log/*
|
14
|
-
/logs/*
|
15
|
-
log-cleaner.log
|
16
|
-
Gemfile.lock
|
17
|
-
*.log
|
18
|
-
|
19
|
-
## Specific to RubyMotion:
|
20
|
-
.dat*
|
21
|
-
.repl_history
|
22
|
-
build/
|
23
|
-
|
24
|
-
## Documentation cache and generated files:
|
25
|
-
/.yardoc/
|
26
|
-
/_yardoc/
|
27
|
-
/doc/
|
28
|
-
/rdoc/
|
29
|
-
|
30
|
-
## Environment normalisation:
|
31
|
-
/.bundle/
|
32
|
-
/lib/bundler/man/
|
33
|
-
|
34
|
-
# for a library or gem, you might want to ignore these files since the code is
|
35
|
-
# intended to run in multiple environments; otherwise, check them in:
|
36
|
-
# Gemfile.lock
|
37
|
-
# .ruby-version
|
38
|
-
# .ruby-gemset
|
39
|
-
|
40
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
41
|
-
.rvmrc
|
data/CHANGELOG.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Emque Consuming CHANGELOG
|
2
|
-
|
3
|
-
- [Add support for running in Kubernetes](https://github.com/emque/emque-consuming/pull/84) (1.9.0)
|
4
|
-
- [Migrate to GitHub Actions](https://github.com/emque/emque-consuming/pull/82) (1.8.1)
|
5
|
-
- [Add prefetch for DelayedMessageWorker](https://github.com/emque/emque-consuming/pull/81) (1.8.0)
|
6
|
-
- [Update Rake to fix CVE-2020-8130](https://github.com/emque/emque-consuming/pull/80) (1.7.1)
|
7
|
-
- [Update pipe-ruby to remove error handling](https://github.com/emque/emque-consuming/pull/78) 1.7.0
|
8
|
-
- [Fixes bug with Bunny 2.12 failing when exchange names are symbols](https://github.com/emque/emque-consuming/pull/77) 1.6.1
|
9
|
-
- [Re-enable pipe-ruby `raise_on_error` option to fix automatic retries directing messages to the error queue](https://github.com/emque/emque-consuming/pull/75) 1.6.0
|
10
|
-
- [Update the puma gem to allow v3](https://github.com/emque/emque-consuming/pull/72) 1.5.0
|
11
|
-
- [Disable pipe-ruby `raise_on_error` option to prevent duplicate erorrs](https://github.com/emque/emque-consuming/pull/74) 1.4.0
|
12
|
-
- [Update minimum Ruby version to 2.3](https://github.com/emque/emque-consuming/pull/68) 1.3.0
|
13
|
-
- [Update the oj gem to 2.18.5](https://github.com/emque/emque-consuming/pull/67) 1.2.4
|
14
|
-
- [Add error logging when an exception is thrown.](https://github.com/emque/emque-consuming/pull/65) 1.2.3
|
15
|
-
- [Remove double ack when consuming a message and ending up in an error state. This was causing consumers to die silently.](https://github.com/emque/emque-consuming/pull/59) 1.2.1
|
16
|
-
- [Add in the ability to retry errors and back off with an exponential delay](https://github.com/emque/emque-consuming/pull/55) 1.2.0
|
17
|
-
- [Add in a configuration option to disable auto shutdown on reaching the error limit](https://github.com/emque/emque-consuming/pull/58) 1.1.3
|
18
|
-
|
19
|
-
## 1.0.0.beta4
|
20
|
-
|
21
|
-
### BREAKING CHANGE - New Queue Names
|
22
|
-
Applications updating to this version will have new queue names in RabbitMQ.
|
23
|
-
After starting up, messages will need to be manually moved
|
24
|
-
from the old queue to the new one.
|
25
|
-
|
26
|
-
### Failed Message Routing
|
27
|
-
Messages that are not acknowledged due to a consumer error will now be routed
|
28
|
-
into a `service_name.error` queue. These can then be inspected and be discarded,
|
29
|
-
purged, or manually moved back to the primary queue for re-processing.
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 TeamSnap
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
# Emque::Consuming
|
2
|
-
|
3
|
-

|
4
|
-
[](https://badge.fury.io/rb/emque-consuming)
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
6
|
-
|
7
|
-
Emque Consuming is a Ruby application framework that includes everything needed
|
8
|
-
to create and run application capable of consuming messages from a message
|
9
|
-
broker in a Pub/sub architecture. Messages can be produced with the
|
10
|
-
[emque-producing](https://github.com/emque/emque-producing) library.
|
11
|
-
|
12
|
-
## Adapters
|
13
|
-
|
14
|
-
We currently only support RabbitMQ. If you would like to add your own adapter,
|
15
|
-
take a look at [the adapters directory](https://github.com/emque/emque-consuming/tree/main/lib/emque/consuming/adapters).
|
16
|
-
|
17
|
-
## Installation
|
18
|
-
|
19
|
-
Add this line to your application's Gemfile:
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
gem "emque-consuming"
|
23
|
-
# make sure you have bunny for rabbitmq unless you're using a custom adapter
|
24
|
-
gem "bunny", "~> 2.11.0"
|
25
|
-
```
|
26
|
-
|
27
|
-
And then execute:
|
28
|
-
|
29
|
-
$ bundle
|
30
|
-
|
31
|
-
Or install it yourself as:
|
32
|
-
|
33
|
-
$ gem install emque-consuming
|
34
|
-
|
35
|
-
## Setup
|
36
|
-
|
37
|
-
### Easy
|
38
|
-
|
39
|
-
Using the `new` generator is the easiest way to get up and running quickly.
|
40
|
-
|
41
|
-
```
|
42
|
-
emque <options> new name
|
43
|
-
```
|
44
|
-
|
45
|
-
This command will create a directory "name" with barebones directories and files
|
46
|
-
you'll need to get started. You can also use the following command line options
|
47
|
-
to customize your application's configuration. Options will be added to the
|
48
|
-
config/application.rb file generated.
|
49
|
-
|
50
|
-
```
|
51
|
-
emque <options> (start|stop|new|console|help) <name (new only)>
|
52
|
-
# ...
|
53
|
-
-S, --socket PATH PATH to the application's unix socket
|
54
|
-
-b, --bind IP:PORT IP & port for the http status application to listen on.
|
55
|
-
# ...
|
56
|
-
-e, --error-limit N Set the max errors before application suicide
|
57
|
-
-s, --status Run the http status application
|
58
|
-
-x, --error-expiration SECONDS Expire errors after SECONDS
|
59
|
-
--app-name NAME Run the application as NAME
|
60
|
-
# ...
|
61
|
-
```
|
62
|
-
|
63
|
-
### Automatic Error Retries
|
64
|
-
|
65
|
-
In 1.2.0 the ability to automatically retry specific types of errors was introduced.
|
66
|
-
This depends on the [Delayed Message Exchange](https://github.com/rabbitmq/rabbitmq-delayed-message-exchange) plugin. After
|
67
|
-
[installing the plugin](https://github.com/rabbitmq/rabbitmq-delayed-message-exchange#installing),
|
68
|
-
you'll need to configure emque consuming to utilize the plugin:
|
69
|
-
|
70
|
-
```
|
71
|
-
config.enable_delayed_message = true # turn on retryable errors, defaults to false
|
72
|
-
config.retryable_errors = ["ExampleError"] # a comma delimited array of strings matching the error, defaults to any empty array ([])
|
73
|
-
config.retryable_error_limit = 4 # the number of retries to use before dead lettering the message, defaults to 3
|
74
|
-
config.delayed_message_workers = 3 # the number of workers processing delayed messages, defaults to 1
|
75
|
-
```
|
76
|
-
|
77
|
-
This will now allow you to retry known errors with an exponential backoff, which should help with transient errors!
|
78
|
-
|
79
|
-
### Custom
|
80
|
-
|
81
|
-
Configure Emque::Consuming in your config/application.rb file. Here is an example:
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
# config/application.rb
|
85
|
-
require "emque/consuming"
|
86
|
-
|
87
|
-
module Example
|
88
|
-
class Application
|
89
|
-
include Emque::Consuming::Application
|
90
|
-
|
91
|
-
initialize_core!
|
92
|
-
|
93
|
-
config.set_adapter(:rabbit_mq, :url => ENV["RABBITMQ_URL"], :prefetch => 10)
|
94
|
-
|
95
|
-
# customize the error thresholds
|
96
|
-
# config.error_limit = 10
|
97
|
-
# config.error_expiration = 300
|
98
|
-
|
99
|
-
# enable the status application
|
100
|
-
# config.status = :on
|
101
|
-
|
102
|
-
# errors will be logged, but if more is needed, that can be added
|
103
|
-
# config.error_handlers << Proc.new {|ex, context|
|
104
|
-
# send an email, send to HoneyBadger, etc
|
105
|
-
# }
|
106
|
-
|
107
|
-
# do something when shutdown occurs
|
108
|
-
# config.shutdown_handlers << Proc.new { |context|
|
109
|
-
# notify slack, pagerduty or send an email
|
110
|
-
# }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
```
|
114
|
-
|
115
|
-
You'll also want to set up a routes.rb file:
|
116
|
-
|
117
|
-
```ruby
|
118
|
-
# config/routes.rb
|
119
|
-
|
120
|
-
Example::Application.router.map do
|
121
|
-
topic "events" => EventsConsumer do
|
122
|
-
map "events.new" => "new_event"
|
123
|
-
# ...
|
124
|
-
end
|
125
|
-
|
126
|
-
# ...
|
127
|
-
end
|
128
|
-
```
|
129
|
-
|
130
|
-
and a consumer for each topic:
|
131
|
-
|
132
|
-
```ruby
|
133
|
-
# app/consumers/events_consumer.rb
|
134
|
-
|
135
|
-
class EventsConsumer
|
136
|
-
include Emque::Consuming.consumer
|
137
|
-
|
138
|
-
def new_event(message)
|
139
|
-
# NOTE: message is an immutable Virtus (https://github.com/solnic/virtus) Value Object.
|
140
|
-
# Check it out here: https://github.com/emque/emque-consuming/blob/main/lib/emque/consuming/message.rb
|
141
|
-
|
142
|
-
# You don't have to use pipe (https://github.com/teamsnap/pipe-ruby), but we love it!
|
143
|
-
pipe(message, :through => [
|
144
|
-
:shared_action, :do_something_with_new_event
|
145
|
-
])
|
146
|
-
end
|
147
|
-
|
148
|
-
private
|
149
|
-
|
150
|
-
def shared_action(message)
|
151
|
-
# ...
|
152
|
-
end
|
153
|
-
|
154
|
-
def do_something_with_new_event(message)
|
155
|
-
# ...
|
156
|
-
end
|
157
|
-
end
|
158
|
-
```
|
159
|
-
|
160
|
-
## Usage
|
161
|
-
|
162
|
-
Emque::Consuming provides a command line interface:
|
163
|
-
|
164
|
-
```
|
165
|
-
$ bundle exec emque help
|
166
|
-
|
167
|
-
emque <options> (start|stop|new|console|help) <name (new only)>
|
168
|
-
-P, --pidfile PATH Store pid in PATH
|
169
|
-
-S, --socket PATH PATH to the application's unix socket
|
170
|
-
-b, --bind IP:PORT IP & port for the http status application to listen on.
|
171
|
-
-d, --daemon Daemonize the application
|
172
|
-
-e, --error-limit N Set the max errors before application suicide
|
173
|
-
-s, --status Run the http status application
|
174
|
-
-x, --error-expiration SECONDS Expire errors after SECONDS
|
175
|
-
--app-name NAME Run the application as NAME
|
176
|
-
--env (ex. production) Set the application environment, overrides EMQUE_ENV
|
177
|
-
--auto-shutdown (false|true) Enable or disable auto shutdown on reaching the error limit
|
178
|
-
```
|
179
|
-
|
180
|
-
and a series of rake commands:
|
181
|
-
|
182
|
-
```
|
183
|
-
$ bundle exec rake -T
|
184
|
-
|
185
|
-
rake emque:configuration # Show the current configuration of a running instance (accepts SOCKET)
|
186
|
-
rake emque:console # Start a pry console
|
187
|
-
rake emque:errors:clear # Clear all outstanding errors (accepts SOCKET)
|
188
|
-
rake emque:errors:expire_after # Change the number of seconds to SECONDS before future errors expire (accepts SOCKET)
|
189
|
-
rake emque:errors:limit:down # Decrease the error limit (accepts SOCKET)
|
190
|
-
rake emque:errors:limit:up # Increase the error limit (accepts SOCKET)
|
191
|
-
rake emque:restart # Restart the workers inside a running instance (does not reload code; accepts SOCKET)
|
192
|
-
rake emque:routes # Show the available routes
|
193
|
-
rake emque:start # Start a new instance (accepts PIDFILE, DAEMON)
|
194
|
-
rake emque:status # Show the current status of a running instance (accepts SOCKET)
|
195
|
-
rake emque:stop # Stop a running instance (accepts SOCKET)
|
196
|
-
```
|
197
|
-
|
198
|
-
To use the rake commands, add the following lines to your application's Rakefile:
|
199
|
-
|
200
|
-
```ruby
|
201
|
-
require_relative "config/application"
|
202
|
-
require "emque/consuming/tasks"
|
203
|
-
```
|
204
|
-
|
205
|
-
## Tests
|
206
|
-
|
207
|
-
Testing is a bit sparse at the moment, but we're working on it.
|
208
|
-
|
209
|
-
To run tests...
|
210
|
-
|
211
|
-
```
|
212
|
-
bundle exec rspec
|
213
|
-
```
|
214
|
-
|
215
|
-
## Contributing
|
216
|
-
|
217
|
-
FIRST: Read our style guides at https://github.com/teamsnap/guides/tree/master/ruby
|
218
|
-
|
219
|
-
1. Fork it ( http://github.com/emque/emque-consuming/fork )
|
220
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
221
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
222
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
223
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler/gem_tasks"
|
3
|
-
require "rake/clean"
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
require "coveralls/rake/task"
|
6
|
-
|
7
|
-
CLOBBER.include("coverage")
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
-
t.fail_on_error = false
|
11
|
-
end
|
12
|
-
task :default => :spec
|
13
|
-
|
14
|
-
Coveralls::RakeTask.new
|
data/bin/emque
DELETED
data/emque-consuming.gemspec
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "emque/consuming/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "emque-consuming"
|
8
|
-
spec.version = Emque::Consuming::VERSION
|
9
|
-
spec.authors = ["Ryan Williams", "Dan Matthews", "Paul Hanyzewski"]
|
10
|
-
spec.email = ["oss@teamsnap.com"]
|
11
|
-
spec.summary = %q{Microservices framework for Ruby}
|
12
|
-
spec.summary = %q{Microservices framework for Ruby}
|
13
|
-
spec.homepage = "https://github.com/teamsnap/emque-consuming"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
spec.required_ruby_version = ">= 2.3"
|
21
|
-
|
22
|
-
spec.add_dependency "celluloid", "0.16.0"
|
23
|
-
spec.add_dependency "dante", "~> 0.2.0"
|
24
|
-
spec.add_dependency "oj", "~> 2.18.5"
|
25
|
-
spec.add_dependency "virtus", "~> 1.0"
|
26
|
-
spec.add_dependency "puma", "~> 3.12"
|
27
|
-
spec.add_dependency "pipe-ruby", "~> 1.0"
|
28
|
-
spec.add_dependency "inflecto", "~> 0.0.2"
|
29
|
-
|
30
|
-
spec.add_development_dependency "bundler", ">= 1.17.3"
|
31
|
-
spec.add_development_dependency "rake", ">= 12.3.3"
|
32
|
-
spec.add_development_dependency "rspec", "~> 3.3"
|
33
|
-
spec.add_development_dependency "bunny", "~> 2.11.0"
|
34
|
-
spec.add_development_dependency "timecop", "~> 0.7.1"
|
35
|
-
spec.add_development_dependency "daemon_controller", "~> 1.2.0"
|
36
|
-
end
|
data/lib/templates/.gitignore.tt
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
*.rbc
|
2
|
-
*.sassc
|
3
|
-
.sass-cache
|
4
|
-
capybara-*.html
|
5
|
-
.rspec
|
6
|
-
.rvmrc
|
7
|
-
/.bundle
|
8
|
-
/vendor/bundle
|
9
|
-
/log/*
|
10
|
-
/logs/*
|
11
|
-
/tmp/*
|
12
|
-
/db/*.sqlite3
|
13
|
-
/public/system/*
|
14
|
-
/coverage/
|
15
|
-
/spec/tmp/*
|
16
|
-
**.orig
|
17
|
-
rerun.txt
|
18
|
-
pickle-email-*.html
|
19
|
-
.project
|
20
|
-
config/initializers/secret_token.rb
|
21
|
-
config/*.yml
|
22
|
-
.ruby-version
|
23
|
-
.rbenv-version
|
24
|
-
/bin/stubs
|
25
|
-
spec/fixtures/vcr_cassettes/*
|
data/lib/templates/Gemfile.tt
DELETED
data/lib/templates/Rakefile.tt
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
2
|
-
require "bundler/setup" if File.exists?(ENV["BUNDLE_GEMFILE"])
|
3
|
-
|
4
|
-
require "emque/consuming"
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
|
7
|
-
|
8
|
-
module <%= @name %>
|
9
|
-
class Application
|
10
|
-
include Emque::Consuming::Application
|
11
|
-
|
12
|
-
initialize_core!
|
13
|
-
|
14
|
-
<%=
|
15
|
-
[].tap { |options_out|
|
16
|
-
if @options.has_key?(:app_name)
|
17
|
-
options_out << "config.app_name = \"#{@options[:app_name]}\""
|
18
|
-
end
|
19
|
-
if @options.has_key?(:error_limit)
|
20
|
-
options_out << "config.error_limit = #{@options[:error_limit]}"
|
21
|
-
end
|
22
|
-
if @options.has_key?(:error_expiration)
|
23
|
-
options_out << "config.error_expiration = #{@options[:error_expiration]}"
|
24
|
-
end
|
25
|
-
options_out << "config.set_adapter(:rabbit_mq)"
|
26
|
-
if @options.has_key?(:status)
|
27
|
-
options_out << "config.status = :on"
|
28
|
-
end
|
29
|
-
if @options.has_key?(:status_host)
|
30
|
-
options_out << "config.status_host = \"#{@options[:status_host]}\""
|
31
|
-
end
|
32
|
-
if @options.has_key?(:status_port)
|
33
|
-
options_out << "config.status_port = #{@options[:status_port]}"
|
34
|
-
end
|
35
|
-
if @options.has_key?(:socket_path)
|
36
|
-
options_out << "config.socket_path = \"#{@options[:socket_path]}\""
|
37
|
-
end
|
38
|
-
}.join("\n ")
|
39
|
-
%>
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|