eventboss 1.3.2 → 1.3.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: eaa1906368e8751476a4df0ae1f274a8008735de72191a34867881b50b19492b
4
- data.tar.gz: 20bfe9695bc682e801b5b6760b92b9d575d0f323218b4286196aaff6f702d30f
3
+ metadata.gz: 75049f48f1c8433cfa188e43b2b01aa1362460f14e54cf86147dddea8f37b554
4
+ data.tar.gz: 22828a987f1b8d6e3eaa3b1c6944a515e379729ab19190c99c232277d0f71463
5
5
  SHA512:
6
- metadata.gz: a1e03452ce05f49cd5cbc09875467145d41c9fe8e6239941f874394a9895c617a2a2843daa479833a498d8ccbed6e6ac64b85ca3dab8dc73f42e2f980ba99468
7
- data.tar.gz: 6c8b23c2ace8d611e3a79f98dcf15a11a97dbba537a46ee97df970730ad0107eef117547697cdebbd2e4ab97404dd99dff388f6ccbfbccfcd9b5fdad9b68d5ae
6
+ metadata.gz: 9f11ff92660d9eb27d1d5d6b0fb7c778887c5fccf7e133d6f0d27679d751aa078c93e7e5b0f90fc259a0c86a2a17e82480ffb985ec0ecead9c2fedb0779f5fa1
7
+ data.tar.gz: e2b5673cfce08d06ffef4ef74ab742765e45b03905ebaad2cbd32495c0b0b28ec3b4c7620c0180c8e0e9662b9992ea115a4621397040f98dbd3535d852978db8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventboss (1.3.2)
4
+ eventboss (1.3.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.269.0)
14
- aws-sdk-core (3.89.1)
13
+ aws-partitions (1.281.0)
14
+ aws-sdk-core (3.90.1)
15
15
  aws-eventstream (~> 1.0, >= 1.0.2)
16
16
  aws-partitions (~> 1, >= 1.239.0)
17
17
  aws-sigv4 (~> 1.1)
@@ -22,12 +22,12 @@ GEM
22
22
  aws-sdk-sqs (1.23.1)
23
23
  aws-sdk-core (~> 3, >= 3.71.0)
24
24
  aws-sigv4 (~> 1.1)
25
- aws-sigv4 (1.1.0)
25
+ aws-sigv4 (1.1.1)
26
26
  aws-eventstream (~> 1.0, >= 1.0.2)
27
27
  diff-lcs (1.3)
28
28
  dotenv (2.7.5)
29
29
  jmespath (1.4.0)
30
- rake (12.3.1)
30
+ rake (13.0.1)
31
31
  rspec (3.7.0)
32
32
  rspec-core (~> 3.7.0)
33
33
  rspec-expectations (~> 3.7.0)
@@ -2,8 +2,9 @@ class Eventboss::Railtie < Rails::Railtie
2
2
  rake_tasks do
3
3
  load 'tasks/eventboss.rake'
4
4
 
5
- # Load rails environment before executing reload.
5
+ # Load rails environment before executing reload and purge.
6
6
  # It makes sure to load configuration file.
7
7
  task 'eventboss:deadletter:reload': :environment
8
+ task 'eventboss:deadletter:purge': :environment
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module Eventboss
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -7,7 +7,7 @@ namespace :eventboss do
7
7
  source_app = args[:source_app]
8
8
  event_name = args[:event_name]
9
9
 
10
- # Zero means, fetch all messages
10
+ # Zero means: fetch all messages
11
11
  max_messages = args[:max_messages].to_i
12
12
 
13
13
  # Ensure we don't fetch more than 10 messages from SQS
@@ -15,13 +15,8 @@ namespace :eventboss do
15
15
 
16
16
  abort "[#{task.name}] At least event name should be passed as argument" unless event_name
17
17
 
18
- queue_name = [
19
- Eventboss.configuration.eventboss_app_name,
20
- Eventboss.configuration.sns_sqs_name_infix,
21
- source_app,
22
- event_name,
23
- Eventboss.env
24
- ].compact.join('-')
18
+ queue_name = compose_queue_name(source_app, event_name)
19
+
25
20
  puts "[#{task.name}] Reloading #{queue_name}-deadletter (max: #{ max_messages }, batch: #{ batch_size })"
26
21
  queue = Eventboss::Queue.new("#{queue_name}-deadletter")
27
22
  send_queue = Eventboss::Queue.new(queue_name)
@@ -49,5 +44,52 @@ namespace :eventboss do
49
44
  break if max_messages > 0 && total >= max_messages
50
45
  end
51
46
  end
47
+
48
+ desc 'Purge deadletter queue'
49
+ task :purge, [:event_name, :source_app, :max_messages] do |task, args|
50
+ source_app = args[:source_app]
51
+ event_name = args[:event_name]
52
+
53
+ # Zero means: fetch all messages
54
+ max_messages = args[:max_messages].to_i
55
+
56
+ # Ensure we don't fetch more than 10 messages from SQS
57
+ batch_size = max_messages == 0 ? 10 : [10, max_messages].min
58
+
59
+ abort "[#{task.name}] At least event name should be passed as argument" unless event_name
60
+
61
+ queue_name = compose_queue_name(source_app, event_name)
62
+
63
+ puts "[#{task.name}] Purging #{queue_name}-deadletter (max: #{ max_messages }, batch: #{ batch_size })"
64
+ queue = Eventboss::Queue.new("#{queue_name}-deadletter")
65
+ puts "[#{task.name}] #{queue.url}"
66
+
67
+ fetcher = Eventboss::Fetcher.new(Eventboss.configuration)
68
+ total = 0
69
+ loop do
70
+ messages = fetcher.fetch(queue, batch_size)
71
+ break if messages.count.zero?
72
+
73
+ messages.each do |message|
74
+ puts "[#{task.name}] Deleting message: #{message.body}"
75
+ fetcher.delete(queue, message)
76
+
77
+ total += 1
78
+ break if max_messages > 0 && total >= max_messages
79
+ end
80
+
81
+ break if max_messages > 0 && total >= max_messages
82
+ end
83
+ end
84
+
85
+ def compose_queue_name(source_app, event_name)
86
+ [
87
+ Eventboss.configuration.eventboss_app_name,
88
+ Eventboss.configuration.sns_sqs_name_infix,
89
+ source_app,
90
+ event_name,
91
+ Eventboss.env
92
+ ].compact.join('-')
93
+ end
52
94
  end
53
95
  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.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AirHelp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sqs