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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f3da9c9e66e143a46bef401acb08968686ea745ea353d40ce8645d3470feb67
4
- data.tar.gz: 34b3eb95dae5b707c5b6ca2eafbeefefb1a3a3e104d56afacec2f5c2c62505e7
3
+ metadata.gz: 70a368862d4c3d3591a5833913f7b6c31a63882b5d05a55cdd86ab02256c2e3e
4
+ data.tar.gz: 1479349eadc2b67d850effa3d9d0b6f1f0c58ed23b9356587f544115b3a228c5
5
5
  SHA512:
6
- metadata.gz: b068d65adb4f68bfef149c1ad9e7a1c6c5f9d4a3d918b706364954564f989260bd352fc54676293fe73a23aedc0ecfe020c5a6adf6839d747d81afb1c8a42ca8
7
- data.tar.gz: aa6f55416d44fadfe6877d931408dbf3cf4f6115518d9ab64cf220cb25c176e647835b69e82991f27839127e4bcd899d9e1b918613a832bb570532217cd9acdf
6
+ metadata.gz: c8d36999774659a68c92fc248163b3fdb8d2e01cdadf5d78f503b6d11f079e82630b0382ac799cae69447dc999976dfff6e71f786a6c729e192ae804f73cf173
7
+ data.tar.gz: fbe6fb495a0d930f680a1d175fccdb92e7f38724180e733de6801a38ac91eaf2a2a6237aa06b24246d6ee7a47f38c1c33ecb3e716b7b1757889d480ec6cc59fc
@@ -38,8 +38,8 @@ jobs:
38
38
  env:
39
39
  RAILS_ENV: test
40
40
  run: |
41
- gem install bundler -v 1.16
42
- bundle _1.16_ install --jobs 4 --retry 3
41
+ gem install bundler -v 2.1.4
42
+ bundle _2.1.4_ install --jobs 4 --retry 3
43
43
 
44
44
  - name: Run tests
45
45
  run: |
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aws-liam (1.0.0)
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.269.0)
15
- aws-sdk-core (3.89.1)
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.0)
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 (10.5.0)
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.16)
60
- rake (~> 10.0)
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.17.2
65
+ 2.1.4
data/README.md CHANGED
@@ -1,29 +1,23 @@
1
- # Welcome to Liam Gem!
1
+ # AWS Liam
2
2
 
3
- Liam is an integration between your (Ruby on Rails) App and SNS, SQS AWS Services. It allows sending a message to the AWS queue (SQS) and then processing the topic name on other (Ruby on Rails) App. (microservices)
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 (Liam Neeson) for so many reasons!
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
- ![Image](https://pmctvline2.files.wordpress.com/2015/09/taken-prequel.jpg)
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 have a medium post [Here](https://medium.com/archdaily-on-technology/microservices-events-aws-our-path-to-improve-communication-between-our-ruby-on-rails-apps-501b65e35fa3) on how we improved communication between our (Ruby on Rails) apps and avoided creating new endpoints in our apps.
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
- **Welcome, Liam!**
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 first thing:
16
+ # The Gem
21
17
 
22
- - *What's SNS Service?*
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
- - *What's SQS Service?*
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', git: 'https://github.com/alexismansilla/liam.git'
36
-
29
+ gem 'aws-liam', require: 'liam'
30
+ ```
31
+ Then run a simple:
32
+ ```
37
33
  $ bundle install
38
34
  ```
39
35
 
40
- If you want the liam file in your rails app then execute:
36
+ Then execute this little rake tast that will generate some configuration files needed.
41
37
 
42
- ```ruby
43
- $ bundle exec rails install:liam
38
+ ```
39
+ $ bundle exec rails g liam:install
44
40
  ```
45
41
 
46
- We're going to create 2 Liam files
42
+ 2 files will be created:
47
43
 
48
- 1. /config/liam.yaml
49
- 2. /lib/task/liam.rake
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
- * Producer Message
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: self.id, title: self.title, created_at: self.created_at }.to_json
57
- topic_name = 'liam_CreateArticle'
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
- * Consumer Message
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
- Liam::Consumer.message
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
- ```ruby
71
- bundle exec rspec
94
+ ```
95
+ $ bundle exec rspec
72
96
  ```
73
97
 
74
- if you want to run all test successfully, we need the LocalStack daemon when sending a message
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/alexismansilla/liam.
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.16'
22
- spec.add_development_dependency 'rake', '~> 10.0'
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
@@ -1,3 +1,3 @@
1
1
  module Liam
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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.5
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-02-20 00:00:00.000000000 Z
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: '1.16'
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: '1.16'
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: '10.0'
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: '10.0'
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: []