emque-consuming 1.8.0 → 1.9.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: a33e1cb0ba1688a3afd735ee7aee23a8b331e744cd0453056b96c4552f51dd02
4
- data.tar.gz: c380412c8831d5ffa843d56da14a4ed45647d9c4fd075fe6a2aace2a1ee9ea29
3
+ metadata.gz: 259c7b22f2046972a4dc8d74895a876f7b510eeca07ba8ba88c686330070dafa
4
+ data.tar.gz: ada2575a2efcdbbd39c286bbe0567b14664b8075d62b107a2e3725dac38e1b3c
5
5
  SHA512:
6
- metadata.gz: de3eb3ea8e8deb9ec9917df070c2559c5b2857fc996e59abaff091756d33c1b65603c310ea586dd744daae9224cf801405201beeff5426b7e28924ba2695de79
7
- data.tar.gz: 78ebf244f57a11f99b3fe5cca252647e37a67179b863d031243d6ff636d3e8b2f076e2ab60992c932f52d6f9a21ee2e9f1c0d7619d107741d2a668cd973bcc8c
6
+ metadata.gz: f96688d19a2253cb72ba318efaa063aaa8a6b0d344d6e494b41378989469e1abfe4eabfa9e53646bb899ce3b3f6b05b325c8828ed432b2f86f14e652acd1ae70
7
+ data.tar.gz: 5b97bffee37917327ae6e9e48c723099fb734d6afd5c3a1f44c602776b9b1058d2d86c0a564c9fc62cea85d34df025f34448d273bc9ab111b3e8aa7ea23d24fc
@@ -8,7 +8,7 @@ module Emque
8
8
  :error_limit, :error_expiration, :retryable_errors,
9
9
  :retryable_error_limit, :status, :status_port, :status_host,
10
10
  :socket_path, :shutdown_handlers
11
- attr_writer :env, :log_level
11
+ attr_writer :env, :log_level, :log_formatter
12
12
 
13
13
  def initialize
14
14
  @app_name = ""
@@ -19,6 +19,7 @@ module Emque
19
19
  @error_limit = 5
20
20
  @error_expiration = 3600 # 60 minutes
21
21
  @log_level = nil
22
+ @log_formatter = nil
22
23
  @retryable_errors = []
23
24
  @retryable_error_limit = 3
24
25
  @status_port = 10000
@@ -40,6 +41,10 @@ module Emque
40
41
  @log_level ||= Logger::INFO
41
42
  end
42
43
 
44
+ def log_formatter
45
+ @log_formatter ||= ::Logger::Formatter.new
46
+ end
47
+
43
48
  def set_adapter(name, options = {})
44
49
  @adapter = Emque::Consuming::Adapter.new(name, options)
45
50
  end
@@ -50,9 +50,11 @@ module Emque
50
50
  )
51
51
  end
52
52
 
53
- def initialize_logger
54
- Emque::Consuming::Logging.initialize_logger(logfile)
53
+ def initialize_logger(daemonized: false)
54
+ target = daemonized ? logfile : STDOUT
55
+ Emque::Consuming::Logging.initialize_logger(target)
55
56
  Emque::Consuming.logger.level = config.log_level
57
+ Emque::Consuming.logger.formatter = config.log_formatter
56
58
  Celluloid.logger = Emque::Consuming.logger
57
59
  end
58
60
 
@@ -82,7 +84,7 @@ module Emque
82
84
  end
83
85
 
84
86
  def emque_env
85
- config.env_var || ENV["EMQUE_ENV"] || ENV["RACK_ENV"] || "development"
87
+ config.env_var || ENV["EMQUE_ENV"] || "development"
86
88
  end
87
89
  end
88
90
  end
@@ -54,11 +54,11 @@ module Emque
54
54
  unless IGNORE.include?(e)
55
55
  loc = File.join(path, e)
56
56
 
57
- if Dir.exists?(loc)
57
+ if Dir.exist?(loc)
58
58
  new_nest = nesting + [e]
59
59
  create_path = File.join(*new_nest)
60
60
 
61
- unless Dir.exists?(create_path)
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.exists?(filename)
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.exists?(path)
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.exists?(path)
50
+ FileUtils.rm_f(path) if File.exist?(path)
51
51
  end
52
52
  end
53
53
  end
@@ -23,7 +23,9 @@ module Emque
23
23
  self.receivers = []
24
24
  self.status = Emque::Consuming::Status.new
25
25
  apply_options
26
- Emque::Consuming.application.initialize_logger
26
+ Emque::Consuming
27
+ .application
28
+ .initialize_logger(daemonized: options.fetch(:daemon) { false })
27
29
  self.class.instance = self
28
30
  self.pidfile = options.fetch(:pidfile, default_pidfile)
29
31
  self.pid = Emque::Consuming::Pidfile.new(pidfile)
@@ -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.exists?(socket_path)
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.exists?(socket_path)
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
 
@@ -1,5 +1,5 @@
1
1
  module Emque
2
2
  module Consuming
3
- VERSION = "1.8.0"
3
+ VERSION = "1.9.1"
4
4
  end
5
5
  end
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.exists?(path)).to eq(false)
8
+ expect(Dir.exist?(path)).to eq(false)
9
9
  Emque::Consuming::Pidfile.new(pidfile)
10
- expect(Dir.exists?(path)).to eq(true)
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.exists?(pidfile)).to eq(true)
38
+ expect(File.exist?(pidfile)).to eq(true)
39
39
  expect(pf.running?).to eq(false)
40
- expect(File.exists?(pidfile)).to eq(false)
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.exists?(pidfile)).to eq(true)
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.exists?(pidfile)).to eq(false)
67
+ expect(File.exist?(pidfile)).to eq(false)
68
68
  pf.write
69
- expect(File.exists?(pidfile)).to eq(true)
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emque-consuming
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Williams
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-09-16 00:00:00.000000000 Z
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: 2.18.5
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: 2.18.5
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: '1.0'
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: '1.0'
98
+ version: 1.0.2
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: inflecto
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -114,16 +114,16 @@ dependencies:
114
114
  name: bundler
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - "~>"
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: '1.7'
119
+ version: 1.17.3
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - "~>"
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
- version: '1.7'
126
+ version: 1.17.3
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: rake
129
129
  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.1
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.1
182
+ version: '0.7'
183
183
  - !ruby/object:Gem::Dependency
184
184
  name: daemon_controller
185
185
  requirement: !ruby/object:Gem::Requirement
@@ -197,20 +197,10 @@ dependencies:
197
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
- - ".gitignore"
206
- - ".travis.yml"
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
@@ -290,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
271
  - !ruby/object:Gem::Version
291
272
  version: '0'
292
273
  requirements: []
293
- rubygems_version: 3.0.3
274
+ rubygems_version: 3.2.22
294
275
  signing_key:
295
276
  specification_version: 4
296
277
  summary: Microservices framework for Ruby
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/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.8
4
- - 2.4.10
5
- - 2.5.8
6
- - 2.6.6
7
- script: bundle exec rake
8
- notifications:
9
- recipients:
10
- - shane@teamsnap.com
11
- - ryan.williams@teamsnap.com
data/CHANGELOG.md DELETED
@@ -1,27 +0,0 @@
1
- # Emque Consuming CHANGELOG
2
-
3
- - [Add prefetch for DelayedMessageWorker](https://github.com/emque/emque-consuming/pull/81) (1.8.0)
4
- - [Update Rake to fix CVE-2020-8130](https://github.com/emque/emque-consuming/pull/80) (1.7.1)
5
- - [Update pipe-ruby to remove error handling](https://github.com/emque/emque-consuming/pull/78) 1.7.0
6
- - [Fixes bug with Bunny 2.12 failing when exchange names are symbols](https://github.com/emque/emque-consuming/pull/77) 1.6.1
7
- - [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
8
- - [Update the puma gem to allow v3](https://github.com/emque/emque-consuming/pull/72) 1.5.0
9
- - [Disable pipe-ruby `raise_on_error` option to prevent duplicate erorrs](https://github.com/emque/emque-consuming/pull/74) 1.4.0
10
- - [Update minimum Ruby version to 2.3](https://github.com/emque/emque-consuming/pull/68) 1.3.0
11
- - [Update the oj gem to 2.18.5](https://github.com/emque/emque-consuming/pull/67) 1.2.4
12
- - [Add error logging when an exception is thrown.](https://github.com/emque/emque-consuming/pull/65) 1.2.3
13
- - [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
14
- - [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
15
- - [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
16
-
17
- ## 1.0.0.beta4
18
-
19
- ### BREAKING CHANGE - New Queue Names
20
- Applications updating to this version will have new queue names in RabbitMQ.
21
- After starting up, messages will need to be manually moved
22
- from the old queue to the new one.
23
-
24
- ### Failed Message Routing
25
- Messages that are not acknowledged due to a consumer error will now be routed
26
- into a `service_name.error` queue. These can then be inspected and be discarded,
27
- purged, or manually moved back to the primary queue for re-processing.
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "simplecov", :require => false
4
- gem "coveralls", :require => false
5
- gem "pry", :require => false
6
-
7
- gemspec
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,221 +0,0 @@
1
- [![Build Status](https://travis-ci.org/emque/emque-consuming.png)](https://travis-ci.org/emque/emque-consuming)
2
-
3
- # Emque::Consuming
4
-
5
- Emque Consuming is a Ruby application framework that includes everything needed
6
- to create and run application capable of consuming messages from a message
7
- broker in a Pub/sub architecture. Messages can be produced with the
8
- [emque-producing](https://github.com/emque/emque-producing) library.
9
-
10
- ## Adapters
11
-
12
- We currently only support RabbitMQ. If you would like to add your own adapter,
13
- take a look at [the adapters directory](https://github.com/emque/emque-consuming/tree/master/lib/emque/consuming/adapters).
14
-
15
- ## Installation
16
-
17
- Add this line to your application's Gemfile:
18
-
19
- ```ruby
20
- gem "emque-consuming"
21
- # make sure you have bunny for rabbitmq unless you're using a custom adapter
22
- gem "bunny", "~> 2.11.0"
23
- ```
24
-
25
- And then execute:
26
-
27
- $ bundle
28
-
29
- Or install it yourself as:
30
-
31
- $ gem install emque-consuming
32
-
33
- ## Setup
34
-
35
- ### Easy
36
-
37
- Using the `new` generator is the easiest way to get up and running quickly.
38
-
39
- ```
40
- emque <options> new name
41
- ```
42
-
43
- This command will create a directory "name" with barebones directories and files
44
- you'll need to get started. You can also use the following command line options
45
- to customize your application's configuration. Options will be added to the
46
- config/application.rb file generated.
47
-
48
- ```
49
- emque <options> (start|stop|new|console|help) <name (new only)>
50
- # ...
51
- -S, --socket PATH PATH to the application's unix socket
52
- -b, --bind IP:PORT IP & port for the http status application to listen on.
53
- # ...
54
- -e, --error-limit N Set the max errors before application suicide
55
- -s, --status Run the http status application
56
- -x, --error-expiration SECONDS Expire errors after SECONDS
57
- --app-name NAME Run the application as NAME
58
- # ...
59
- ```
60
-
61
- ### Automatic Error Retries
62
-
63
- In 1.2.0 the ability to automatically retry specific types of errors was introduced.
64
- This depends on the [Delayed Message Exchange](https://github.com/rabbitmq/rabbitmq-delayed-message-exchange) plugin. After
65
- [installing the plugin](https://github.com/rabbitmq/rabbitmq-delayed-message-exchange#installing),
66
- you'll need to configure emque consuming to utilize the plugin:
67
-
68
- ```
69
- config.enable_delayed_message = true # turn on retryable errors, defaults to false
70
- config.retryable_errors = ["ExampleError"] # a comma delimited array of strings matching the error, defaults to any empty array ([])
71
- config.retryable_error_limit = 4 # the number of retries to use before dead lettering the message, defaults to 3
72
- config.delayed_message_workers = 3 # the number of workers processing delayed messages, defaults to 1
73
- ```
74
-
75
- This will now allow you to retry known errors with an exponential backoff, which should help with transient errors!
76
-
77
- ### Custom
78
-
79
- Configure Emque::Consuming in your config/application.rb file. Here is an example:
80
-
81
- ```ruby
82
- # config/application.rb
83
- require "emque/consuming"
84
-
85
- module Example
86
- class Application
87
- include Emque::Consuming::Application
88
-
89
- initialize_core!
90
-
91
- config.set_adapter(:rabbit_mq, :url => ENV["RABBITMQ_URL"], :prefetch => 10)
92
-
93
- # customize the error thresholds
94
- # config.error_limit = 10
95
- # config.error_expiration = 300
96
-
97
- # enable the status application
98
- # config.status = :on
99
-
100
- # errors will be logged, but if more is needed, that can be added
101
- # config.error_handlers << Proc.new {|ex, context|
102
- # send an email, send to HoneyBadger, etc
103
- # }
104
-
105
- # do something when shutdown occurs
106
- # config.shutdown_handlers << Proc.new { |context|
107
- # notify slack, pagerduty or send an email
108
- # }
109
- end
110
- end
111
- ```
112
-
113
- You'll also want to set up a routes.rb file:
114
-
115
- ```ruby
116
- # config/routes.rb
117
-
118
- Example::Application.router.map do
119
- topic "events" => EventsConsumer do
120
- map "events.new" => "new_event"
121
- # ...
122
- end
123
-
124
- # ...
125
- end
126
- ```
127
-
128
- and a consumer for each topic:
129
-
130
- ```ruby
131
- # app/consumers/events_consumer.rb
132
-
133
- class EventsConsumer
134
- include Emque::Consuming.consumer
135
-
136
- def new_event(message)
137
- # NOTE: message is an immutable Virtus (https://github.com/solnic/virtus) Value Object.
138
- # Check it out here: https://github.com/emque/emque-consuming/blob/master/lib/emque/consuming/message.rb
139
-
140
- # You don't have to use pipe (https://github.com/teamsnap/pipe-ruby), but we love it!
141
- pipe(message, :through => [
142
- :shared_action, :do_something_with_new_event
143
- ])
144
- end
145
-
146
- private
147
-
148
- def shared_action(message)
149
- # ...
150
- end
151
-
152
- def do_something_with_new_event(message)
153
- # ...
154
- end
155
- end
156
- ```
157
-
158
- ## Usage
159
-
160
- Emque::Consuming provides a command line interface:
161
-
162
- ```
163
- $ bundle exec emque help
164
-
165
- emque <options> (start|stop|new|console|help) <name (new only)>
166
- -P, --pidfile PATH Store pid in PATH
167
- -S, --socket PATH PATH to the application's unix socket
168
- -b, --bind IP:PORT IP & port for the http status application to listen on.
169
- -d, --daemon Daemonize the application
170
- -e, --error-limit N Set the max errors before application suicide
171
- -s, --status Run the http status application
172
- -x, --error-expiration SECONDS Expire errors after SECONDS
173
- --app-name NAME Run the application as NAME
174
- --env (ex. production) Set the application environment, overrides EMQUE_ENV
175
- --auto-shutdown (false|true) Enable or disable auto shutdown on reaching the error limit
176
- ```
177
-
178
- and a series of rake commands:
179
-
180
- ```
181
- $ bundle exec rake -T
182
-
183
- rake emque:configuration # Show the current configuration of a running instance (accepts SOCKET)
184
- rake emque:console # Start a pry console
185
- rake emque:errors:clear # Clear all outstanding errors (accepts SOCKET)
186
- rake emque:errors:expire_after # Change the number of seconds to SECONDS before future errors expire (accepts SOCKET)
187
- rake emque:errors:limit:down # Decrease the error limit (accepts SOCKET)
188
- rake emque:errors:limit:up # Increase the error limit (accepts SOCKET)
189
- rake emque:restart # Restart the workers inside a running instance (does not reload code; accepts SOCKET)
190
- rake emque:routes # Show the available routes
191
- rake emque:start # Start a new instance (accepts PIDFILE, DAEMON)
192
- rake emque:status # Show the current status of a running instance (accepts SOCKET)
193
- rake emque:stop # Stop a running instance (accepts SOCKET)
194
- ```
195
-
196
- To use the rake commands, add the following lines to your application's Rakefile:
197
-
198
- ```ruby
199
- require_relative "config/application"
200
- require "emque/consuming/tasks"
201
- ```
202
-
203
- ## Tests
204
-
205
- Testing is a bit sparse at the moment, but we're working on it.
206
-
207
- To run tests...
208
-
209
- ```
210
- bundle exec rspec
211
- ```
212
-
213
- ## Contributing
214
-
215
- FIRST: Read our style guides at https://github.com/teamsnap/guides/tree/master/ruby
216
-
217
- 1. Fork it ( http://github.com/emque/emque-consuming/fork )
218
- 2. Create your feature branch (`git checkout -b my-new-feature`)
219
- 3. Commit your changes (`git commit -am 'Add some feature'`)
220
- 4. Push to the branch (`git push origin my-new-feature`)
221
- 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
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "emque-consuming"
4
-
5
- Emque::Consuming::Cli.new(ARGV)
@@ -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.7"
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
@@ -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/*
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- ruby "2.1.2"
4
-
5
- gem "rake"
6
- gem "emque-consuming", :git => "https://github.com/teamsnap/emque-consuming.git"
@@ -1,7 +0,0 @@
1
- require_relative "config/application"
2
- require "emque/consuming/tasks"
3
-
4
- __DIR__ = File.dirname(__FILE__)
5
- Dir.glob("#{__DIR__}/tasks/*.rake").each do |rake_file|
6
- import rake_file
7
- end
@@ -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
-
@@ -1,2 +0,0 @@
1
- <%= @name %>::Application.configure do
2
- end
@@ -1,2 +0,0 @@
1
- <%= @name %>::Application.configure do
2
- end
@@ -1,2 +0,0 @@
1
- <%= @name %>::Application.configure do
2
- end
@@ -1,2 +0,0 @@
1
- <%= @name %>::Application.configure do
2
- end
@@ -1,8 +0,0 @@
1
- <%= @name %>::Application.router.map do
2
- # topic "samples" => SamplesConsumer[, :workers => 2] do
3
- # map "samples.new" => "new_sample"
4
- # ...
5
- # end
6
-
7
- # ...
8
- end