cloudenvoy 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +7 -0
  4. data/README.md +4 -4
  5. data/app/controllers/cloudenvoy/subscriber_controller.rb +5 -2
  6. data/examples/rails/Gemfile.lock +125 -106
  7. data/examples/sinatra/Gemfile +15 -0
  8. data/examples/sinatra/Gemfile.lock +127 -0
  9. data/examples/sinatra/Procfile +1 -0
  10. data/examples/sinatra/README.md +41 -0
  11. data/examples/sinatra/app/publishers/hello_publisher.rb +34 -0
  12. data/examples/sinatra/app/subscribers/hello_subscriber.rb +16 -0
  13. data/examples/sinatra/app.rb +40 -0
  14. data/examples/sinatra/bin/console +8 -0
  15. data/examples/sinatra/config/initializers/cloudenvoy.rb +30 -0
  16. data/gemfiles/rails_5.2.gemfile.lock +86 -73
  17. data/gemfiles/rails_6.0.gemfile.lock +87 -74
  18. data/gemfiles/semantic_logger_3.4.gemfile.lock +144 -130
  19. data/gemfiles/semantic_logger_4.6.gemfile.lock +144 -130
  20. data/gemfiles/semantic_logger_4.7.0.gemfile.lock +144 -130
  21. data/gemfiles/semantic_logger_4.7.2.gemfile.lock +144 -130
  22. data/lib/cloudenvoy/message.rb +2 -2
  23. data/lib/cloudenvoy/subscriber.rb +1 -1
  24. data/lib/cloudenvoy/version.rb +1 -1
  25. data/lib/generators/cloudenvoy/publisher_generator.rb +46 -0
  26. data/lib/generators/cloudenvoy/subscriber_generator.rb +46 -0
  27. data/lib/generators/cloudenvoy/templates/publisher.rb.erb +11 -0
  28. data/lib/generators/cloudenvoy/templates/publisher_spec.rb.erb +6 -0
  29. data/lib/generators/cloudenvoy/templates/subscriber.rb.erb +11 -0
  30. data/lib/generators/cloudenvoy/templates/subscriber_spec.rb.erb +6 -0
  31. metadata +20 -7
  32. data/Gemfile.lock +0 -267
  33. data/app/controllers/cloudenvoy/application_controller.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0d42680109f30e014cb88dff9c7dc4fad3479f4cfd47131eb934c23ae0e08b2
4
- data.tar.gz: af8a2e13e9f44dfc4af98e421084772a4961833a44faeb72b113aaa2e19ea825
3
+ metadata.gz: 41639ae4ee8dd10d46e88233f3a4ceb028968e01f5b173fd798cfffe19ae0b48
4
+ data.tar.gz: 311ca0ebb0dd52abc523ffe351b5916bed9794ebb2ce2246bc8d517220f3b539
5
5
  SHA512:
6
- metadata.gz: 6449a39dc1bb6e066e9020d824f9c204930e3c32e07c42a9464a2d48ef2b6dc4c179a302236dbaae56f525c7fca3bda33c5ce1fcdb7f03a2234e807a706baab1
7
- data.tar.gz: 1271d88b89fc101ad5dccf86236983ff8bfaea72cdcbee52ce6bd484eb79c8cbbc4c312d73e4a73133a1bc60fb88362f49e7a663ca251ba9c0f9b2849f343fe4
6
+ metadata.gz: a7a8cf4f967e6a63e03878ab8656e20598cdfba01de979b4daeb82b500bbc5a92eb3a424fd6c7893f60e69e14028bd25d78d6780c2485f1362d1551de30ef6d9
7
+ data.tar.gz: f25628e0693c6fa7d1cfaedcff7a0fe3085af7a30bb8186dfa9e7af919c08300bb755ae6e75ffaaa545623a63e8a76f8b0fda8d9968eef05ced0a3fa23f96cb1
data/.gitignore CHANGED
@@ -10,5 +10,8 @@
10
10
  /tmp/
11
11
  /log/*.log
12
12
 
13
+ # Ignore lock files (e.g. Gemfile.lock)
14
+ *.lock
15
+
13
16
  # rspec failure tracking
14
17
  .rspec_status
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.4.2](https://github.com/keypup-io/cloudenvoy/tree/v0.4.2) (2021-10-25)
4
+
5
+ [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.1...v0.4.2)
6
+
7
+ **Bug fix:**
8
+ - Message processing: fix subscription parsing for topic names with dots.
9
+
3
10
  ## [v0.4.1](https://github.com/keypup-io/cloudenvoy/tree/v0.4.1) (2020-10-06)
4
11
 
5
12
  [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.0...v0.4.1)
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  ![Build Status](https://github.com/keypup-io/cloudenvoy/workflows/Test/badge.svg) [![Gem Version](https://badge.fury.io/rb/cloudenvoy.svg)](https://badge.fury.io/rb/cloudenvoy)
2
2
 
3
- **Note**: this gem is currently in alpha stage and has not been tested in production yet.
4
-
5
3
  # Cloudenvoy
6
4
 
7
5
  Cross-application messaging framework for GCP Pub/Sub.
@@ -12,6 +10,8 @@ Pub/Sub solves that event distribution problem by allowing developers to define
12
10
 
13
11
  Cloudenvoy works with the local pub/sub emulator as well, meaning that you can work offline without access to GCP.
14
12
 
13
+ **Maturity**: The gem is relatively young but is production-friendly. We at Keypup have already processed hundreds of thousands of pub/sub messages through Cloudenvoy. If you spot any bug, feel free to report it! we're aiming at a `v1.0.0` around Q1 2022.
14
+
15
15
  ## Summary
16
16
 
17
17
  1. [Installation](#installation)
@@ -80,7 +80,7 @@ Cloudenvoy.configure do |config|
80
80
  end
81
81
  ```
82
82
 
83
- Define a publisher:
83
+ Define a publisher or use generator: `rails generate cloudenvoy:publisher Dummy`
84
84
  ```ruby
85
85
  # app/publishers/dummy_publisher.rb
86
86
 
@@ -100,7 +100,7 @@ class DummyPublisher
100
100
  end
101
101
  ```
102
102
 
103
- Define a subscriber:
103
+ Define a subscriber or use generator: `rails generate cloudenvoy:subscriber Dummy`
104
104
  ```ruby
105
105
  # app/subscribers/dummy_subscriber.rb
106
106
 
@@ -2,7 +2,10 @@
2
2
 
3
3
  module Cloudenvoy
4
4
  # Handle execution of Cloudenvoy subscribers
5
- class SubscriberController < ApplicationController
5
+ class SubscriberController < ActionController::Base
6
+ # No need for CSRF verification on API endpoints
7
+ skip_before_action :verify_authenticity_token
8
+
6
9
  # Authenticate all requests.
7
10
  before_action :authenticate!
8
11
 
@@ -40,7 +43,7 @@ module Cloudenvoy
40
43
  # Get raw body
41
44
  content = request.body.read
42
45
 
43
- # Return content parsed as JSON and add job retries count
46
+ # Return content parsed as JSON
44
47
  JSON.parse(content).except('token')
45
48
  end
46
49
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- cloudenvoy (0.3.0)
4
+ cloudenvoy (0.4.1)
5
5
  activesupport
6
6
  google-cloud-pubsub (~> 2.0)
7
7
  jwt
@@ -10,187 +10,206 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (6.0.3.2)
14
- actionpack (= 6.0.3.2)
13
+ actioncable (6.0.4.1)
14
+ actionpack (= 6.0.4.1)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
- actionmailbox (6.0.3.2)
18
- actionpack (= 6.0.3.2)
19
- activejob (= 6.0.3.2)
20
- activerecord (= 6.0.3.2)
21
- activestorage (= 6.0.3.2)
22
- activesupport (= 6.0.3.2)
17
+ actionmailbox (6.0.4.1)
18
+ actionpack (= 6.0.4.1)
19
+ activejob (= 6.0.4.1)
20
+ activerecord (= 6.0.4.1)
21
+ activestorage (= 6.0.4.1)
22
+ activesupport (= 6.0.4.1)
23
23
  mail (>= 2.7.1)
24
- actionmailer (6.0.3.2)
25
- actionpack (= 6.0.3.2)
26
- actionview (= 6.0.3.2)
27
- activejob (= 6.0.3.2)
24
+ actionmailer (6.0.4.1)
25
+ actionpack (= 6.0.4.1)
26
+ actionview (= 6.0.4.1)
27
+ activejob (= 6.0.4.1)
28
28
  mail (~> 2.5, >= 2.5.4)
29
29
  rails-dom-testing (~> 2.0)
30
- actionpack (6.0.3.2)
31
- actionview (= 6.0.3.2)
32
- activesupport (= 6.0.3.2)
30
+ actionpack (6.0.4.1)
31
+ actionview (= 6.0.4.1)
32
+ activesupport (= 6.0.4.1)
33
33
  rack (~> 2.0, >= 2.0.8)
34
34
  rack-test (>= 0.6.3)
35
35
  rails-dom-testing (~> 2.0)
36
36
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.0.3.2)
38
- actionpack (= 6.0.3.2)
39
- activerecord (= 6.0.3.2)
40
- activestorage (= 6.0.3.2)
41
- activesupport (= 6.0.3.2)
37
+ actiontext (6.0.4.1)
38
+ actionpack (= 6.0.4.1)
39
+ activerecord (= 6.0.4.1)
40
+ activestorage (= 6.0.4.1)
41
+ activesupport (= 6.0.4.1)
42
42
  nokogiri (>= 1.8.5)
43
- actionview (6.0.3.2)
44
- activesupport (= 6.0.3.2)
43
+ actionview (6.0.4.1)
44
+ activesupport (= 6.0.4.1)
45
45
  builder (~> 3.1)
46
46
  erubi (~> 1.4)
47
47
  rails-dom-testing (~> 2.0)
48
48
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.0.3.2)
50
- activesupport (= 6.0.3.2)
49
+ activejob (6.0.4.1)
50
+ activesupport (= 6.0.4.1)
51
51
  globalid (>= 0.3.6)
52
- activemodel (6.0.3.2)
53
- activesupport (= 6.0.3.2)
54
- activerecord (6.0.3.2)
55
- activemodel (= 6.0.3.2)
56
- activesupport (= 6.0.3.2)
57
- activestorage (6.0.3.2)
58
- actionpack (= 6.0.3.2)
59
- activejob (= 6.0.3.2)
60
- activerecord (= 6.0.3.2)
61
- marcel (~> 0.3.1)
62
- activesupport (6.0.3.2)
52
+ activemodel (6.0.4.1)
53
+ activesupport (= 6.0.4.1)
54
+ activerecord (6.0.4.1)
55
+ activemodel (= 6.0.4.1)
56
+ activesupport (= 6.0.4.1)
57
+ activestorage (6.0.4.1)
58
+ actionpack (= 6.0.4.1)
59
+ activejob (= 6.0.4.1)
60
+ activerecord (= 6.0.4.1)
61
+ marcel (~> 1.0.0)
62
+ activesupport (6.0.4.1)
63
63
  concurrent-ruby (~> 1.0, >= 1.0.2)
64
64
  i18n (>= 0.7, < 2)
65
65
  minitest (~> 5.1)
66
66
  tzinfo (~> 1.1)
67
67
  zeitwerk (~> 2.2, >= 2.2.2)
68
- addressable (2.7.0)
68
+ addressable (2.8.0)
69
69
  public_suffix (>= 2.0.2, < 5.0)
70
70
  builder (3.2.4)
71
- concurrent-ruby (1.1.7)
71
+ concurrent-ruby (1.1.9)
72
72
  crass (1.0.6)
73
- erubi (1.9.0)
74
- faraday (1.0.1)
73
+ erubi (1.10.0)
74
+ faraday (1.8.0)
75
+ faraday-em_http (~> 1.0)
76
+ faraday-em_synchrony (~> 1.0)
77
+ faraday-excon (~> 1.1)
78
+ faraday-httpclient (~> 1.0.1)
79
+ faraday-net_http (~> 1.0)
80
+ faraday-net_http_persistent (~> 1.1)
81
+ faraday-patron (~> 1.0)
82
+ faraday-rack (~> 1.0)
75
83
  multipart-post (>= 1.2, < 3)
76
- gapic-common (0.3.4)
77
- google-protobuf (~> 3.12, >= 3.12.2)
78
- googleapis-common-protos (>= 1.3.9, < 2.0)
79
- googleapis-common-protos-types (>= 1.0.4, < 2.0)
80
- googleauth (~> 0.9)
81
- grpc (~> 1.25)
82
- globalid (0.4.2)
83
- activesupport (>= 4.2.0)
84
- google-cloud-core (1.5.0)
84
+ ruby2_keywords (>= 0.0.4)
85
+ faraday-em_http (1.0.0)
86
+ faraday-em_synchrony (1.0.0)
87
+ faraday-excon (1.1.0)
88
+ faraday-httpclient (1.0.1)
89
+ faraday-net_http (1.0.1)
90
+ faraday-net_http_persistent (1.2.0)
91
+ faraday-patron (1.0.0)
92
+ faraday-rack (1.0.0)
93
+ gapic-common (0.7.0)
94
+ faraday (~> 1.3)
95
+ google-protobuf (~> 3.14)
96
+ googleapis-common-protos (>= 1.3.11, < 2.a)
97
+ googleapis-common-protos-types (>= 1.0.6, < 2.a)
98
+ googleauth (>= 0.17.0, < 2.a)
99
+ grpc (~> 1.36)
100
+ globalid (0.5.2)
101
+ activesupport (>= 5.0)
102
+ google-cloud-core (1.6.0)
85
103
  google-cloud-env (~> 1.0)
86
104
  google-cloud-errors (~> 1.0)
87
- google-cloud-env (1.3.3)
105
+ google-cloud-env (1.5.0)
88
106
  faraday (>= 0.17.3, < 2.0)
89
- google-cloud-errors (1.0.1)
90
- google-cloud-pubsub (2.0.0)
107
+ google-cloud-errors (1.2.0)
108
+ google-cloud-pubsub (2.8.1)
91
109
  concurrent-ruby (~> 1.1)
92
110
  google-cloud-core (~> 1.5)
93
111
  google-cloud-pubsub-v1 (~> 0.0)
94
- google-cloud-pubsub-v1 (0.1.2)
95
- gapic-common (~> 0.3)
112
+ google-cloud-pubsub-v1 (0.6.0)
113
+ gapic-common (>= 0.7, < 2.a)
96
114
  google-cloud-errors (~> 1.0)
97
- grpc-google-iam-v1 (>= 0.6.10, < 2.0)
98
- google-protobuf (3.13.0-universal-darwin)
99
- googleapis-common-protos (1.3.10)
100
- google-protobuf (~> 3.11)
101
- googleapis-common-protos-types (>= 1.0.5, < 2.0)
115
+ grpc-google-iam-v1 (>= 0.6.10, < 2.a)
116
+ google-protobuf (3.18.0)
117
+ googleapis-common-protos (1.3.12)
118
+ google-protobuf (~> 3.14)
119
+ googleapis-common-protos-types (~> 1.2)
102
120
  grpc (~> 1.27)
103
- googleapis-common-protos-types (1.0.5)
104
- google-protobuf (~> 3.11)
105
- googleauth (0.13.1)
121
+ googleapis-common-protos-types (1.2.0)
122
+ google-protobuf (~> 3.14)
123
+ googleauth (1.0.0)
106
124
  faraday (>= 0.17.3, < 2.0)
107
125
  jwt (>= 1.4, < 3.0)
108
126
  memoist (~> 0.16)
109
127
  multi_json (~> 1.11)
110
128
  os (>= 0.9, < 2.0)
111
- signet (~> 0.14)
112
- grpc (1.32.0-universal-darwin)
113
- google-protobuf (~> 3.13)
129
+ signet (>= 0.16, < 2.a)
130
+ grpc (1.40.0)
131
+ google-protobuf (~> 3.15)
114
132
  googleapis-common-protos-types (~> 1.0)
115
- grpc-google-iam-v1 (0.6.10)
116
- google-protobuf (~> 3.11)
117
- googleapis-common-protos (>= 1.3.10, < 2.0)
133
+ grpc-google-iam-v1 (1.0.0)
134
+ google-protobuf (~> 3.14)
135
+ googleapis-common-protos (>= 1.3.12, < 2.0)
118
136
  grpc (~> 1.27)
119
- i18n (1.8.5)
137
+ i18n (1.8.10)
120
138
  concurrent-ruby (~> 1.0)
121
- jwt (2.2.2)
122
- loofah (2.6.0)
139
+ jwt (2.2.3)
140
+ loofah (2.12.0)
123
141
  crass (~> 1.0.2)
124
142
  nokogiri (>= 1.5.9)
125
143
  mail (2.7.1)
126
144
  mini_mime (>= 0.1.1)
127
- marcel (0.3.3)
128
- mimemagic (~> 0.3.2)
145
+ marcel (1.0.2)
129
146
  memoist (0.16.2)
130
147
  method_source (1.0.0)
131
- mimemagic (0.3.5)
132
- mini_mime (1.0.2)
133
- mini_portile2 (2.4.0)
134
- minitest (5.14.2)
148
+ mini_mime (1.1.1)
149
+ mini_portile2 (2.6.1)
150
+ minitest (5.14.4)
135
151
  multi_json (1.15.0)
136
152
  multipart-post (2.1.1)
137
- nio4r (2.5.2)
138
- nokogiri (1.10.9)
139
- mini_portile2 (~> 2.4.0)
153
+ nio4r (2.5.8)
154
+ nokogiri (1.12.5)
155
+ mini_portile2 (~> 2.6.1)
156
+ racc (~> 1.4)
140
157
  os (1.1.1)
141
158
  public_suffix (4.0.6)
159
+ racc (1.5.2)
142
160
  rack (2.2.3)
143
161
  rack-test (1.1.0)
144
162
  rack (>= 1.0, < 3)
145
- rails (6.0.3.2)
146
- actioncable (= 6.0.3.2)
147
- actionmailbox (= 6.0.3.2)
148
- actionmailer (= 6.0.3.2)
149
- actionpack (= 6.0.3.2)
150
- actiontext (= 6.0.3.2)
151
- actionview (= 6.0.3.2)
152
- activejob (= 6.0.3.2)
153
- activemodel (= 6.0.3.2)
154
- activerecord (= 6.0.3.2)
155
- activestorage (= 6.0.3.2)
156
- activesupport (= 6.0.3.2)
163
+ rails (6.0.4.1)
164
+ actioncable (= 6.0.4.1)
165
+ actionmailbox (= 6.0.4.1)
166
+ actionmailer (= 6.0.4.1)
167
+ actionpack (= 6.0.4.1)
168
+ actiontext (= 6.0.4.1)
169
+ actionview (= 6.0.4.1)
170
+ activejob (= 6.0.4.1)
171
+ activemodel (= 6.0.4.1)
172
+ activerecord (= 6.0.4.1)
173
+ activestorage (= 6.0.4.1)
174
+ activesupport (= 6.0.4.1)
157
175
  bundler (>= 1.3.0)
158
- railties (= 6.0.3.2)
176
+ railties (= 6.0.4.1)
159
177
  sprockets-rails (>= 2.0.0)
160
178
  rails-dom-testing (2.0.3)
161
179
  activesupport (>= 4.2.0)
162
180
  nokogiri (>= 1.6)
163
- rails-html-sanitizer (1.3.0)
181
+ rails-html-sanitizer (1.4.2)
164
182
  loofah (~> 2.3)
165
- railties (6.0.3.2)
166
- actionpack (= 6.0.3.2)
167
- activesupport (= 6.0.3.2)
183
+ railties (6.0.4.1)
184
+ actionpack (= 6.0.4.1)
185
+ activesupport (= 6.0.4.1)
168
186
  method_source
169
187
  rake (>= 0.8.7)
170
188
  thor (>= 0.20.3, < 2.0)
171
- rake (13.0.1)
189
+ rake (13.0.6)
172
190
  retriable (3.1.2)
173
- signet (0.14.0)
174
- addressable (~> 2.3)
191
+ ruby2_keywords (0.0.5)
192
+ signet (0.16.0)
193
+ addressable (~> 2.8)
175
194
  faraday (>= 0.17.3, < 2.0)
176
195
  jwt (>= 1.5, < 3.0)
177
196
  multi_json (~> 1.10)
178
197
  sprockets (4.0.2)
179
198
  concurrent-ruby (~> 1.0)
180
199
  rack (> 1, < 3)
181
- sprockets-rails (3.2.1)
200
+ sprockets-rails (3.2.2)
182
201
  actionpack (>= 4.0)
183
202
  activesupport (>= 4.0)
184
203
  sprockets (>= 3.0.0)
185
204
  sqlite3 (1.4.2)
186
- thor (1.0.1)
205
+ thor (1.1.0)
187
206
  thread_safe (0.3.6)
188
- tzinfo (1.2.7)
207
+ tzinfo (1.2.9)
189
208
  thread_safe (~> 0.1)
190
- websocket-driver (0.7.2)
209
+ websocket-driver (0.7.5)
191
210
  websocket-extensions (>= 0.1.0)
192
211
  websocket-extensions (0.1.5)
193
- zeitwerk (2.4.0)
212
+ zeitwerk (2.4.2)
194
213
 
195
214
  PLATFORMS
196
215
  ruby
@@ -204,4 +223,4 @@ RUBY VERSION
204
223
  ruby 2.5.5p157
205
224
 
206
225
  BUNDLED WITH
207
- 2.1.4
226
+ 2.2.26
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ ruby '2.5.5'
7
+
8
+ # Web framework
9
+ gem 'sinatra'
10
+
11
+ # Support rake tasks
12
+ gem 'rake'
13
+
14
+ # Pub/sub via cloudenvoy
15
+ gem 'cloudenvoy', path: '../../'
@@ -0,0 +1,127 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ cloudenvoy (0.4.1)
5
+ activesupport
6
+ google-cloud-pubsub (~> 2.0)
7
+ jwt
8
+ retriable
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (6.1.4.1)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ zeitwerk (~> 2.3)
19
+ addressable (2.8.0)
20
+ public_suffix (>= 2.0.2, < 5.0)
21
+ concurrent-ruby (1.1.9)
22
+ faraday (1.8.0)
23
+ faraday-em_http (~> 1.0)
24
+ faraday-em_synchrony (~> 1.0)
25
+ faraday-excon (~> 1.1)
26
+ faraday-httpclient (~> 1.0.1)
27
+ faraday-net_http (~> 1.0)
28
+ faraday-net_http_persistent (~> 1.1)
29
+ faraday-patron (~> 1.0)
30
+ faraday-rack (~> 1.0)
31
+ multipart-post (>= 1.2, < 3)
32
+ ruby2_keywords (>= 0.0.4)
33
+ faraday-em_http (1.0.0)
34
+ faraday-em_synchrony (1.0.0)
35
+ faraday-excon (1.1.0)
36
+ faraday-httpclient (1.0.1)
37
+ faraday-net_http (1.0.1)
38
+ faraday-net_http_persistent (1.2.0)
39
+ faraday-patron (1.0.0)
40
+ faraday-rack (1.0.0)
41
+ gapic-common (0.7.0)
42
+ faraday (~> 1.3)
43
+ google-protobuf (~> 3.14)
44
+ googleapis-common-protos (>= 1.3.11, < 2.a)
45
+ googleapis-common-protos-types (>= 1.0.6, < 2.a)
46
+ googleauth (>= 0.17.0, < 2.a)
47
+ grpc (~> 1.36)
48
+ google-cloud-core (1.6.0)
49
+ google-cloud-env (~> 1.0)
50
+ google-cloud-errors (~> 1.0)
51
+ google-cloud-env (1.5.0)
52
+ faraday (>= 0.17.3, < 2.0)
53
+ google-cloud-errors (1.2.0)
54
+ google-cloud-pubsub (2.8.1)
55
+ concurrent-ruby (~> 1.1)
56
+ google-cloud-core (~> 1.5)
57
+ google-cloud-pubsub-v1 (~> 0.0)
58
+ google-cloud-pubsub-v1 (0.6.0)
59
+ gapic-common (>= 0.7, < 2.a)
60
+ google-cloud-errors (~> 1.0)
61
+ grpc-google-iam-v1 (>= 0.6.10, < 2.a)
62
+ google-protobuf (3.18.0-universal-darwin)
63
+ googleapis-common-protos (1.3.12)
64
+ google-protobuf (~> 3.14)
65
+ googleapis-common-protos-types (~> 1.2)
66
+ grpc (~> 1.27)
67
+ googleapis-common-protos-types (1.2.0)
68
+ google-protobuf (~> 3.14)
69
+ googleauth (1.0.0)
70
+ faraday (>= 0.17.3, < 2.0)
71
+ jwt (>= 1.4, < 3.0)
72
+ memoist (~> 0.16)
73
+ multi_json (~> 1.11)
74
+ os (>= 0.9, < 2.0)
75
+ signet (>= 0.16, < 2.a)
76
+ grpc (1.40.0-universal-darwin)
77
+ google-protobuf (~> 3.15)
78
+ googleapis-common-protos-types (~> 1.0)
79
+ grpc-google-iam-v1 (1.0.0)
80
+ google-protobuf (~> 3.14)
81
+ googleapis-common-protos (>= 1.3.12, < 2.0)
82
+ grpc (~> 1.27)
83
+ i18n (1.8.10)
84
+ concurrent-ruby (~> 1.0)
85
+ jwt (2.2.3)
86
+ memoist (0.16.2)
87
+ minitest (5.14.4)
88
+ multi_json (1.15.0)
89
+ multipart-post (2.1.1)
90
+ mustermann (1.1.1)
91
+ ruby2_keywords (~> 0.0.1)
92
+ os (1.1.1)
93
+ public_suffix (4.0.6)
94
+ rack (2.2.3)
95
+ rack-protection (2.1.0)
96
+ rack
97
+ rake (13.0.6)
98
+ retriable (3.1.2)
99
+ ruby2_keywords (0.0.5)
100
+ signet (0.16.0)
101
+ addressable (~> 2.8)
102
+ faraday (>= 0.17.3, < 2.0)
103
+ jwt (>= 1.5, < 3.0)
104
+ multi_json (~> 1.10)
105
+ sinatra (2.1.0)
106
+ mustermann (~> 1.0)
107
+ rack (~> 2.2)
108
+ rack-protection (= 2.1.0)
109
+ tilt (~> 2.0)
110
+ tilt (2.0.10)
111
+ tzinfo (2.0.4)
112
+ concurrent-ruby (~> 1.0)
113
+ zeitwerk (2.4.2)
114
+
115
+ PLATFORMS
116
+ x86_64-darwin-17
117
+
118
+ DEPENDENCIES
119
+ cloudenvoy!
120
+ rake
121
+ sinatra
122
+
123
+ RUBY VERSION
124
+ ruby 2.5.5p157
125
+
126
+ BUNDLED WITH
127
+ 2.2.26
@@ -0,0 +1 @@
1
+ web: bundle exec ruby app.rb -p 3000
@@ -0,0 +1,41 @@
1
+ # Example usage with Rails
2
+
3
+ ## Run using the local gcloud Pub/Sub emulator
4
+
5
+ 1. Install dependencies: `bundle install`
6
+ 2. Intall the Pub/Sub emulator: `gcloud components install pubsub-emulator && gcloud components update`
7
+ 3. Run the Pub/Sub emulator: `gcloud beta emulators pubsub start`
8
+ 4. Launch the server: `foreman start`
9
+ 5. Open a Rails console: `./bin/console`
10
+ 6. Create the topics and subscriptions (one time setup - no need to redo it until you restart the pubsub emulator)
11
+ ```ruby
12
+ Cloudenvoy.setup_publishers
13
+ Cloudenvoy.setup_subscribers
14
+ ```
15
+ 7. Publish messages:
16
+ ```ruby
17
+ HelloPublisher.publish('Some message')
18
+ ```
19
+ 8. Tail the logs to see how message get processed by `HelloSubscriber`
20
+
21
+ ## Run using GCP Pub/Sub
22
+
23
+ 1. Ensure that your [Google Cloud SDK](https://cloud.google.com/sdk/docs/quickstarts) is setup.
24
+ 2. Install dependencies: `bundle install`
25
+ 3. Start an [ngrok](https://ngrok.com) tunnel: `ngrok http 3000`
26
+ 4. Edit the [initializer](./config/initializers/cloudenvoy.rb)
27
+ * Add the configuration of your GCP Pub/Sub
28
+ * Set `config.processor_host` to the ngrok http or https url
29
+ * Set `config.mode` to `:production`
30
+ 5. Launch the server: `foreman start`
31
+ 6. Open a Rails console: `./bin/console`
32
+ 7. Create the topics and subscriptions (one time setup)
33
+ ```ruby
34
+ Cloudenvoy.setup_publishers
35
+ Cloudenvoy.setup_subscribers
36
+ ```
37
+ 8. Publish messages
38
+ ```ruby
39
+ HelloPublisher.publish('Some message')
40
+ ```
41
+ 9. Tail the logs to see how message get processed by `HelloSubscriber`
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class HelloPublisher
4
+ include Cloudenvoy::Publisher
5
+
6
+ cloudenvoy_options topic: 'hello-msgs'
7
+
8
+ #
9
+ # Set message metadata (attributes)
10
+ #
11
+ # @param [String] msg The message to publish
12
+ #
13
+ # @return [Hash] The message metadata
14
+ #
15
+ def metadata(msg)
16
+ {
17
+ kind: msg.start_with?('Hello') ? 'hello' : 'regular'
18
+ }
19
+ end
20
+
21
+ #
22
+ # Format the payload.
23
+ #
24
+ # @param [String] msg The message to publish
25
+ #
26
+ # @return [Hash] The formatted message
27
+ #
28
+ def payload(msg)
29
+ {
30
+ type: 'message',
31
+ content: msg
32
+ }
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class HelloSubscriber
4
+ include Cloudenvoy::Subscriber
5
+
6
+ cloudenvoy_options topic: 'hello-msgs'
7
+
8
+ #
9
+ # Process a pub/sub message
10
+ #
11
+ # @param [Cloudenvoy::Message] message The message to process.
12
+ #
13
+ def process(message)
14
+ logger.info("Received message #{message.payload.dig('content')}")
15
+ end
16
+ end