cloudenvoy 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint_rubocop.yml +20 -0
  3. data/.github/workflows/{test.yml → test_ruby_2.5_2.6.yml} +8 -13
  4. data/.github/workflows/test_ruby_2.7.yml +36 -0
  5. data/.github/workflows/test_ruby_3.x.yml +35 -0
  6. data/.gitignore +3 -0
  7. data/.rubocop.yml +5 -0
  8. data/Appraisals +24 -4
  9. data/CHANGELOG.md +16 -0
  10. data/README.md +7 -4
  11. data/app/controllers/cloudenvoy/subscriber_controller.rb +5 -2
  12. data/cloudenvoy.gemspec +0 -4
  13. data/examples/rails/.ruby-version +1 -1
  14. data/examples/rails/Gemfile +4 -1
  15. data/examples/rails/Gemfile.lock +139 -113
  16. data/examples/rails/README.md +1 -1
  17. data/examples/sinatra/Gemfile +18 -0
  18. data/examples/sinatra/Gemfile.lock +139 -0
  19. data/examples/sinatra/Procfile +1 -0
  20. data/examples/sinatra/README.md +41 -0
  21. data/examples/sinatra/app/publishers/hello_publisher.rb +34 -0
  22. data/examples/sinatra/app/subscribers/hello_subscriber.rb +16 -0
  23. data/examples/sinatra/app.rb +40 -0
  24. data/examples/sinatra/bin/console +8 -0
  25. data/examples/sinatra/config/initializers/cloudenvoy.rb +30 -0
  26. data/gemfiles/.bundle/config +2 -0
  27. data/gemfiles/rails_5.2.gemfile +1 -0
  28. data/gemfiles/rails_5.2.gemfile.lock +117 -92
  29. data/gemfiles/rails_6.0.gemfile +1 -0
  30. data/gemfiles/rails_6.0.gemfile.lock +118 -93
  31. data/gemfiles/rails_6.1.gemfile +8 -0
  32. data/gemfiles/rails_7.0.gemfile +8 -0
  33. data/gemfiles/semantic_logger_3.4.gemfile +1 -0
  34. data/gemfiles/semantic_logger_3.4.gemfile.lock +95 -189
  35. data/gemfiles/semantic_logger_4.6.gemfile +1 -0
  36. data/gemfiles/semantic_logger_4.6.gemfile.lock +95 -189
  37. data/gemfiles/semantic_logger_4.7.0.gemfile +1 -0
  38. data/gemfiles/semantic_logger_4.7.0.gemfile.lock +95 -189
  39. data/gemfiles/semantic_logger_4.7.2.gemfile +1 -0
  40. data/gemfiles/semantic_logger_4.7.2.gemfile.lock +95 -189
  41. data/lib/cloudenvoy/backend/google_pub_sub.rb +2 -2
  42. data/lib/cloudenvoy/message.rb +2 -2
  43. data/lib/cloudenvoy/subscriber.rb +1 -1
  44. data/lib/cloudenvoy/version.rb +1 -1
  45. data/lib/cloudenvoy.rb +1 -0
  46. data/lib/generators/cloudenvoy/publisher_generator.rb +46 -0
  47. data/lib/generators/cloudenvoy/subscriber_generator.rb +46 -0
  48. data/lib/generators/cloudenvoy/templates/publisher.rb.erb +11 -0
  49. data/lib/generators/cloudenvoy/templates/publisher_spec.rb.erb +6 -0
  50. data/lib/generators/cloudenvoy/templates/subscriber.rb.erb +11 -0
  51. data/lib/generators/cloudenvoy/templates/subscriber_spec.rb.erb +6 -0
  52. metadata +28 -51
  53. data/Gemfile.lock +0 -267
  54. data/app/controllers/cloudenvoy/application_controller.rb +0 -8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- cloudenvoy (0.3.0)
4
+ cloudenvoy (0.5.0)
5
5
  activesupport
6
6
  google-cloud-pubsub (~> 2.0)
7
7
  jwt
@@ -10,198 +10,224 @@ 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.7)
14
+ actionpack (= 6.0.4.7)
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.7)
18
+ actionpack (= 6.0.4.7)
19
+ activejob (= 6.0.4.7)
20
+ activerecord (= 6.0.4.7)
21
+ activestorage (= 6.0.4.7)
22
+ activesupport (= 6.0.4.7)
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.7)
25
+ actionpack (= 6.0.4.7)
26
+ actionview (= 6.0.4.7)
27
+ activejob (= 6.0.4.7)
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.7)
31
+ actionview (= 6.0.4.7)
32
+ activesupport (= 6.0.4.7)
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.7)
38
+ actionpack (= 6.0.4.7)
39
+ activerecord (= 6.0.4.7)
40
+ activestorage (= 6.0.4.7)
41
+ activesupport (= 6.0.4.7)
42
42
  nokogiri (>= 1.8.5)
43
- actionview (6.0.3.2)
44
- activesupport (= 6.0.3.2)
43
+ actionview (6.0.4.7)
44
+ activesupport (= 6.0.4.7)
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.7)
50
+ activesupport (= 6.0.4.7)
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.7)
53
+ activesupport (= 6.0.4.7)
54
+ activerecord (6.0.4.7)
55
+ activemodel (= 6.0.4.7)
56
+ activesupport (= 6.0.4.7)
57
+ activestorage (6.0.4.7)
58
+ actionpack (= 6.0.4.7)
59
+ activejob (= 6.0.4.7)
60
+ activerecord (= 6.0.4.7)
61
+ marcel (~> 1.0.0)
62
+ activesupport (6.0.4.7)
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.10.0)
75
+ faraday-em_http (~> 1.0)
76
+ faraday-em_synchrony (~> 1.0)
77
+ faraday-excon (~> 1.1)
78
+ faraday-httpclient (~> 1.0)
79
+ faraday-multipart (~> 1.0)
80
+ faraday-net_http (~> 1.0)
81
+ faraday-net_http_persistent (~> 1.0)
82
+ faraday-patron (~> 1.0)
83
+ faraday-rack (~> 1.0)
84
+ faraday-retry (~> 1.0)
85
+ ruby2_keywords (>= 0.0.4)
86
+ faraday-em_http (1.0.0)
87
+ faraday-em_synchrony (1.0.0)
88
+ faraday-excon (1.1.0)
89
+ faraday-httpclient (1.0.1)
90
+ faraday-multipart (1.0.3)
75
91
  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)
92
+ faraday-net_http (1.0.1)
93
+ faraday-net_http_persistent (1.2.0)
94
+ faraday-patron (1.0.0)
95
+ faraday-rack (1.0.0)
96
+ faraday-retry (1.0.3)
97
+ gapic-common (0.8.0)
98
+ faraday (~> 1.3)
99
+ google-protobuf (~> 3.14)
100
+ googleapis-common-protos (>= 1.3.11, < 2.a)
101
+ googleapis-common-protos-types (>= 1.0.6, < 2.a)
102
+ googleauth (>= 0.17.0, < 2.a)
103
+ grpc (~> 1.36)
104
+ globalid (1.0.0)
105
+ activesupport (>= 5.0)
106
+ google-cloud-core (1.6.0)
85
107
  google-cloud-env (~> 1.0)
86
108
  google-cloud-errors (~> 1.0)
87
- google-cloud-env (1.3.3)
109
+ google-cloud-env (1.5.0)
88
110
  faraday (>= 0.17.3, < 2.0)
89
- google-cloud-errors (1.0.1)
90
- google-cloud-pubsub (2.0.0)
111
+ google-cloud-errors (1.2.0)
112
+ google-cloud-pubsub (2.9.1)
91
113
  concurrent-ruby (~> 1.1)
92
114
  google-cloud-core (~> 1.5)
93
115
  google-cloud-pubsub-v1 (~> 0.0)
94
- google-cloud-pubsub-v1 (0.1.2)
95
- gapic-common (~> 0.3)
116
+ google-cloud-pubsub-v1 (0.7.1)
117
+ gapic-common (>= 0.7, < 2.a)
96
118
  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)
119
+ grpc-google-iam-v1 (>= 0.6.10, < 2.a)
120
+ google-protobuf (3.19.4)
121
+ googleapis-common-protos (1.3.12)
122
+ google-protobuf (~> 3.14)
123
+ googleapis-common-protos-types (~> 1.2)
102
124
  grpc (~> 1.27)
103
- googleapis-common-protos-types (1.0.5)
104
- google-protobuf (~> 3.11)
105
- googleauth (0.13.1)
106
- faraday (>= 0.17.3, < 2.0)
125
+ googleapis-common-protos-types (1.3.0)
126
+ google-protobuf (~> 3.14)
127
+ googleauth (1.1.2)
128
+ faraday (>= 0.17.3, < 3.a)
107
129
  jwt (>= 1.4, < 3.0)
108
130
  memoist (~> 0.16)
109
131
  multi_json (~> 1.11)
110
132
  os (>= 0.9, < 2.0)
111
- signet (~> 0.14)
112
- grpc (1.32.0-universal-darwin)
113
- google-protobuf (~> 3.13)
133
+ signet (>= 0.16, < 2.a)
134
+ grpc (1.43.1)
135
+ google-protobuf (~> 3.18)
114
136
  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)
137
+ grpc-google-iam-v1 (1.0.0)
138
+ google-protobuf (~> 3.14)
139
+ googleapis-common-protos (>= 1.3.12, < 2.0)
118
140
  grpc (~> 1.27)
119
- i18n (1.8.5)
141
+ i18n (1.10.0)
120
142
  concurrent-ruby (~> 1.0)
121
- jwt (2.2.2)
122
- loofah (2.6.0)
143
+ jwt (2.3.0)
144
+ loofah (2.14.0)
123
145
  crass (~> 1.0.2)
124
146
  nokogiri (>= 1.5.9)
125
147
  mail (2.7.1)
126
148
  mini_mime (>= 0.1.1)
127
- marcel (0.3.3)
128
- mimemagic (~> 0.3.2)
149
+ marcel (1.0.2)
129
150
  memoist (0.16.2)
130
151
  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)
152
+ mini_mime (1.1.2)
153
+ mini_portile2 (2.8.0)
154
+ minitest (5.15.0)
135
155
  multi_json (1.15.0)
136
156
  multipart-post (2.1.1)
137
- nio4r (2.5.2)
138
- nokogiri (1.10.9)
139
- mini_portile2 (~> 2.4.0)
140
- os (1.1.1)
157
+ nio4r (2.5.8)
158
+ nokogiri (1.13.3)
159
+ mini_portile2 (~> 2.8.0)
160
+ racc (~> 1.4)
161
+ os (1.1.4)
141
162
  public_suffix (4.0.6)
163
+ puma (5.6.2)
164
+ nio4r (~> 2.0)
165
+ racc (1.6.0)
142
166
  rack (2.2.3)
143
167
  rack-test (1.1.0)
144
168
  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)
169
+ rails (6.0.4.7)
170
+ actioncable (= 6.0.4.7)
171
+ actionmailbox (= 6.0.4.7)
172
+ actionmailer (= 6.0.4.7)
173
+ actionpack (= 6.0.4.7)
174
+ actiontext (= 6.0.4.7)
175
+ actionview (= 6.0.4.7)
176
+ activejob (= 6.0.4.7)
177
+ activemodel (= 6.0.4.7)
178
+ activerecord (= 6.0.4.7)
179
+ activestorage (= 6.0.4.7)
180
+ activesupport (= 6.0.4.7)
157
181
  bundler (>= 1.3.0)
158
- railties (= 6.0.3.2)
182
+ railties (= 6.0.4.7)
159
183
  sprockets-rails (>= 2.0.0)
160
184
  rails-dom-testing (2.0.3)
161
185
  activesupport (>= 4.2.0)
162
186
  nokogiri (>= 1.6)
163
- rails-html-sanitizer (1.3.0)
187
+ rails-html-sanitizer (1.4.2)
164
188
  loofah (~> 2.3)
165
- railties (6.0.3.2)
166
- actionpack (= 6.0.3.2)
167
- activesupport (= 6.0.3.2)
189
+ railties (6.0.4.7)
190
+ actionpack (= 6.0.4.7)
191
+ activesupport (= 6.0.4.7)
168
192
  method_source
169
193
  rake (>= 0.8.7)
170
194
  thor (>= 0.20.3, < 2.0)
171
- rake (13.0.1)
195
+ rake (13.0.6)
172
196
  retriable (3.1.2)
173
- signet (0.14.0)
174
- addressable (~> 2.3)
175
- faraday (>= 0.17.3, < 2.0)
197
+ ruby2_keywords (0.0.5)
198
+ signet (0.16.1)
199
+ addressable (~> 2.8)
200
+ faraday (>= 0.17.5, < 3.0)
176
201
  jwt (>= 1.5, < 3.0)
177
202
  multi_json (~> 1.10)
178
- sprockets (4.0.2)
203
+ sprockets (4.0.3)
179
204
  concurrent-ruby (~> 1.0)
180
205
  rack (> 1, < 3)
181
- sprockets-rails (3.2.1)
182
- actionpack (>= 4.0)
183
- activesupport (>= 4.0)
206
+ sprockets-rails (3.4.2)
207
+ actionpack (>= 5.2)
208
+ activesupport (>= 5.2)
184
209
  sprockets (>= 3.0.0)
185
210
  sqlite3 (1.4.2)
186
- thor (1.0.1)
211
+ thor (1.2.1)
187
212
  thread_safe (0.3.6)
188
- tzinfo (1.2.7)
213
+ tzinfo (1.2.9)
189
214
  thread_safe (~> 0.1)
190
- websocket-driver (0.7.2)
215
+ websocket-driver (0.7.5)
191
216
  websocket-extensions (>= 0.1.0)
192
217
  websocket-extensions (0.1.5)
193
- zeitwerk (2.4.0)
218
+ zeitwerk (2.5.4)
194
219
 
195
220
  PLATFORMS
196
221
  ruby
197
222
 
198
223
  DEPENDENCIES
199
224
  cloudenvoy!
225
+ puma (~> 5.6.2)
200
226
  rails (~> 6.0.2)
201
227
  sqlite3
202
228
 
203
229
  RUBY VERSION
204
- ruby 2.5.5p157
230
+ ruby 3.0.0p0
205
231
 
206
232
  BUNDLED WITH
207
- 2.1.4
233
+ 2.3.4
@@ -22,7 +22,7 @@ HelloPublisher.publish('Some message')
22
22
  * Add the configuration of your GCP Pub/Sub
23
23
  * Set `config.processor_host` to the ngrok http or https url
24
24
  * Set `config.mode` to `:production`
25
- 5. Launch the server: `foreman start web`
25
+ 5. Launch the server: `foreman start`
26
26
  6. Open a Rails console: `rails c`
27
27
  7. Publish messages
28
28
  ```ruby
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ ruby '3.0.0'
7
+
8
+ # Web framework
9
+ gem 'sinatra'
10
+
11
+ # Server
12
+ gem 'puma', '~> 5.6.2'
13
+
14
+ # Support rake tasks
15
+ gem 'rake'
16
+
17
+ # Pub/sub via cloudenvoy
18
+ gem 'cloudenvoy', path: '../../'
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ cloudenvoy (0.5.0)
5
+ activesupport
6
+ google-cloud-pubsub (~> 2.0)
7
+ jwt
8
+ retriable
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (7.0.2.3)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ addressable (2.8.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
+ concurrent-ruby (1.1.9)
21
+ faraday (1.10.0)
22
+ faraday-em_http (~> 1.0)
23
+ faraday-em_synchrony (~> 1.0)
24
+ faraday-excon (~> 1.1)
25
+ faraday-httpclient (~> 1.0)
26
+ faraday-multipart (~> 1.0)
27
+ faraday-net_http (~> 1.0)
28
+ faraday-net_http_persistent (~> 1.0)
29
+ faraday-patron (~> 1.0)
30
+ faraday-rack (~> 1.0)
31
+ faraday-retry (~> 1.0)
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-multipart (1.0.3)
38
+ multipart-post (>= 1.2, < 3)
39
+ faraday-net_http (1.0.1)
40
+ faraday-net_http_persistent (1.2.0)
41
+ faraday-patron (1.0.0)
42
+ faraday-rack (1.0.0)
43
+ faraday-retry (1.0.3)
44
+ gapic-common (0.8.0)
45
+ faraday (~> 1.3)
46
+ google-protobuf (~> 3.14)
47
+ googleapis-common-protos (>= 1.3.11, < 2.a)
48
+ googleapis-common-protos-types (>= 1.0.6, < 2.a)
49
+ googleauth (>= 0.17.0, < 2.a)
50
+ grpc (~> 1.36)
51
+ google-cloud-core (1.6.0)
52
+ google-cloud-env (~> 1.0)
53
+ google-cloud-errors (~> 1.0)
54
+ google-cloud-env (1.5.0)
55
+ faraday (>= 0.17.3, < 2.0)
56
+ google-cloud-errors (1.2.0)
57
+ google-cloud-pubsub (2.9.1)
58
+ concurrent-ruby (~> 1.1)
59
+ google-cloud-core (~> 1.5)
60
+ google-cloud-pubsub-v1 (~> 0.0)
61
+ google-cloud-pubsub-v1 (0.7.1)
62
+ gapic-common (>= 0.7, < 2.a)
63
+ google-cloud-errors (~> 1.0)
64
+ grpc-google-iam-v1 (>= 0.6.10, < 2.a)
65
+ google-protobuf (3.19.4-x86_64-darwin)
66
+ google-protobuf (3.19.4-x86_64-linux)
67
+ googleapis-common-protos (1.3.12)
68
+ google-protobuf (~> 3.14)
69
+ googleapis-common-protos-types (~> 1.2)
70
+ grpc (~> 1.27)
71
+ googleapis-common-protos-types (1.3.0)
72
+ google-protobuf (~> 3.14)
73
+ googleauth (1.1.2)
74
+ faraday (>= 0.17.3, < 3.a)
75
+ jwt (>= 1.4, < 3.0)
76
+ memoist (~> 0.16)
77
+ multi_json (~> 1.11)
78
+ os (>= 0.9, < 2.0)
79
+ signet (>= 0.16, < 2.a)
80
+ grpc (1.43.1-universal-darwin)
81
+ google-protobuf (~> 3.18)
82
+ googleapis-common-protos-types (~> 1.0)
83
+ grpc (1.43.1-x86_64-linux)
84
+ google-protobuf (~> 3.18)
85
+ googleapis-common-protos-types (~> 1.0)
86
+ grpc-google-iam-v1 (1.0.0)
87
+ google-protobuf (~> 3.14)
88
+ googleapis-common-protos (>= 1.3.12, < 2.0)
89
+ grpc (~> 1.27)
90
+ i18n (1.10.0)
91
+ concurrent-ruby (~> 1.0)
92
+ jwt (2.3.0)
93
+ memoist (0.16.2)
94
+ minitest (5.15.0)
95
+ multi_json (1.15.0)
96
+ multipart-post (2.1.1)
97
+ mustermann (1.1.1)
98
+ ruby2_keywords (~> 0.0.1)
99
+ nio4r (2.5.8)
100
+ os (1.1.4)
101
+ public_suffix (4.0.6)
102
+ puma (5.6.2)
103
+ nio4r (~> 2.0)
104
+ rack (2.2.3)
105
+ rack-protection (2.2.0)
106
+ rack
107
+ rake (13.0.6)
108
+ retriable (3.1.2)
109
+ ruby2_keywords (0.0.5)
110
+ signet (0.16.1)
111
+ addressable (~> 2.8)
112
+ faraday (>= 0.17.5, < 3.0)
113
+ jwt (>= 1.5, < 3.0)
114
+ multi_json (~> 1.10)
115
+ sinatra (2.2.0)
116
+ mustermann (~> 1.0)
117
+ rack (~> 2.2)
118
+ rack-protection (= 2.2.0)
119
+ tilt (~> 2.0)
120
+ tilt (2.0.10)
121
+ tzinfo (2.0.4)
122
+ concurrent-ruby (~> 1.0)
123
+
124
+ PLATFORMS
125
+ x86_64-darwin-17
126
+ x86_64-darwin-19
127
+ x86_64-linux
128
+
129
+ DEPENDENCIES
130
+ cloudenvoy!
131
+ puma (~> 5.6.2)
132
+ rake
133
+ sinatra
134
+
135
+ RUBY VERSION
136
+ ruby 3.0.0p0
137
+
138
+ BUNDLED WITH
139
+ 2.3.4
@@ -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
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Force logging to be realtime
4
+ STDOUT.sync = true
5
+
6
+ # Require project files
7
+ require 'sinatra'
8
+ Dir.glob('./config/initializers/*.rb').each { |file| require file }
9
+ Dir.glob('./app/publishers/*.rb').each { |file| require file }
10
+ Dir.glob('./app/subscribers/*.rb').each { |file| require file }
11
+
12
+ #---------------------------------------------------
13
+ # Routes
14
+ #---------------------------------------------------
15
+
16
+ get '/' do
17
+ 'Hello!'
18
+ end
19
+
20
+ post '/cloudenvoy/receive' do
21
+ begin
22
+ # Authenticate request
23
+ Cloudenvoy::Authenticator.verify!(params['token'])
24
+
25
+ # Parse message descriptor
26
+ content = request.body.read
27
+ msg_descriptor = JSON.parse(content).except('token')
28
+
29
+ # Process message descriptor
30
+ Cloudenvoy::Subscriber.execute_from_descriptor(msg_descriptor)
31
+ return 204
32
+ rescue Cloudenvoy::InvalidSubscriberError
33
+ # 404: Message delivery will be retried
34
+ return 404
35
+ rescue StandardError => e
36
+ # 422: Message delivery will be retried
37
+ logger.info([e.message, e.backtrace].flatten.join("\n"))
38
+ return 422
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require File.expand_path('../app.rb', __dir__)
6
+
7
+ require 'irb'
8
+ IRB.start(__FILE__)