eventq 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/eventq/eventq_aws/aws_eventq_client.rb +61 -10
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44350fbecea612b6974553376fdf3bfaa20809910c897f985d50eefed53a2f87
|
|
4
|
+
data.tar.gz: bfe1de2206aa996194c29628a70c10ca3c95af93536f12c982f96081dd8da525
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3313a913a9af416e66b0fe209240f1898b20b26051ba85e17b955dac0c2c2cf92a3b2a652c1be743920c9b6d26f1bf3d8df0f704a5f30f2e51e4bc67ad0021f5
|
|
7
|
+
data.tar.gz: 025ccd2da3590a7bb7e87f3d71e7fe5d5d151fa35bae37001e97e61d00f08691e2a98d85853d4cd2ad947a67241ff4bb87923d8cd3278ced9721bf1330936631
|
|
@@ -3,12 +3,8 @@ module EventQ
|
|
|
3
3
|
# Implements a general interface to raise an event
|
|
4
4
|
# EventQ::RabbitMq::EventQClient is the sister-class which does the same for RabbitMq
|
|
5
5
|
class EventQClient
|
|
6
|
-
|
|
7
6
|
def initialize(options)
|
|
8
|
-
|
|
9
|
-
if options[:client] == nil
|
|
10
|
-
raise ':client (QueueClient) must be specified.'.freeze
|
|
11
|
-
end
|
|
7
|
+
raise ':client (QueueClient) must be specified.'.freeze if options[:client].nil?
|
|
12
8
|
|
|
13
9
|
@client = options[:client]
|
|
14
10
|
|
|
@@ -52,6 +48,10 @@ module EventQ
|
|
|
52
48
|
raise_event(topic, event, context, region)
|
|
53
49
|
end
|
|
54
50
|
|
|
51
|
+
def publish_batch(topic:, events:, context: {}, region: nil)
|
|
52
|
+
raise_events_batch(topic, events, context, region)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
55
|
def raise_event(event_type, event, context = {}, region = nil)
|
|
56
56
|
topic_arn = register_event(event_type, region)
|
|
57
57
|
|
|
@@ -63,13 +63,37 @@ module EventQ
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
EventQ.logger.debug do
|
|
66
|
-
"[#{self.class} #raise_event] - Published to SNS with topic_arn: #{topic_arn}
|
|
66
|
+
"[#{self.class} #raise_event] - Published to SNS with topic_arn: #{topic_arn}" \
|
|
67
|
+
" | event_type: #{event_type} | Message: #{message}"
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
response
|
|
70
71
|
end
|
|
71
72
|
end
|
|
72
73
|
|
|
74
|
+
def raise_events_batch(event_type, events, context = {}, region = nil)
|
|
75
|
+
topic_arn = register_event(event_type, region)
|
|
76
|
+
publish_entries = prepare_batch_entries(event_type, events, context)
|
|
77
|
+
|
|
78
|
+
message_ids = []
|
|
79
|
+
# AWS SNS PublishBatch API allows a maximum of 10 messages per batch
|
|
80
|
+
publish_entries.each_slice(10) do |batch_entries|
|
|
81
|
+
response = @client.sns(region).publish_batch(
|
|
82
|
+
topic_arn: topic_arn,
|
|
83
|
+
publish_batch_request_entries: batch_entries
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
EventQ.logger.debug do
|
|
87
|
+
"[#{self.class} #raise_events_batch] - Published batch to SNS with topic_arn: #{topic_arn}" \
|
|
88
|
+
" | event_type: #{event_type} | batch_size: #{batch_entries.length}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
message_ids.concat(response.successful.map(&:message_id))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
message_ids
|
|
95
|
+
end
|
|
96
|
+
|
|
73
97
|
def raise_event_in_queue(event_type, event, queue, delay, context = {})
|
|
74
98
|
queue_url = @client.sqs_helper.get_queue_url(queue)
|
|
75
99
|
with_prepared_message(event_type, event, context) do |message|
|
|
@@ -80,7 +104,8 @@ module EventQ
|
|
|
80
104
|
)
|
|
81
105
|
|
|
82
106
|
EventQ.logger.debug do
|
|
83
|
-
"[#{self.class} #raise_event_in_queue] - Raised event to SQS queue: #{queue_url}
|
|
107
|
+
"[#{self.class} #raise_event_in_queue] - Raised event to SQS queue: #{queue_url}" \
|
|
108
|
+
" | event_type: #{event_type} | Message: #{message}"
|
|
84
109
|
end
|
|
85
110
|
|
|
86
111
|
response
|
|
@@ -93,7 +118,29 @@ module EventQ
|
|
|
93
118
|
|
|
94
119
|
private
|
|
95
120
|
|
|
96
|
-
def
|
|
121
|
+
def prepare_batch_entries(event_type, events, default_context)
|
|
122
|
+
events.each_with_index.map do |entry, index|
|
|
123
|
+
event, context = batch_entry_values(entry, default_context)
|
|
124
|
+
|
|
125
|
+
{
|
|
126
|
+
id: "msg-#{index}",
|
|
127
|
+
message: prepared_message(event_type, event, context),
|
|
128
|
+
subject: event_type
|
|
129
|
+
}
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def batch_entry_values(entry, default_context)
|
|
134
|
+
return [entry[:event], entry.fetch(:context, default_context)] if entry.is_a?(Hash) && entry.key?(:event)
|
|
135
|
+
|
|
136
|
+
[entry, default_context]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def prepared_message(event_type, event, context)
|
|
140
|
+
build_queue_message(event_type, event, context).yield_self { |qm| serialized_message(qm) }
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def build_queue_message(event_type, event, context)
|
|
97
144
|
qm = new_message
|
|
98
145
|
qm.content = event
|
|
99
146
|
qm.type = event_type
|
|
@@ -104,12 +151,16 @@ module EventQ
|
|
|
104
151
|
qm.Correlation = event.Correlation
|
|
105
152
|
end
|
|
106
153
|
|
|
107
|
-
|
|
154
|
+
unless EventQ::Configuration.signature_secret.nil?
|
|
108
155
|
provider = @signature_manager.get_provider(EventQ::Configuration.signature_provider)
|
|
109
156
|
qm.signature = provider.write(message: qm, secret: EventQ::Configuration.signature_secret)
|
|
110
157
|
end
|
|
111
158
|
|
|
112
|
-
|
|
159
|
+
qm
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def with_prepared_message(event_type, event, context)
|
|
163
|
+
message = prepared_message(event_type, event, context)
|
|
113
164
|
|
|
114
165
|
response = yield(message)
|
|
115
166
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eventq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SageOne
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -324,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
324
324
|
- !ruby/object:Gem::Version
|
|
325
325
|
version: '0'
|
|
326
326
|
requirements: []
|
|
327
|
-
rubygems_version: 3.4.
|
|
327
|
+
rubygems_version: 3.4.20
|
|
328
328
|
signing_key:
|
|
329
329
|
specification_version: 4
|
|
330
330
|
summary: EventQ is a pub/sub system that uses async notifications and message queues
|