eventboss 1.4.1 → 1.8.0

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: 4e7d223c4834db900777f804ac21d03e023e952fa2df455d90768d845cc806e1
4
- data.tar.gz: bcc796c5866521aeea6a33c2920ab1634956e5f3b5aeb367c81a17b657df19a3
3
+ metadata.gz: 96d1bb368bb5d3178aba2cf5a00bec49444f24e3a0b768d3128651d14947248e
4
+ data.tar.gz: 98c2d5c2e7c64a629ef7ceedb31bfb74798c6a61d781fea22c52e36f132fd2b4
5
5
  SHA512:
6
- metadata.gz: c84d52bb6344340c0cc17f8e7387db07e1a46fa1eb5d04b67d9d577e879ddc294fa71c150e0c3110244ee046a278e3fd43c855e3bd28f31e0477c01e8c5c8603
7
- data.tar.gz: de26d5a46fe898d785edc6cd3a3436a75350907c10bf3ac3fd3d2bb9366c390776372dc9b39475cab57529df0c5aaf6df01c6ce1575043f5d947f806b8d056dc
6
+ metadata.gz: c54b9a6375dc06ce7dd516513b5e09c0f8eda8c79e796694cb9fbceaa348bff1bc196e83d400f2355b323b85b344018b13c8194505c37773b04c7196d6d6c012
7
+ data.tar.gz: a64d2636b7d9a8dbb910d85f36eedd873abdeb7b7b7aa078c19fcb67772d6de7f6dfc353117cf1b0ea84505c3f5aa5f87d48a4deb2c68beb504b4a6cfe24333c
@@ -0,0 +1,40 @@
1
+ name: Verify
2
+ # Source: https://github.com/actions/setup-ruby
3
+
4
+ on:
5
+ push:
6
+ branches: [master]
7
+ pull_request:
8
+ branches: [master]
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ["2.6", "2.7", "3.0"]
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby
19
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ # runs 'bundle install' and caches installed gems automatically
24
+ bundler-cache: true
25
+ - name: Run tests
26
+ run: bundle exec rspec
27
+ audit:
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Set up Ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: "3.0"
35
+ - name: Install bundle audit
36
+ run: gem install bundle-audit
37
+ - name: Update Ruby Advisory Database
38
+ run: bundle-audit update
39
+ - name: Run audit
40
+ run: bundle audit
data/Gemfile.lock CHANGED
@@ -1,55 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventboss (1.4.1)
4
+ eventboss (1.8.0)
5
5
  aws-sdk-sns (>= 1.1.0)
6
6
  aws-sdk-sqs (>= 1.3.0)
7
7
  dotenv (~> 2.1, >= 2.1.1)
8
+ rexml (~> 3.0)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- aws-eventstream (1.1.0)
13
- aws-partitions (1.350.0)
14
- aws-sdk-core (3.104.3)
13
+ aws-eventstream (1.2.0)
14
+ aws-partitions (1.568.0)
15
+ aws-sdk-core (3.130.0)
15
16
  aws-eventstream (~> 1, >= 1.0.2)
16
- aws-partitions (~> 1, >= 1.239.0)
17
+ aws-partitions (~> 1, >= 1.525.0)
17
18
  aws-sigv4 (~> 1.1)
18
19
  jmespath (~> 1.0)
19
- aws-sdk-sns (1.28.0)
20
- aws-sdk-core (~> 3, >= 3.99.0)
20
+ aws-sdk-sns (1.53.0)
21
+ aws-sdk-core (~> 3, >= 3.127.0)
21
22
  aws-sigv4 (~> 1.1)
22
- aws-sdk-sqs (1.30.0)
23
- aws-sdk-core (~> 3, >= 3.99.0)
23
+ aws-sdk-sqs (1.51.0)
24
+ aws-sdk-core (~> 3, >= 3.127.0)
24
25
  aws-sigv4 (~> 1.1)
25
- aws-sigv4 (1.2.1)
26
+ aws-sigv4 (1.4.0)
26
27
  aws-eventstream (~> 1, >= 1.0.2)
27
- diff-lcs (1.3)
28
+ diff-lcs (1.5.0)
28
29
  dotenv (2.7.6)
29
- jmespath (1.4.0)
30
- rake (13.0.1)
31
- rspec (3.7.0)
32
- rspec-core (~> 3.7.0)
33
- rspec-expectations (~> 3.7.0)
34
- rspec-mocks (~> 3.7.0)
35
- rspec-core (3.7.0)
36
- rspec-support (~> 3.7.0)
37
- rspec-expectations (3.7.0)
30
+ jmespath (1.6.1)
31
+ rake (13.0.6)
32
+ rexml (3.2.5)
33
+ rspec (3.11.0)
34
+ rspec-core (~> 3.11.0)
35
+ rspec-expectations (~> 3.11.0)
36
+ rspec-mocks (~> 3.11.0)
37
+ rspec-core (3.11.0)
38
+ rspec-support (~> 3.11.0)
39
+ rspec-expectations (3.11.0)
38
40
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.7.0)
40
- rspec-mocks (3.7.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-mocks (3.11.0)
41
43
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.7.0)
43
- rspec-support (3.7.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-support (3.11.0)
44
46
 
45
47
  PLATFORMS
46
48
  ruby
47
49
 
48
50
  DEPENDENCIES
49
- bundler (~> 1.13)
51
+ bundler (>= 1)
50
52
  eventboss!
51
53
  rake (>= 10.0)
52
54
  rspec (~> 3.0)
53
55
 
54
56
  BUNDLED WITH
55
- 1.17.3
57
+ 2.3.7
data/README.md CHANGED
@@ -100,8 +100,8 @@ EVENTBOSS_ENV=env_name # production/staging/test
100
100
  EVENTBOSS_REGION=aws_region # i.e. eu-west-1
101
101
  EVENTBOSS_CONCURRENCY=10 # default is 25
102
102
 
103
- AWS_SNS_ENDPOINT=http://localhost:4575 # when using with localstack
104
- AWS_SQS_ENDPOINT=http://localhost:4576 # when using with localstack
103
+ AWS_SNS_ENDPOINT=http://localhost:4566 # when using with localstack
104
+ AWS_SQS_ENDPOINT=http://localhost:4566 # when using with localstack
105
105
  ```
106
106
  Use fixed account ID for localstack setup:
107
107
  ```
data/eventboss.gemspec CHANGED
@@ -23,8 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "aws-sdk-sqs", ">= 1.3.0"
24
24
  spec.add_dependency "aws-sdk-sns", ">= 1.1.0"
25
25
  spec.add_dependency "dotenv", "~> 2.1", ">= 2.1.1"
26
+ spec.add_dependency "rexml", "~> 3.0"
26
27
 
27
- spec.add_development_dependency "bundler", "~> 1.13"
28
+ spec.add_development_dependency "bundler", ">= 1"
28
29
  spec.add_development_dependency 'rake', '>= 10.0'
29
30
  spec.add_development_dependency "rspec", "~> 3.0"
30
31
  end
@@ -25,14 +25,13 @@ module Eventboss
25
25
  :sns_sqs_name_infix,
26
26
  :listeners
27
27
 
28
-
29
28
  def raise_on_missing_configuration
30
29
  defined_or_default('raise_on_missing_configuration') { (ENV['EVENTBOSS_RAISE_ON_MISSING_CONFIGURATION'] || ENV['EVENTBUS_RAISE_ON_MISSING_CONFIGURATION'])&.downcase == 'true' }
31
30
  end
32
31
 
33
32
  def error_handlers
34
33
  defined_or_default('error_handlers') do
35
- [ErrorHandlers::Logger.new].tap do |handlers|
34
+ [ErrorHandlers::Logger.new, ErrorHandlers::NonExistentQueueHandler.new].tap do |handlers|
36
35
  handlers << ErrorHandlers::DbConnectionDropHandler.new if defined?(::ActiveRecord::StatementInvalid)
37
36
  handlers << ErrorHandlers::DbConnectionNotEstablishedHandler.new if defined?(::ActiveRecord::ConnectionNotEstablished)
38
37
  end
@@ -17,6 +17,9 @@ module Eventboss
17
17
  logger.info('development-mode') { "Creating queue #{queue.name}..." }
18
18
  sqs_client.create_queue(queue_name: queue.name)
19
19
 
20
+ logger.info('development-mode') { "Creating deadletter queue #{queue.name}-deadletter..." }
21
+ sqs_client.create_queue(queue_name: "#{queue.name}-deadletter")
22
+
20
23
  logger.info('development-mode') { "Setting up queue #{queue.name} policy..." }
21
24
  policy = queue_policy(queue.arn, topic.topic_arn)
22
25
  sqs_client.set_queue_attributes(queue_url: queue.url, attributes: { Policy: policy.to_json })
@@ -0,0 +1,12 @@
1
+ module Eventboss
2
+ module ErrorHandlers
3
+ class NonExistentQueueHandler
4
+ def call(exception, context = {})
5
+ if exception.class == ::Aws::SQS::Errors::NonExistentQueue
6
+ queue = context.fetch(:poller_id, "").sub('poller-', '')
7
+ Eventboss.logger.error("Queue doesn't exist: " + queue)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module Eventboss
2
+ module ErrorHandlers
3
+ class Rollbar
4
+ def call(exception, context = {})
5
+ eventboss_context = { component: 'eventboss' }
6
+ eventboss_context[:action] = context[:processor].class.to_s if context[:processor]
7
+ ::Rollbar.error(exception, eventboss_context.merge(context))
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,6 @@
1
1
  require 'eventboss/error_handlers/logger'
2
2
  require 'eventboss/error_handlers/airbrake'
3
+ require 'eventboss/error_handlers/rollbar'
3
4
  require 'eventboss/error_handlers/db_connection_drop_handler'
4
5
  require 'eventboss/error_handlers/db_connection_not_established_handler'
6
+ require 'eventboss/error_handlers/non_existent_queue_handler'
@@ -34,6 +34,7 @@ module Eventboss
34
34
  @bus.clear
35
35
  @pollers.each(&:terminate)
36
36
  @workers.each(&:terminate)
37
+ @bus.close
37
38
 
38
39
  wait_for_shutdown
39
40
  hard_shutdown
@@ -70,7 +71,7 @@ module Eventboss
70
71
  end
71
72
 
72
73
  def new_worker(id)
73
- Worker.new(self, id, @bus)
74
+ Worker.new(self, "worker-#{id}", @bus)
74
75
  end
75
76
 
76
77
  def new_poller(queue, listener)
@@ -45,6 +45,8 @@ module Eventboss
45
45
  fetch_messages.each do |message|
46
46
  logger.debug(id) { "enqueueing message #{message.message_id}" }
47
47
  @bus << UnitOfWork.new(@client, queue, listener, message)
48
+ rescue ClosedQueueError
49
+ logger.info(id) { "skip message #{message.message_id} enqueuing due to closed queue" }
48
50
  end
49
51
  end
50
52
 
@@ -53,6 +55,9 @@ module Eventboss
53
55
  @launcher.poller_stopped(self)
54
56
  rescue Eventboss::Shutdown
55
57
  @launcher.poller_stopped(self)
58
+ rescue Aws::SQS::Errors::NonExistentQueue => exception
59
+ handle_exception(exception, poller_id: id)
60
+ @launcher.poller_stopped(self)
56
61
  rescue StandardError => exception
57
62
  handle_exception(exception, poller_id: id)
58
63
  # Give a chance for temporary AWS errors to be resolved
@@ -1,3 +1,3 @@
1
1
  module Eventboss
2
- VERSION = "1.4.1"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -7,7 +7,7 @@ module Eventboss
7
7
  attr_reader :id
8
8
 
9
9
  def initialize(launcher, id, bus, restart_on: [Exception])
10
- @id = "worker-#{id}"
10
+ @id = id
11
11
  @launcher = launcher
12
12
  @bus = bus
13
13
  @thread = nil
@@ -45,7 +45,6 @@ module Eventboss
45
45
  end
46
46
 
47
47
  def kill(wait = false)
48
- stop_token
49
48
  return unless @thread
50
49
  @thread.raise Eventboss::Shutdown
51
50
  @thread.value if wait
@@ -6,6 +6,9 @@ namespace :eventboss do
6
6
  task :reload, [:event_name, :source_app, :max_messages] do |task, args|
7
7
  source_app = args[:source_app]
8
8
  event_name = args[:event_name]
9
+ start_time = Time.now
10
+
11
+ Eventboss.logger.info "[#{task.name}] Start task"
9
12
 
10
13
  # Zero means: fetch all messages
11
14
  max_messages = args[:max_messages].to_i
@@ -17,13 +20,11 @@ namespace :eventboss do
17
20
 
18
21
  queue_name = compose_queue_name(source_app, event_name)
19
22
 
20
- puts "[#{task.name}] Reloading #{queue_name}-deadletter (max: #{ max_messages }, batch: #{ batch_size })"
23
+ Eventboss.logger.info "[#{task.name}] Reloading #{queue_name}-deadletter (max: #{ max_messages }, batch: #{ batch_size })"
21
24
  queue = Eventboss::Queue.new("#{queue_name}-deadletter")
22
25
  send_queue = Eventboss::Queue.new(queue_name)
23
26
 
24
- puts "[#{task.name}] #{queue.url}"
25
- puts "[#{task.name}] to"
26
- puts "[#{task.name}] #{send_queue.url}"
27
+ Eventboss.logger.info "[#{task.name}] #{queue.url} to #{send_queue.url}"
27
28
 
28
29
  fetcher = Eventboss::Fetcher.new(Eventboss.configuration)
29
30
  client = fetcher.client
@@ -42,16 +43,24 @@ namespace :eventboss do
42
43
 
43
44
  break if max_messages > 0 && total >= max_messages
44
45
  end
46
+ Eventboss.logger.info <<~HEREDOC
47
+ [#{task.name}] Task done
48
+ total messages: #{total}
49
+ total time: #{Time.now - start_time}s
50
+ HEREDOC
45
51
  end
46
52
 
47
53
  desc 'Purge deadletter queue'
48
54
  task :purge, [:event_name, :source_app, :max_messages] do |task, args|
49
55
  source_app = args[:source_app]
50
56
  event_name = args[:event_name]
57
+ start_time = Time.now
51
58
 
52
59
  # Zero means: fetch all messages
53
60
  max_messages = args[:max_messages].to_i
54
61
 
62
+ Eventboss.logger.info "[#{task.name}] Start task"
63
+
55
64
  # Ensure we don't fetch more than 10 messages from SQS
56
65
  batch_size = max_messages == 0 ? 10 : [10, max_messages].min
57
66
 
@@ -59,9 +68,9 @@ namespace :eventboss do
59
68
 
60
69
  queue_name = compose_queue_name(source_app, event_name)
61
70
 
62
- puts "[#{task.name}] Purging #{queue_name}-deadletter (max: #{ max_messages }, batch: #{ batch_size })"
71
+ Eventboss.logger.info "[#{task.name}] Purging #{queue_name}-deadletter (max: #{ max_messages }, batch: #{ batch_size })"
63
72
  queue = Eventboss::Queue.new("#{queue_name}-deadletter")
64
- puts "[#{task.name}] #{queue.url}"
73
+ Eventboss.logger.info "[#{task.name}] #{queue.url}"
65
74
 
66
75
  fetcher = Eventboss::Fetcher.new(Eventboss.configuration)
67
76
  total = 0
@@ -78,6 +87,12 @@ namespace :eventboss do
78
87
 
79
88
  break if max_messages > 0 && total >= max_messages
80
89
  end
90
+
91
+ Eventboss.logger.info <<~HEREDOC
92
+ [#{task.name}] Task done
93
+ total messages: #{total}
94
+ total time: #{Time.now - start_time}s
95
+ HEREDOC
81
96
  end
82
97
 
83
98
  def compose_queue_name(source_app, event_name)
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.4.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AirHelp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-11 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sqs
@@ -59,19 +59,33 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: 2.1.1
61
61
  - !ruby/object:Gem::Dependency
62
- name: bundler
62
+ name: rexml
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '1.13'
68
- type: :development
67
+ version: '3.0'
68
+ type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '1.13'
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: bundler
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '1'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: rake
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,7 @@ executables:
108
122
  extensions: []
109
123
  extra_rdoc_files: []
110
124
  files:
125
+ - ".github/workflows/verify.yml"
111
126
  - ".gitignore"
112
127
  - ".rspec"
113
128
  - ".travis.yml"
@@ -128,6 +143,8 @@ files:
128
143
  - lib/eventboss/error_handlers/db_connection_drop_handler.rb
129
144
  - lib/eventboss/error_handlers/db_connection_not_established_handler.rb
130
145
  - lib/eventboss/error_handlers/logger.rb
146
+ - lib/eventboss/error_handlers/non_existent_queue_handler.rb
147
+ - lib/eventboss/error_handlers/rollbar.rb
131
148
  - lib/eventboss/extensions.rb
132
149
  - lib/eventboss/fetcher.rb
133
150
  - lib/eventboss/instrumentation.rb
@@ -171,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
188
  - !ruby/object:Gem::Version
172
189
  version: '0'
173
190
  requirements: []
174
- rubygems_version: 3.0.3
191
+ rubygems_version: 3.3.7
175
192
  signing_key:
176
193
  specification_version: 4
177
194
  summary: Eventboss Ruby Client.