eventboss 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +1 -0
- data/bin/eventboss +3 -3
- data/lib/eventboss/configuration.rb +7 -0
- data/lib/eventboss/error_handlers/logger.rb +3 -1
- data/lib/eventboss/instrumentation.rb +1 -1
- data/lib/eventboss/launcher.rb +6 -6
- data/lib/eventboss/logging.rb +1 -1
- data/lib/eventboss/long_poller.rb +2 -2
- data/lib/eventboss/runner.rb +1 -1
- data/lib/eventboss/scripts.rb +1 -1
- data/lib/eventboss/sns_client.rb +1 -1
- data/lib/eventboss/unit_of_work.rb +4 -3
- data/lib/eventboss/version.rb +1 -1
- data/lib/eventboss.rb +4 -1
- metadata +2 -3
- data/lib/eventboss/logger.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d49008b553f3a7cbe490be82579774a46d7b7bf6df9f9d11c0541035e1434eb
|
4
|
+
data.tar.gz: ddca3e4e49ff3e0897d73b92e1c23d21d1887963b1e3530aaa97c9a2d6202c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92804d146a379b5302d87e6e6e43b4cab29dcb10d7441aed309743e18c67da9ad73d3f254169e055605c5541b4780a4086d1b01d08ad710976bbded71cbaa265
|
7
|
+
data.tar.gz: 706ef8d1113b7fd8061696361a7352ada6d805532820b12f58be177ce6113be2d629ab0baee03322c5548565c62a818e2882c1f647590370064c42c5d0fc1598
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eventboss (1.1.
|
4
|
+
eventboss (1.1.3)
|
5
5
|
aws-sdk-sns (>= 1.1.0)
|
6
6
|
aws-sdk-sqs (>= 1.3.0)
|
7
7
|
dotenv (~> 2.1, >= 2.1.1)
|
@@ -10,8 +10,8 @@ GEM
|
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
aws-eventstream (1.0.3)
|
13
|
-
aws-partitions (1.
|
14
|
-
aws-sdk-core (3.
|
13
|
+
aws-partitions (1.211.0)
|
14
|
+
aws-sdk-core (3.67.0)
|
15
15
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
16
16
|
aws-partitions (~> 1.0)
|
17
17
|
aws-sigv4 (~> 1.1)
|
data/README.md
CHANGED
@@ -85,6 +85,7 @@ Eventboss.configure do |config|
|
|
85
85
|
config.concurrency = 10
|
86
86
|
# when using custom clients like localstack
|
87
87
|
config.sns_client = client # Custom SNS Client can be used, i.e. to use local mock, see: https://github.com/phstc/shoryuken/wiki/Using-a-local-mock-SQS-server
|
88
|
+
config.logger = MyLogger.new
|
88
89
|
config.sqs_client = Aws::SQS::Client.new(endpoint: 'http://localstack:4576', region: 'us-east-1', credentials: Aws::Credentials.new('fake', 'fake'))
|
89
90
|
end
|
90
91
|
```
|
data/bin/eventboss
CHANGED
@@ -17,10 +17,7 @@ OptionParser.new do |parser|
|
|
17
17
|
end.parse!
|
18
18
|
|
19
19
|
begin
|
20
|
-
logger = Eventboss::Logger
|
21
|
-
|
22
20
|
require 'rails'
|
23
|
-
logger.debug('Loading rails...')
|
24
21
|
if ::Rails::VERSION::MAJOR < 4
|
25
22
|
require File.expand_path('config/environment.rb')
|
26
23
|
else
|
@@ -28,6 +25,8 @@ begin
|
|
28
25
|
require File.expand_path('config/environment.rb')
|
29
26
|
end
|
30
27
|
|
28
|
+
logger = Eventboss.logger
|
29
|
+
logger.debug('Loaded rails...')
|
31
30
|
# Due to a changes introduced in Rails 6 regarding autoloading
|
32
31
|
# we need to determine how to perform eager_load
|
33
32
|
# @see https://weblog.rubyonrails.org/2019/2/22/zeitwerk-integration-in-rails-6-beta-2/
|
@@ -37,6 +36,7 @@ begin
|
|
37
36
|
::Rails.application.eager_load!
|
38
37
|
end
|
39
38
|
rescue LoadError
|
39
|
+
logger = Eventboss.logger
|
40
40
|
logger.debug('Seems like not a Rails app')
|
41
41
|
|
42
42
|
if options[:require].nil?
|
@@ -4,6 +4,7 @@ module Eventboss
|
|
4
4
|
:error_handlers,
|
5
5
|
:concurrency,
|
6
6
|
:log_level,
|
7
|
+
:logger,
|
7
8
|
:sns_client,
|
8
9
|
:sqs_client,
|
9
10
|
:eventboss_region,
|
@@ -35,6 +36,12 @@ module Eventboss
|
|
35
36
|
defined_or_default('log_level') { :info }
|
36
37
|
end
|
37
38
|
|
39
|
+
def logger
|
40
|
+
defined_or_default('logger') do
|
41
|
+
::Logger.new(STDOUT, level: Eventboss.configuration.log_level)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
38
45
|
def sns_client
|
39
46
|
defined_or_default('sns_client') { Eventboss::SnsClient.new(self) }
|
40
47
|
end
|
@@ -5,7 +5,9 @@ module Eventboss
|
|
5
5
|
notice = {}.merge!(context)
|
6
6
|
notice[:jid] = notice[:processor].jid if notice[:processor]
|
7
7
|
notice[:processor] = notice[:processor].class.to_s if notice[:processor]
|
8
|
-
Eventboss
|
8
|
+
Eventboss.logger.error(notice) do
|
9
|
+
"Failure processing request #{exception.message}"
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -9,7 +9,7 @@ module Eventboss
|
|
9
9
|
# :nodoc:
|
10
10
|
module NewRelic
|
11
11
|
def self.install(queue_listeners)
|
12
|
-
Eventboss
|
12
|
+
Eventboss.logger.info('Loaded NewRelic instrumentation')
|
13
13
|
queue_listeners.each_value do |listener_class|
|
14
14
|
listener_class.include(::NewRelic::Agent::Instrumentation::ControllerInstrumentation)
|
15
15
|
listener_class.add_transaction_tracer(:receive, category: 'OtherTransaction/EventbossJob')
|
data/lib/eventboss/launcher.rb
CHANGED
@@ -22,14 +22,14 @@ module Eventboss
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def start
|
25
|
-
logger.info("Starting #{@workers.size} workers, #{@pollers.size} pollers"
|
25
|
+
logger.info('launcher') { "Starting #{@workers.size} workers, #{@pollers.size} pollers" }
|
26
26
|
|
27
27
|
@pollers.each(&:start)
|
28
28
|
@workers.each(&:start)
|
29
29
|
end
|
30
30
|
|
31
31
|
def stop
|
32
|
-
logger.info('Gracefully shutdown'
|
32
|
+
logger.info('launcher') { 'Gracefully shutdown' }
|
33
33
|
|
34
34
|
@bus.clear
|
35
35
|
@pollers.each(&:terminate)
|
@@ -42,7 +42,7 @@ module Eventboss
|
|
42
42
|
def hard_shutdown
|
43
43
|
return if @pollers.empty? && @workers.empty?
|
44
44
|
|
45
|
-
logger.info("Killing remaining #{@pollers.size} pollers, #{@workers.size} workers"
|
45
|
+
logger.info('launcher') { "Killing remaining #{@pollers.size} pollers, #{@workers.size} workers" }
|
46
46
|
@pollers.each(&:kill)
|
47
47
|
@workers.each(&:kill)
|
48
48
|
end
|
@@ -52,7 +52,7 @@ module Eventboss
|
|
52
52
|
@workers.delete(worker)
|
53
53
|
@workers << new_worker(worker.id).tap(&:start) if restart
|
54
54
|
end
|
55
|
-
logger.debug("Worker #{worker.id} stopped, restart: #{restart}"
|
55
|
+
logger.debug('launcher') { "Worker #{worker.id} stopped, restart: #{restart}" }
|
56
56
|
end
|
57
57
|
|
58
58
|
def poller_stopped(poller, restart: false)
|
@@ -60,7 +60,7 @@ module Eventboss
|
|
60
60
|
@pollers.delete(poller)
|
61
61
|
@pollers << new_poller(poller.queue, poller.listener).tap(&:start) if restart
|
62
62
|
end
|
63
|
-
logger.debug("Poller #{poller.id} stopped, restart: #{restart}"
|
63
|
+
logger.debug('launcher') { "Poller #{poller.id} stopped, restart: #{restart}" }
|
64
64
|
end
|
65
65
|
|
66
66
|
private
|
@@ -82,7 +82,7 @@ module Eventboss
|
|
82
82
|
while @pollers.any? || @workers.any?
|
83
83
|
break if (attempts += 1) > shutdown_attempts
|
84
84
|
sleep shutdown_delay
|
85
|
-
logger.info("Waiting for #{@pollers.size} pollers, #{@workers.size} workers"
|
85
|
+
logger.info('launcher') { "Waiting for #{@pollers.size} pollers, #{@workers.size} workers" }
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/lib/eventboss/logging.rb
CHANGED
@@ -43,7 +43,7 @@ module Eventboss
|
|
43
43
|
|
44
44
|
def fetch_and_dispatch
|
45
45
|
fetch_messages.each do |message|
|
46
|
-
logger.debug("enqueueing message #{message.message_id}"
|
46
|
+
logger.debug(id) { "enqueueing message #{message.message_id}" }
|
47
47
|
@bus << UnitOfWork.new(queue, listener, message)
|
48
48
|
end
|
49
49
|
end
|
@@ -64,7 +64,7 @@ module Eventboss
|
|
64
64
|
private
|
65
65
|
|
66
66
|
def fetch_messages
|
67
|
-
logger.debug('fetching messages'
|
67
|
+
logger.debug(id) { 'fetching messages' }
|
68
68
|
@client.receive_message(
|
69
69
|
queue_url: queue.url,
|
70
70
|
max_number_of_messages: 10,
|
data/lib/eventboss/runner.rb
CHANGED
@@ -40,7 +40,7 @@ module Eventboss
|
|
40
40
|
def handle_signals(self_read, launcher)
|
41
41
|
while readable_io = IO.select([self_read])
|
42
42
|
signal = readable_io.first[0].gets.strip
|
43
|
-
logger.info("Received #{ signal } signal, gracefully shutdowning..."
|
43
|
+
logger.info('runner') { "Received #{ signal } signal, gracefully shutdowning..." }
|
44
44
|
|
45
45
|
launcher.stop
|
46
46
|
exit 0
|
data/lib/eventboss/scripts.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
load 'tasks/eventboss.rake'
|
1
|
+
load 'tasks/eventboss.rake' if defined?(Rake::Task)
|
data/lib/eventboss/sns_client.rb
CHANGED
@@ -10,13 +10,14 @@ module Eventboss
|
|
10
10
|
@queue = queue
|
11
11
|
@listener = listener
|
12
12
|
@message = message
|
13
|
+
@logger = logger
|
13
14
|
end
|
14
15
|
|
15
16
|
def run(client)
|
16
|
-
logger.debug(
|
17
|
+
logger.debug(@message.message_id) { 'Started' }
|
17
18
|
processor = @listener.new
|
18
19
|
processor.receive(JSON.parse(@message.body))
|
19
|
-
logger.
|
20
|
+
logger.debug(@message.message_id) { 'Finished' }
|
20
21
|
rescue StandardError => exception
|
21
22
|
handle_exception(exception, processor: processor, message_id: @message.message_id)
|
22
23
|
else
|
@@ -27,7 +28,7 @@ module Eventboss
|
|
27
28
|
client.delete_message(
|
28
29
|
queue_url: @queue.url, receipt_handle: @message.receipt_handle
|
29
30
|
)
|
30
|
-
logger.debug(
|
31
|
+
logger.debug(@message.message_id) { 'Deleting' }
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
data/lib/eventboss/version.rb
CHANGED
data/lib/eventboss.rb
CHANGED
@@ -19,7 +19,6 @@ require 'eventboss/fetcher'
|
|
19
19
|
require 'eventboss/publisher'
|
20
20
|
require 'eventboss/sender'
|
21
21
|
require 'eventboss/runner'
|
22
|
-
require 'eventboss/logger'
|
23
22
|
require 'eventboss/extensions'
|
24
23
|
|
25
24
|
# For Rails use railtie, for plain Ruby apps use custom scripts loader
|
@@ -67,5 +66,9 @@ module Eventboss
|
|
67
66
|
def configuration
|
68
67
|
@_configuration ||= Configuration.new
|
69
68
|
end
|
69
|
+
|
70
|
+
def logger
|
71
|
+
Thread.current[:ah_eventboss_logger] ||= configuration.logger
|
72
|
+
end
|
70
73
|
end
|
71
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventboss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AirHelp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-sqs
|
@@ -130,7 +130,6 @@ files:
|
|
130
130
|
- lib/eventboss/instrumentation.rb
|
131
131
|
- lib/eventboss/launcher.rb
|
132
132
|
- lib/eventboss/listener.rb
|
133
|
-
- lib/eventboss/logger.rb
|
134
133
|
- lib/eventboss/logging.rb
|
135
134
|
- lib/eventboss/long_poller.rb
|
136
135
|
- lib/eventboss/publisher.rb
|
data/lib/eventboss/logger.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Eventboss
|
2
|
-
class Logger
|
3
|
-
class << self
|
4
|
-
def logger
|
5
|
-
Thread.current[:ah_eventboss_logger] ||= ::Logger.new(
|
6
|
-
STDOUT,
|
7
|
-
level: Eventboss.configuration.log_level
|
8
|
-
)
|
9
|
-
end
|
10
|
-
|
11
|
-
def info(msg, tag = nil)
|
12
|
-
return unless logger
|
13
|
-
logger.info(tagged(msg, tag))
|
14
|
-
end
|
15
|
-
|
16
|
-
def debug(msg, tag = nil)
|
17
|
-
return unless logger
|
18
|
-
logger.debug(tagged(msg, tag))
|
19
|
-
end
|
20
|
-
|
21
|
-
def error(msg, tag = nil)
|
22
|
-
return unless logger
|
23
|
-
logger.error(tagged(msg, tag))
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def tagged(msg, tag)
|
29
|
-
return msg if tag.nil?
|
30
|
-
msg.prepend("[#{tag}] ")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|