mimi-messaging 1.2.2 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +22 -2
- data/docs/Messaging_Layer_Properties.md +1 -1
- data/docs/Why_HTTP_is_a_bad_choice.md +4 -4
- data/lib/mimi/messaging.rb +16 -11
- data/lib/mimi/messaging/adapters/memory.rb +1 -1
- data/lib/mimi/messaging/version.rb +1 -1
- data/mimi-messaging.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8fa18eabeb0e00848c4eaf7eca202e77cef3526bd6995506ce810f0000dbdc9e
|
4
|
+
data.tar.gz: 34808e22b8405e89de11f0c571ac98004a2be18fa52e3587877e8f9eeb9c0dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c88607df18839125d858dea4ca4a076403910ac0f1ced785289dbe990910ff193ca069d16e6a72e67a43119ef983671e2dde3582a1871b9118fca3ac774746b8
|
7
|
+
data.tar.gz: 485b23c110854107a0580f0932a1bd60a1a5d3bf45ae57cf914dd778733a328adf0c642fbcdde1cf2ee2ba5d87b627a5fc97486e1682daef09277d0dbd168fdc
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# mimi-messaging
|
2
2
|
|
3
3
|
Interservice communication via message bus for microservices.
|
4
4
|
|
5
|
+
## Is it production ready?
|
6
|
+
|
7
|
+
No. Consider this project a WIP.
|
8
|
+
|
5
9
|
## What
|
6
10
|
|
7
11
|
`mimi-messaging` is a Messaging layer -- an interservice
|
@@ -15,6 +19,9 @@ See also: [Overview of Messaging layer properties](docs/Messaging_Layer_Properti
|
|
15
19
|
|
16
20
|
## Why
|
17
21
|
|
22
|
+
When it comes to organizing communications between different microservices of a system,
|
23
|
+
currently there is only two options: to use HTTP or a message bus.
|
24
|
+
|
18
25
|
[Why HTTP is a bad choice for interservice communication?](docs/Why_HTTP_is_a_bad_choice.md)
|
19
26
|
|
20
27
|
TBD: Message bus pro's and con's.
|
@@ -45,10 +52,20 @@ Mimi::Messaging.start
|
|
45
52
|
|
46
53
|
## Usage
|
47
54
|
|
55
|
+
Producing messages:
|
48
56
|
```
|
57
|
+
# COMMAND
|
58
|
+
Mimi::Messaging.command("users/lock", id: "b3cc29c8d2ec68e0")
|
59
|
+
|
60
|
+
# QUERY
|
49
61
|
response = Mimi::Messaging.query("orders/show", id: 123)
|
62
|
+
|
63
|
+
# EVENT
|
50
64
|
```
|
51
65
|
|
66
|
+
See (/examples)[/examples] folder for more examples on how to produce and consume messages.
|
67
|
+
|
68
|
+
|
52
69
|
## Adapters
|
53
70
|
|
54
71
|
`mimi-messaging` is not bound to a specific message broker implementation like RabbitMQ or Kafka. It interacts with a message broker using an adapter interface and
|
@@ -58,7 +75,7 @@ there are several available adapters:
|
|
58
75
|
* RabbitMQ (TBD)
|
59
76
|
* NATS (TBD)
|
60
77
|
* [Amazon SQS/SNS](https://github.com/kukushkin/mimi-messaging-sqs_sns)
|
61
|
-
* in-memory (single process)
|
78
|
+
* (in-memory (single process))[lib/mimi/messaging/adapters/memory.rb]
|
62
79
|
|
63
80
|
## Designing apps
|
64
81
|
|
@@ -71,6 +88,9 @@ There are only two hard problems in distributed systems:
|
|
71
88
|
2. Exactly-once delivery
|
72
89
|
```
|
73
90
|
|
91
|
+
|
92
|
+
[Messaging API specification format](https://github.com/kukushkin/mimi-messaging-spec)
|
93
|
+
|
74
94
|
## License
|
75
95
|
|
76
96
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -95,7 +95,7 @@ For commands and queries, the target of the message consists of a queue name
|
|
95
95
|
and a method name (e.g. `"customers/create"`).
|
96
96
|
|
97
97
|
For events, the target of the message consists of a topic name and an
|
98
|
-
event type (e.g. `"customers
|
98
|
+
event type (e.g. `"customers#created"`).
|
99
99
|
|
100
100
|
This allows to model the communication around your business domain concepts,
|
101
101
|
and not the implementation details like application or host names.
|
@@ -1,6 +1,4 @@
|
|
1
|
-
# Why HTTP is a bad choice for interservice communication
|
2
|
-
|
3
|
-
[WIP]
|
1
|
+
# [WIP] Why HTTP is a bad choice for interservice communication
|
4
2
|
|
5
3
|
Downsides of HTTP:
|
6
4
|
* inherently synchronous
|
@@ -17,4 +15,6 @@ Downsides of HTTP:
|
|
17
15
|
|
18
16
|
Pro's of HTTP:
|
19
17
|
* synchronous communication is simple
|
20
|
-
* HTTP as technology is well known by engineers
|
18
|
+
* HTTP as technology is well known by engineers
|
19
|
+
* more stable and simpler to setup if the services are not closely deployed (e.g. in different datacenters/regions)
|
20
|
+
|
data/lib/mimi/messaging.rb
CHANGED
@@ -15,22 +15,24 @@ module Mimi
|
|
15
15
|
#
|
16
16
|
module Messaging
|
17
17
|
# Request target validation pattern:
|
18
|
-
# "[<name>.][...]<name>/<
|
19
|
-
# Where <name> consists of
|
18
|
+
# "[<name>.][...]<name>/<identifier>"
|
19
|
+
# Where <name> consists of characters: A-Za-z0-9_-
|
20
|
+
# and <method_name> can be any of: A-Za-z0-9_
|
20
21
|
#
|
21
22
|
# Example:
|
22
23
|
# "shop.orders/list"
|
23
24
|
#
|
24
|
-
REQUEST_TARGET_REGEX = %r{^(
|
25
|
+
REQUEST_TARGET_REGEX = %r{^([\w\-]+\.)*([\w\-]+)\/(\w+)$}.freeze
|
25
26
|
|
26
27
|
# Event target validation pattern:
|
27
|
-
# "[<name>.][...]<name>#<
|
28
|
-
# Where <name> consists of
|
28
|
+
# "[<name>.][...]<name>#<identifier>"
|
29
|
+
# Where <name> consists of characters: A-Za-z0-9_-
|
30
|
+
# and <method_name> can be any of: A-Za-z0-9_
|
29
31
|
#
|
30
32
|
# Example:
|
31
33
|
# "shop.orders#created"
|
32
34
|
#
|
33
|
-
EVENT_TARGET_REGEX = %r{^(
|
35
|
+
EVENT_TARGET_REGEX = %r{^([\w\-]+\.)*([\w\-]+)\#(\w+)$}.freeze
|
34
36
|
|
35
37
|
# By default Mimi::Messaging logs at given level
|
36
38
|
DEFAULT_LOG_AT_LEVEL = :info
|
@@ -348,7 +350,7 @@ module Mimi
|
|
348
350
|
end
|
349
351
|
|
350
352
|
message_processor_params = {
|
351
|
-
type: :
|
353
|
+
type: :event_with_queue,
|
352
354
|
topic_name: topic_name,
|
353
355
|
queue_name: queue_name,
|
354
356
|
processor: processor,
|
@@ -450,24 +452,27 @@ module Mimi
|
|
450
452
|
end
|
451
453
|
private_class_method :start_message_processor
|
452
454
|
|
453
|
-
# Starts
|
455
|
+
# Starts all registered message processors at the adapter
|
454
456
|
#
|
455
457
|
def self.start_all_message_processors
|
456
458
|
message_processors.each { |p| start_message_processor(p) }
|
457
459
|
end
|
458
460
|
private_class_method :start_all_message_processors
|
459
461
|
|
460
|
-
# Stops
|
462
|
+
# Stops all registered message processors at the adapter
|
461
463
|
#
|
462
464
|
def self.stop_all_processors
|
463
465
|
log "#{self} stopping all message processors"
|
464
466
|
adapter.stop_all_processors
|
467
|
+
message_processors.each { |p| p[:started] = false }
|
465
468
|
end
|
466
469
|
private_class_method :stop_all_processors
|
467
470
|
|
468
|
-
#
|
471
|
+
# Deregisters all message processors
|
469
472
|
#
|
470
|
-
def self.
|
473
|
+
def self.unregister_all_processors
|
474
|
+
stop_all_processors
|
475
|
+
message_processors.replace([])
|
471
476
|
end
|
472
477
|
end # module Messaging
|
473
478
|
end # module Mimi
|
@@ -117,7 +117,7 @@ module Mimi
|
|
117
117
|
serialize(response)
|
118
118
|
end
|
119
119
|
|
120
|
-
def dispatch_event(target,
|
120
|
+
def dispatch_event(target, message, _opts = {})
|
121
121
|
topic_name, event_type = target.split("#")
|
122
122
|
processors = event_processors[topic_name] || []
|
123
123
|
processor_queues = event_processors_with_queue[topic_name] || {}
|
data/mimi-messaging.gemspec
CHANGED
@@ -36,6 +36,6 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
spec.add_development_dependency "bundler", "~> 2.0"
|
38
38
|
spec.add_development_dependency "pry", "~> 0.12"
|
39
|
-
spec.add_development_dependency "rake", "~>
|
39
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
40
40
|
spec.add_development_dependency "rspec", "~> 3.0"
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mimi-messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kukushkin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mimi-core
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.6.14.4
|
148
|
+
rubygems_version: 3.1.2
|
150
149
|
signing_key:
|
151
150
|
specification_version: 4
|
152
151
|
summary: Interservice communication via message bus for microservices
|