event_hub_aws 1.0.0 → 1.1.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: d3c7401b3851c2637639028138ddf94cb783c776a5dc4d97039f7000a14cd4e6
4
- data.tar.gz: 8af5a65ca4bbf444160836aeb23a2d60c41c8c2b05d8bed319fe3f448c6110af
3
+ metadata.gz: 6d6d8cd6e3a3662021f32454f0187d5ac8f26daa56124945a25bec23a684ee85
4
+ data.tar.gz: 62c21c366bf10fd64ba662030fc0259f2ee5bb861280c5e99a6cad13dc4fa1b6
5
5
  SHA512:
6
- metadata.gz: 82fcb23b41a84ba0a3ac54816f32d949338765cb013ca22936f2a90d71caee1fc56c85bb1b4b34724d2bd4727146b938ccca41d84a156543a765a7504a82ebf4
7
- data.tar.gz: b4d0c28833549ac73ca5698db13f1b474a2f245e229d7967cf4b643fa04ce92c62f3dcd32d2b7176b856817ef2b0804e85170838e0036b9f63138dadd6ef80a9
6
+ metadata.gz: 857b59a72cb7190fcaf925d636567f5aa684bd9a150cc8cc061d7691d16532959c345e7abfe82921c544c8d6fa124020e75ed1fa07f584931a3662c7e80c3237
7
+ data.tar.gz: d4731533089e45e50c355ee43bba4af36c4138c211939885517fecb53149d78d7a831f25b29f2456b856119947425abc11d877d4cbf116f7a8e00c31f552fb7d
data/.env.test CHANGED
@@ -1,6 +1,6 @@
1
- QUEUE_URL=https://sqs.us-west-2.amazonaws.com/744522205193/market-data-events.fifo
2
- QUEUE_ARN=arn:aws:sqs:us-west-2:744522205193:market-data-events.fifo
3
- EXCHANGE_ARN=arn:aws:sns:us-west-2:744522205193:event-hub.fifo
4
- ACCOUNT_NUMBER=744522205193
1
+ QUEUE_URL=https://sqs.us-west-2.amazonaws.com/123456789012/market-data-events.fifo
2
+ QUEUE_ARN=arn:aws:sqs:us-west-2:123456789012:market-data-events.fifo
3
+ EXCHANGE_ARN=arn:aws:sns:us-west-2:123456789012:event-hub.fifo
4
+ ACCOUNT_NUMBER=123456789012
5
5
  ACCESS_KEY_ID=123
6
6
  SECRET_ACCESS_KEY=321
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- event_hub_aws (1.0.0)
4
+ event_hub_aws (1.1.0)
5
5
  aws-sdk-sns (~> 1.0)
6
6
  aws-sdk-sqs (~> 1.0)
7
7
  event_hub (~> 1.0)
@@ -95,6 +95,7 @@ GEM
95
95
 
96
96
  PLATFORMS
97
97
  x86_64-darwin-21
98
+ x86_64-darwin-22
98
99
  x86_64-linux
99
100
 
100
101
  DEPENDENCIES
data/README.md CHANGED
@@ -28,6 +28,7 @@ development:
28
28
  queue_url: https://sqs.us-west-2.amazonaws.com/1234567890/events.fifo
29
29
  queue_arn: arn:aws:sqs:us-west-2:1234567890:events.fifo
30
30
  exchange_arn: arn:aws:sns:us-west-2:1234567890:event-hub.fifo
31
+ # delete_message_on_failure: true # uncomment if you don't have dead-letter queue and wanna just delete messages on failure
31
32
  subscribe:
32
33
  user_registered:
33
34
  handler: Handlers::UserRegistered
@@ -31,10 +31,9 @@ class EventHub
31
31
  end
32
32
 
33
33
  def reject
34
- if @adapter.config[:dead_queue_url]
35
- # TODO: publish the message to the dead_queue
36
- end
37
- ack
34
+ ack if @adapter.config[:delete_message_on_failure]
35
+ # other wise it will be returned to the main queue and then after the maxReceiveCount it will be sent to
36
+ # the DeadLetter queue
38
37
  end
39
38
 
40
39
  private
@@ -31,15 +31,17 @@ class EventHub
31
31
  end
32
32
 
33
33
  def publish(event)
34
- topic.publish({
35
- message: event.body,
36
- message_attributes: {
37
- event: { data_type: 'String', string_value: event.class.event },
38
- version: { data_type: 'String', string_value: event.class.version },
39
- },
40
- message_group_id: 'message_group_id',
41
- message_deduplication_id: SecureRandom.uuid
42
- })
34
+ message = {
35
+ message: event.body,
36
+ message_attributes: {
37
+ event: { data_type: 'String', string_value: event.class.event },
38
+ version: { data_type: 'String', string_value: event.class.version },
39
+ },
40
+ }
41
+ if fifo_exchange?
42
+ message.merge!(message_group_id: 'message_group_id', message_deduplication_id: SecureRandom.uuid)
43
+ end
44
+ topic.publish(message)
43
45
  end
44
46
 
45
47
  def setup_bindings
@@ -79,6 +81,12 @@ class EventHub
79
81
  def sqs
80
82
  @sqs ||= ::Aws::SQS::Client.new(@config[:credentials] || {})
81
83
  end
84
+
85
+ def fifo_exchange?
86
+ return @fifo_exchange if defined?(@fifo_exchange)
87
+
88
+ @fifo_exchange = @config[:exchange_arn].end_with?('.fifo')
89
+ end
82
90
  end
83
91
  end
84
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventHubAws
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_hub_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Guban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-23 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sns