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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2235f89e3779ac82843097dc2b527b3ca2dd10425fe362097d3c90217111ea1
4
- data.tar.gz: 4606f78b6bdff27c6fe997d71167f7296562aa75ce63c73c725e9eb199d477ae
3
+ metadata.gz: 1d49008b553f3a7cbe490be82579774a46d7b7bf6df9f9d11c0541035e1434eb
4
+ data.tar.gz: ddca3e4e49ff3e0897d73b92e1c23d21d1887963b1e3530aaa97c9a2d6202c2b
5
5
  SHA512:
6
- metadata.gz: 78dea8a722f457449f18c06b89be6126fcd40a57b2765a884166fc2eff721fe59a2517d9404cce2019018d6ddf500c67598f9cd4edefdf1113743ebb3065fbff
7
- data.tar.gz: a234ee1da7eaab890ac9ce3e25a0289a45664d393f3a8be25b48c6e5c89b1a91bbe5ba955e9e8f519a701d47e060b683a74af0ebc94ecf24d311eb0c0ab34310
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.2)
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.210.0)
14
- aws-sdk-core (3.66.0)
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::Logger.error("Failure processing request #{exception.message}", notice)
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::Logger.logger.info('Loaded NewRelic instrumentation')
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')
@@ -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", 'launcher')
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', 'launcher')
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", 'launcher')
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}", 'launcher')
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}", 'launcher')
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", 'launcher')
85
+ logger.info('launcher') { "Waiting for #{@pollers.size} pollers, #{@workers.size} workers" }
86
86
  end
87
87
  end
88
88
 
@@ -2,7 +2,7 @@ module Eventboss
2
2
  # Logging include logging helpers
3
3
  module Logging
4
4
  def logger
5
- Eventboss::Logger
5
+ Eventboss.logger
6
6
  end
7
7
  end
8
8
  end
@@ -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}", 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', id)
67
+ logger.debug(id) { 'fetching messages' }
68
68
  @client.receive_message(
69
69
  queue_url: queue.url,
70
70
  max_number_of_messages: 10,
@@ -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...", 'runner')
43
+ logger.info('runner') { "Received #{ signal } signal, gracefully shutdowning..." }
44
44
 
45
45
  launcher.stop
46
46
  exit 0
@@ -1 +1 @@
1
- load 'tasks/eventboss.rake'
1
+ load 'tasks/eventboss.rake' if defined?(Rake::Task)
@@ -46,7 +46,7 @@ module Eventboss
46
46
 
47
47
  class Mock
48
48
  def publish(_)
49
- Eventboss::Logger.info('Eventboss is not configured. Skipping message publishing!')
49
+ Eventboss.logger.info('Eventboss is not configured. Skipping message publishing!')
50
50
  return
51
51
  end
52
52
  end
@@ -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('Started', @message.message_id)
17
+ logger.debug(@message.message_id) { 'Started' }
17
18
  processor = @listener.new
18
19
  processor.receive(JSON.parse(@message.body))
19
- logger.info('Finished', @message.message_id)
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('Deleting', @message.message_id)
31
+ logger.debug(@message.message_id) { 'Deleting' }
31
32
  end
32
33
  end
33
34
  end
@@ -1,3 +1,3 @@
1
1
  module Eventboss
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
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.2
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 00:00:00.000000000 Z
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
@@ -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