aws-liam 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yaml +2 -2
- data/Gemfile.lock +8 -8
- data/README.md +56 -32
- data/liam.gemspec +4 -4
- data/lib/liam/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70a368862d4c3d3591a5833913f7b6c31a63882b5d05a55cdd86ab02256c2e3e
|
4
|
+
data.tar.gz: 1479349eadc2b67d850effa3d9d0b6f1f0c58ed23b9356587f544115b3a228c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8d36999774659a68c92fc248163b3fdb8d2e01cdadf5d78f503b6d11f079e82630b0382ac799cae69447dc999976dfff6e71f786a6c729e192ae804f73cf173
|
7
|
+
data.tar.gz: fbe6fb495a0d930f680a1d175fccdb92e7f38724180e733de6801a38ac91eaf2a2a6237aa06b24246d6ee7a47f38c1c33ecb3e716b7b1757889d480ec6cc59fc
|
data/.github/workflows/main.yaml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
aws-liam (
|
4
|
+
aws-liam (0.0.5)
|
5
5
|
aws-sdk-sns (~> 1.21)
|
6
6
|
aws-sdk-sqs (~> 1.23, >= 1.23.1)
|
7
7
|
|
@@ -11,8 +11,8 @@ GEM
|
|
11
11
|
addressable (2.7.0)
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
13
13
|
aws-eventstream (1.0.3)
|
14
|
-
aws-partitions (1.
|
15
|
-
aws-sdk-core (3.
|
14
|
+
aws-partitions (1.279.0)
|
15
|
+
aws-sdk-core (3.90.1)
|
16
16
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
17
17
|
aws-partitions (~> 1, >= 1.239.0)
|
18
18
|
aws-sigv4 (~> 1.1)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
aws-sdk-sqs (1.23.1)
|
24
24
|
aws-sdk-core (~> 3, >= 3.71.0)
|
25
25
|
aws-sigv4 (~> 1.1)
|
26
|
-
aws-sigv4 (1.1.
|
26
|
+
aws-sigv4 (1.1.1)
|
27
27
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
28
28
|
crack (0.4.3)
|
29
29
|
safe_yaml (~> 1.0.0)
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
hashdiff (1.0.0)
|
32
32
|
jmespath (1.4.0)
|
33
33
|
public_suffix (4.0.3)
|
34
|
-
rake (
|
34
|
+
rake (13.0.1)
|
35
35
|
rspec (3.9.0)
|
36
36
|
rspec-core (~> 3.9.0)
|
37
37
|
rspec-expectations (~> 3.9.0)
|
@@ -56,10 +56,10 @@ PLATFORMS
|
|
56
56
|
|
57
57
|
DEPENDENCIES
|
58
58
|
aws-liam!
|
59
|
-
bundler (~> 1.
|
60
|
-
rake (~>
|
59
|
+
bundler (~> 2.1.4)
|
60
|
+
rake (~> 13.0)
|
61
61
|
rspec (~> 3.9.0)
|
62
62
|
webmock (~> 3.7.6)
|
63
63
|
|
64
64
|
BUNDLED WITH
|
65
|
-
1.
|
65
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,29 +1,23 @@
|
|
1
|
-
#
|
1
|
+
# AWS Liam
|
2
2
|
|
3
|
-
Liam is
|
3
|
+
Liam is how we decided to call the implementation we did for our events based communication between different Ruby on Rails apps within our AWS infrastructure. We think it can be usefull for some of you that are struggling with this kind of issues too.
|
4
4
|
|
5
|
-
We called it Liam in honor to
|
5
|
+
We called it Liam in honor to Liam Neeson for so many reasons, being the most important this iconic scene when Bryan (Liam) called Marko and said:
|
6
6
|
|
7
|
-
![
|
8
|
-
|
9
|
-
Liam sends an important message to Marko from Tropoja
|
7
|
+
![Liam](https://pmctvline2.files.wordpress.com/2015/09/taken-prequel.jpg)
|
10
8
|
|
11
9
|
> *I DONT KNOW WHO YOU ARE, I DON’T KNOW WHAT YOU WANT, BUT I WILL FIND YOU AND I WILL KILL YOU*...
|
12
10
|
|
13
|
-
We
|
14
|
-
But what happens when the App A needs data from App B and App B is down for a microsecond?
|
11
|
+
We wrote an [article at Medium](https://medium.com/archdaily-on-technology/microservices-events-aws-our-path-to-improve-communication-between-our-ruby-on-rails-apps-501b65e35fa3) where we explained the whole problem we had when we tried to use plain POST http requests between applications.
|
15
12
|
|
16
|
-
|
13
|
+
After implementing this solution in a couple of apps, Alexis and Sebastian decided to create this gem to encapsulate all the needed code.
|
17
14
|
|
18
|
-
With Liam we can send a message easily to SQS Service through SNS Service and process the message data through the consumer that Liam has
|
19
15
|
|
20
|
-
The
|
16
|
+
# The Gem
|
21
17
|
|
22
|
-
|
23
|
-
Amazon Simple Notification Service (SNS) [Documentation](https://docs.aws.amazon.com/sns/latest/dg/welcome.html)
|
18
|
+
With AWS Liam we can easily send an event (a message) from App A to App B using [SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html) and [SNS](https://docs.aws.amazon.com/sns/latest/dg/welcome.html).
|
24
19
|
|
25
|
-
|
26
|
-
Amazon Simple Queue Service (SQS) [Documentation](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html)
|
20
|
+
The architecture you'll need is very simple: create as many SQS queues as applications you have (it's a good idea to call them `liam_NAME_OF_APPLICATION`, for example `liam_service_a` and `liam_service_b`) and as many SNS topics as events you want to work on (it's a good idea to call them `liam_NAME_OF_THE_EVENT`, for example `liam_ArticleCreated`, `liam_product_edited`, etc) and then subscribe the queues from the Services that need to consume the events from each topic as showed in the image bellow.
|
27
21
|
|
28
22
|
![Image](https://miro.medium.com/max/4000/1*DjlJlFUnT1UgviJzNJZ-xQ.png)
|
29
23
|
|
@@ -32,50 +26,80 @@ The first thing:
|
|
32
26
|
Add this line to your application's Gemfile:
|
33
27
|
|
34
28
|
```ruby
|
35
|
-
gem 'liam',
|
36
|
-
|
29
|
+
gem 'aws-liam', require: 'liam'
|
30
|
+
```
|
31
|
+
Then run a simple:
|
32
|
+
```
|
37
33
|
$ bundle install
|
38
34
|
```
|
39
35
|
|
40
|
-
|
36
|
+
Then execute this little rake tast that will generate some configuration files needed.
|
41
37
|
|
42
|
-
```
|
43
|
-
$ bundle exec rails install
|
38
|
+
```
|
39
|
+
$ bundle exec rails g liam:install
|
44
40
|
```
|
45
41
|
|
46
|
-
|
42
|
+
2 files will be created:
|
47
43
|
|
48
|
-
1.
|
49
|
-
2.
|
44
|
+
1. config/liam.yaml
|
45
|
+
2. lib/task/liam.rake
|
46
|
+
|
47
|
+
Go to the first one an setup your credentials and topics endpoints at AWS. The second rake task should need to be called in Service B (and whenever you want to keep listening from new messages)
|
50
48
|
|
51
49
|
## Usage
|
52
50
|
|
53
|
-
|
51
|
+
### The Producer (Service A)
|
52
|
+
Every time something happens in Service A that needs to be shared to other applications (for example, an article was published) you need to put this simple three lines (basically create the article JSON, define where do you want to send the message and send the message):
|
54
53
|
|
55
54
|
```ruby
|
56
|
-
message = { id:
|
57
|
-
topic_name = '
|
55
|
+
message = { id: id, title: title, created_at: created_at }
|
56
|
+
topic_name = 'liam_ArticleCreated'
|
58
57
|
|
59
58
|
Liam::Producer.message(topic: topic_name, message: message)
|
60
59
|
```
|
61
60
|
|
62
|
-
|
61
|
+
### The Consumer (Service B)
|
62
|
+
In the oher hand you will have to create a method in Service B that will consume the message received from Service A. At this point Class names is very important.
|
63
|
+
|
64
|
+
If you called the topic `liam_ArticleCreated` then you'll need to create a class called `ArticleCreated` within an `Liam` module at Service B, like the following example.
|
65
|
+
|
63
66
|
```ruby
|
64
|
-
|
67
|
+
# app/services/liam/article_created.rb
|
68
|
+
|
69
|
+
module Liam
|
70
|
+
class ArticleCreated
|
71
|
+
def initialize(message)
|
72
|
+
@message = message
|
73
|
+
end
|
74
|
+
|
75
|
+
def process
|
76
|
+
# Do all you need to do related to this article (at @message) that has been created at Service A
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
```
|
81
|
+
All of these files should live at `app/services/liam`.
|
82
|
+
|
83
|
+
Now you have to run the included task inside the Consumer App (make sure this task runs for ever):
|
84
|
+
|
65
85
|
```
|
86
|
+
$ bundle exec rake liam:consumer:start production
|
87
|
+
```
|
88
|
+
|
89
|
+
And that's it!
|
66
90
|
|
67
91
|
## Testing
|
68
92
|
Can you run the test easily executing
|
69
93
|
|
70
|
-
```
|
71
|
-
bundle exec rspec
|
94
|
+
```
|
95
|
+
$ bundle exec rspec
|
72
96
|
```
|
73
97
|
|
74
|
-
|
98
|
+
If you want to run all test successfully, we need the LocalStack daemon when sending a message
|
75
99
|
|
76
100
|
## Localstack Running
|
77
101
|
TODO
|
78
102
|
|
79
103
|
## Contributing
|
80
104
|
|
81
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
105
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/archdaily/aws-liam.
|
data/liam.gemspec
CHANGED
@@ -8,8 +8,8 @@ require 'liam/version'
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = 'aws-liam'
|
10
10
|
spec.version = Liam::VERSION
|
11
|
-
spec.authors = ['alexismansilla', 'sebastian-palma']
|
12
|
-
spec.email = ['alexis.mansilla04@gmail.com', 'sebastianpalma@protonmail.com']
|
11
|
+
spec.authors = ['alexismansilla', 'sebastian-palma', 'luctus']
|
12
|
+
spec.email = ['alexis.mansilla04@gmail.com', 'sebastianpalma@protonmail.com', 'luctus@gmail.com']
|
13
13
|
spec.summary = 'AWS SQS+SNS middleware integration between Ruby microservices'
|
14
14
|
spec.description = 'Improved communication between our (Ruby on Rails) apps with AWS SNS - SQS'
|
15
15
|
spec.homepage = 'http://github.com/archdaily/aws-liam'
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
spec.add_dependency 'aws-sdk-sns', '~> 1.21'
|
20
20
|
spec.add_dependency 'aws-sdk-sqs', '~> 1.23', '>= 1.23.1'
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
21
|
+
spec.add_development_dependency 'bundler', '~> 2.1.4'
|
22
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
23
23
|
spec.add_development_dependency 'rspec', '~> 3.9.0'
|
24
24
|
spec.add_development_dependency 'webmock', '~> 3.7.6'
|
25
25
|
end
|
data/lib/liam/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-liam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alexismansilla
|
8
8
|
- sebastian-palma
|
9
|
+
- luctus
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2020-
|
13
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: aws-sdk-sns
|
@@ -51,28 +52,28 @@ dependencies:
|
|
51
52
|
requirements:
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
+
version: 2.1.4
|
55
56
|
type: :development
|
56
57
|
prerelease: false
|
57
58
|
version_requirements: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
+
version: 2.1.4
|
62
63
|
- !ruby/object:Gem::Dependency
|
63
64
|
name: rake
|
64
65
|
requirement: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
+
version: '13.0'
|
69
70
|
type: :development
|
70
71
|
prerelease: false
|
71
72
|
version_requirements: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
74
|
- - "~>"
|
74
75
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
76
|
+
version: '13.0'
|
76
77
|
- !ruby/object:Gem::Dependency
|
77
78
|
name: rspec
|
78
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +107,7 @@ description: Improved communication between our (Ruby on Rails) apps with AWS SN
|
|
106
107
|
email:
|
107
108
|
- alexis.mansilla04@gmail.com
|
108
109
|
- sebastianpalma@protonmail.com
|
110
|
+
- luctus@gmail.com
|
109
111
|
executables: []
|
110
112
|
extensions: []
|
111
113
|
extra_rdoc_files: []
|