mimi-messaging 1.1.1 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4392d50097d139e224851c8d8609a7f3e092772
4
- data.tar.gz: 587ba9c7a31e84d732e377c02df969dcecd2a296
3
+ metadata.gz: 26a8638d1cd6dc83e1dae3096d1e069dacf09b11
4
+ data.tar.gz: bd878a461feb3246b95030322e6a00f403131ae3
5
5
  SHA512:
6
- metadata.gz: c07418b84dc02e2e5d33cdf3c4b836b2aef84710ae6f53c539a99e918c3f5f488ee6efcd30e36b668dc81559808fed04baa9a6841cb5ebe8a5c9bc2d61c29c56
7
- data.tar.gz: 8c7a7441e4b5eed3b2013daf7450f52cf9127449257b692508d8d3f6c580d4a695aa1a360b2cb3faa737b6680e3d4ed3298f5ab76fcb4189c2dfc3d82ee967a8
6
+ metadata.gz: adc464f5691764a4ce6584aba1680629ce5cedeb0335d340f484bc32655bc422397e4e9d46ac7a02e932f5e03cccd57960f1a261cc3ad751542941496c51fb3b
7
+ data.tar.gz: 5218ebeac04c69fbdfe26c5a567090a44b0cc4dcaafc2dee44e9db90cb367a0aeec46071028a732324500ae4598eb4fecca8464f0854355b8fe7e3c51bd24311
data/README.md CHANGED
@@ -57,7 +57,7 @@ there are several available adapters:
57
57
  * [Kafka](https://github.com/kukushkin/mimi-messaging-kafka)
58
58
  * RabbitMQ (TBD)
59
59
  * NATS (TBD)
60
- * Amazon SQS/SNS
60
+ * [Amazon SQS/SNS](https://github.com/kukushkin/mimi-messaging-sqs_sns)
61
61
  * in-memory (single process)
62
62
 
63
63
  ## Designing apps
@@ -65,10 +65,11 @@ there are several available adapters:
65
65
 
66
66
  There are only two hard problems in distributed systems:
67
67
 
68
+ ```
68
69
  2. Exactly-once delivery
69
70
  1. Guaranteed order of messages
70
71
  2. Exactly-once delivery
71
-
72
+ ```
72
73
 
73
74
  ## License
74
75
 
@@ -14,14 +14,23 @@ module Mimi
14
14
  # Usage: [TBD]
15
15
  #
16
16
  module Messaging
17
- # Target validation pattern:
17
+ # Request target validation pattern:
18
18
  # "[<name>.][...]<name>/<name>"
19
19
  # Where <name> consists of valid identifier characters: A-Za-z0-9_
20
20
  #
21
21
  # Example:
22
22
  # "shop.orders/list"
23
23
  #
24
- TARGET_REGEX = %r{^((\w+)\.)*(\w+)\/(\w+)$}.freeze
24
+ REQUEST_TARGET_REGEX = %r{^((\w+)\.)*(\w+)\/(\w+)$}.freeze
25
+
26
+ # Event target validation pattern:
27
+ # "[<name>.][...]<name>#<name>"
28
+ # Where <name> consists of valid identifier characters: A-Za-z0-9_
29
+ #
30
+ # Example:
31
+ # "shop.orders#created"
32
+ #
33
+ EVENT_TARGET_REGEX = %r{^((\w+)\.)*(\w+)\#(\w+)$}.freeze
25
34
 
26
35
  # By default Mimi::Messaging logs at given level
27
36
  DEFAULT_LOG_AT_LEVEL = :info
@@ -185,7 +194,7 @@ module Mimi
185
194
  # @return nil
186
195
  #
187
196
  def self.command(target, message = {}, opts = {})
188
- raise ArgumentError, "Invalid target argument" unless TARGET_REGEX.match(target)
197
+ raise ArgumentError, "Invalid target argument" unless REQUEST_TARGET_REGEX.match(target)
189
198
  raise ArgumentError, "Invalid message, Hash or Message is expected" unless message.is_a?(Hash)
190
199
  raise Error, "Failed to send command, adapter is not started" unless started?(:adapter)
191
200
 
@@ -206,7 +215,7 @@ module Mimi
206
215
  # @return [Hash]
207
216
  #
208
217
  def self.query(target, message = {}, opts = {})
209
- raise ArgumentError, "Invalid target argument" unless TARGET_REGEX.match(target)
218
+ raise ArgumentError, "Invalid target argument" unless REQUEST_TARGET_REGEX.match(target)
210
219
  raise ArgumentError, "Invalid message, Hash or Message is expected" unless message.is_a?(Hash)
211
220
  raise Error, "Failed to send query, adapter is not started" unless started?(:adapter)
212
221
 
@@ -215,12 +224,12 @@ module Mimi
215
224
 
216
225
  # Broadcasts the event with the given target
217
226
  #
218
- # @param target [String] "<topic>/<event_type>", e.g. "customers/created"
227
+ # @param target [String] "<topic>#<event_type>", e.g. "customers#created"
219
228
  # @param message [Hash,Mimi::Messaging::Message]
220
229
  # @param opts [Hash] additional options
221
230
  #
222
231
  def self.event(target, message = {}, opts = {})
223
- raise ArgumentError, "Invalid target argument" unless TARGET_REGEX.match(target)
232
+ raise ArgumentError, "Invalid target argument" unless EVENT_TARGET_REGEX.match(target)
224
233
  raise ArgumentError, "Invalid message, Hash or Message is expected" unless message.is_a?(Hash)
225
234
  raise Error, "Failed to broadcast event, adapter is not started" unless started?(:adapter)
226
235
 
@@ -88,7 +88,7 @@ module Mimi
88
88
 
89
89
  # Broadcasts the event with the given target
90
90
  #
91
- # @param target [String] "<topic>/<event_type>", e.g. "customers/created"
91
+ # @param target [String] "<topic>#<event_type>", e.g. "customers#created"
92
92
  # @param message [Mimi::Messaging::Message]
93
93
  # @param opts [Hash] additional options
94
94
  #
@@ -89,7 +89,7 @@ module Mimi
89
89
  end
90
90
 
91
91
  def dispatch_event(target, message_serialized, _opts = {})
92
- topic_name, event_type = target.split("/")
92
+ topic_name, event_type = target.split("#")
93
93
  processors = event_processors[topic_name] || []
94
94
  processor_queues = event_processors_with_queue[topic_name] || {}
95
95
  processor_queues.values.each do |same_queue_processors|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mimi
4
4
  module Messaging
5
- VERSION = "1.1.1"
5
+ VERSION = "1.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimi-messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kukushkin