cloudenvoy 0.3.1 → 0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) 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 +33 -2
  10. data/README.md +4 -4
  11. data/app/controllers/cloudenvoy/subscriber_controller.rb +6 -5
  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 +132 -110
  16. data/examples/rails/README.md +1 -1
  17. data/examples/sinatra/Gemfile +18 -0
  18. data/examples/sinatra/Gemfile.lock +131 -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 +111 -88
  29. data/gemfiles/rails_6.0.gemfile +1 -0
  30. data/gemfiles/rails_6.0.gemfile.lock +112 -89
  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 +89 -187
  35. data/gemfiles/semantic_logger_4.6.gemfile +1 -0
  36. data/gemfiles/semantic_logger_4.6.gemfile.lock +89 -187
  37. data/gemfiles/semantic_logger_4.7.0.gemfile +1 -0
  38. data/gemfiles/semantic_logger_4.7.0.gemfile.lock +89 -187
  39. data/gemfiles/semantic_logger_4.7.2.gemfile +1 -0
  40. data/gemfiles/semantic_logger_4.7.2.gemfile.lock +89 -187
  41. data/lib/cloudenvoy/backend/google_pub_sub.rb +18 -3
  42. data/lib/cloudenvoy/message.rb +2 -2
  43. data/lib/cloudenvoy/publisher.rb +1 -0
  44. data/lib/cloudenvoy/subscriber.rb +3 -2
  45. data/lib/cloudenvoy/version.rb +1 -1
  46. data/lib/cloudenvoy.rb +1 -0
  47. data/lib/generators/cloudenvoy/publisher_generator.rb +46 -0
  48. data/lib/generators/cloudenvoy/subscriber_generator.rb +46 -0
  49. data/lib/generators/cloudenvoy/templates/publisher.rb.erb +11 -0
  50. data/lib/generators/cloudenvoy/templates/publisher_spec.rb.erb +6 -0
  51. data/lib/generators/cloudenvoy/templates/subscriber.rb.erb +11 -0
  52. data/lib/generators/cloudenvoy/templates/subscriber_spec.rb.erb +6 -0
  53. data/lib/tasks/cloudenvoy.rake +4 -4
  54. metadata +30 -53
  55. data/Gemfile.lock +0 -267
  56. 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.4.2)
5
5
  activesupport
6
6
  google-cloud-pubsub (~> 2.0)
7
7
  jwt
@@ -10,198 +10,220 @@ 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.4)
14
+ actionpack (= 6.0.4.4)
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.4)
18
+ actionpack (= 6.0.4.4)
19
+ activejob (= 6.0.4.4)
20
+ activerecord (= 6.0.4.4)
21
+ activestorage (= 6.0.4.4)
22
+ activesupport (= 6.0.4.4)
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.4)
25
+ actionpack (= 6.0.4.4)
26
+ actionview (= 6.0.4.4)
27
+ activejob (= 6.0.4.4)
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.4)
31
+ actionview (= 6.0.4.4)
32
+ activesupport (= 6.0.4.4)
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.4)
38
+ actionpack (= 6.0.4.4)
39
+ activerecord (= 6.0.4.4)
40
+ activestorage (= 6.0.4.4)
41
+ activesupport (= 6.0.4.4)
42
42
  nokogiri (>= 1.8.5)
43
- actionview (6.0.3.2)
44
- activesupport (= 6.0.3.2)
43
+ actionview (6.0.4.4)
44
+ activesupport (= 6.0.4.4)
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.4)
50
+ activesupport (= 6.0.4.4)
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.4)
53
+ activesupport (= 6.0.4.4)
54
+ activerecord (6.0.4.4)
55
+ activemodel (= 6.0.4.4)
56
+ activesupport (= 6.0.4.4)
57
+ activestorage (6.0.4.4)
58
+ actionpack (= 6.0.4.4)
59
+ activejob (= 6.0.4.4)
60
+ activerecord (= 6.0.4.4)
61
+ marcel (~> 1.0.0)
62
+ activesupport (6.0.4.4)
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 (1.0.0)
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.9.0)
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.1)
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.19.1)
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.3.0)
122
+ google-protobuf (~> 3.14)
123
+ googleauth (1.1.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.11)
120
138
  concurrent-ruby (~> 1.0)
121
- jwt (2.2.2)
122
- loofah (2.6.0)
139
+ jwt (2.3.0)
140
+ loofah (2.13.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.2)
149
+ mini_portile2 (2.6.1)
150
+ minitest (5.15.0)
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)
140
- os (1.1.1)
153
+ nio4r (2.5.8)
154
+ nokogiri (1.12.5)
155
+ mini_portile2 (~> 2.6.1)
156
+ racc (~> 1.4)
157
+ os (1.1.4)
141
158
  public_suffix (4.0.6)
159
+ puma (5.5.2)
160
+ nio4r (~> 2.0)
161
+ racc (1.6.0)
142
162
  rack (2.2.3)
143
163
  rack-test (1.1.0)
144
164
  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)
165
+ rails (6.0.4.4)
166
+ actioncable (= 6.0.4.4)
167
+ actionmailbox (= 6.0.4.4)
168
+ actionmailer (= 6.0.4.4)
169
+ actionpack (= 6.0.4.4)
170
+ actiontext (= 6.0.4.4)
171
+ actionview (= 6.0.4.4)
172
+ activejob (= 6.0.4.4)
173
+ activemodel (= 6.0.4.4)
174
+ activerecord (= 6.0.4.4)
175
+ activestorage (= 6.0.4.4)
176
+ activesupport (= 6.0.4.4)
157
177
  bundler (>= 1.3.0)
158
- railties (= 6.0.3.2)
178
+ railties (= 6.0.4.4)
159
179
  sprockets-rails (>= 2.0.0)
160
180
  rails-dom-testing (2.0.3)
161
181
  activesupport (>= 4.2.0)
162
182
  nokogiri (>= 1.6)
163
- rails-html-sanitizer (1.3.0)
183
+ rails-html-sanitizer (1.4.2)
164
184
  loofah (~> 2.3)
165
- railties (6.0.3.2)
166
- actionpack (= 6.0.3.2)
167
- activesupport (= 6.0.3.2)
185
+ railties (6.0.4.4)
186
+ actionpack (= 6.0.4.4)
187
+ activesupport (= 6.0.4.4)
168
188
  method_source
169
189
  rake (>= 0.8.7)
170
190
  thor (>= 0.20.3, < 2.0)
171
- rake (13.0.1)
191
+ rake (13.0.6)
172
192
  retriable (3.1.2)
173
- signet (0.14.0)
174
- addressable (~> 2.3)
193
+ ruby2_keywords (0.0.5)
194
+ signet (0.16.0)
195
+ addressable (~> 2.8)
175
196
  faraday (>= 0.17.3, < 2.0)
176
197
  jwt (>= 1.5, < 3.0)
177
198
  multi_json (~> 1.10)
178
199
  sprockets (4.0.2)
179
200
  concurrent-ruby (~> 1.0)
180
201
  rack (> 1, < 3)
181
- sprockets-rails (3.2.1)
182
- actionpack (>= 4.0)
183
- activesupport (>= 4.0)
202
+ sprockets-rails (3.4.2)
203
+ actionpack (>= 5.2)
204
+ activesupport (>= 5.2)
184
205
  sprockets (>= 3.0.0)
185
206
  sqlite3 (1.4.2)
186
- thor (1.0.1)
207
+ thor (1.2.1)
187
208
  thread_safe (0.3.6)
188
- tzinfo (1.2.7)
209
+ tzinfo (1.2.9)
189
210
  thread_safe (~> 0.1)
190
- websocket-driver (0.7.2)
211
+ websocket-driver (0.7.5)
191
212
  websocket-extensions (>= 0.1.0)
192
213
  websocket-extensions (0.1.5)
193
- zeitwerk (2.4.0)
214
+ zeitwerk (2.5.3)
194
215
 
195
216
  PLATFORMS
196
217
  ruby
197
218
 
198
219
  DEPENDENCIES
199
220
  cloudenvoy!
221
+ puma (~> 5.5.2)
200
222
  rails (~> 6.0.2)
201
223
  sqlite3
202
224
 
203
225
  RUBY VERSION
204
- ruby 2.5.5p157
226
+ ruby 3.0.0p0
205
227
 
206
228
  BUNDLED WITH
207
- 2.1.4
229
+ 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.5.2'
13
+
14
+ # Support rake tasks
15
+ gem 'rake'
16
+
17
+ # Pub/sub via cloudenvoy
18
+ gem 'cloudenvoy', path: '../../'
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ cloudenvoy (0.4.2)
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.0)
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.8.0)
22
+ faraday-em_http (~> 1.0)
23
+ faraday-em_synchrony (~> 1.0)
24
+ faraday-excon (~> 1.1)
25
+ faraday-httpclient (~> 1.0.1)
26
+ faraday-net_http (~> 1.0)
27
+ faraday-net_http_persistent (~> 1.1)
28
+ faraday-patron (~> 1.0)
29
+ faraday-rack (~> 1.0)
30
+ multipart-post (>= 1.2, < 3)
31
+ ruby2_keywords (>= 0.0.4)
32
+ faraday-em_http (1.0.0)
33
+ faraday-em_synchrony (1.0.0)
34
+ faraday-excon (1.1.0)
35
+ faraday-httpclient (1.0.1)
36
+ faraday-net_http (1.0.1)
37
+ faraday-net_http_persistent (1.2.0)
38
+ faraday-patron (1.0.0)
39
+ faraday-rack (1.0.0)
40
+ gapic-common (0.7.0)
41
+ faraday (~> 1.3)
42
+ google-protobuf (~> 3.14)
43
+ googleapis-common-protos (>= 1.3.11, < 2.a)
44
+ googleapis-common-protos-types (>= 1.0.6, < 2.a)
45
+ googleauth (>= 0.17.0, < 2.a)
46
+ grpc (~> 1.36)
47
+ google-cloud-core (1.6.0)
48
+ google-cloud-env (~> 1.0)
49
+ google-cloud-errors (~> 1.0)
50
+ google-cloud-env (1.5.0)
51
+ faraday (>= 0.17.3, < 2.0)
52
+ google-cloud-errors (1.2.0)
53
+ google-cloud-pubsub (2.9.0)
54
+ concurrent-ruby (~> 1.1)
55
+ google-cloud-core (~> 1.5)
56
+ google-cloud-pubsub-v1 (~> 0.0)
57
+ google-cloud-pubsub-v1 (0.6.1)
58
+ gapic-common (>= 0.7, < 2.a)
59
+ google-cloud-errors (~> 1.0)
60
+ grpc-google-iam-v1 (>= 0.6.10, < 2.a)
61
+ google-protobuf (3.19.1-x86_64-darwin)
62
+ googleapis-common-protos (1.3.12)
63
+ google-protobuf (~> 3.14)
64
+ googleapis-common-protos-types (~> 1.2)
65
+ grpc (~> 1.27)
66
+ googleapis-common-protos-types (1.3.0)
67
+ google-protobuf (~> 3.14)
68
+ googleauth (1.1.0)
69
+ faraday (>= 0.17.3, < 2.0)
70
+ jwt (>= 1.4, < 3.0)
71
+ memoist (~> 0.16)
72
+ multi_json (~> 1.11)
73
+ os (>= 0.9, < 2.0)
74
+ signet (>= 0.16, < 2.a)
75
+ grpc (1.40.0-universal-darwin)
76
+ google-protobuf (~> 3.15)
77
+ googleapis-common-protos-types (~> 1.0)
78
+ grpc-google-iam-v1 (1.0.0)
79
+ google-protobuf (~> 3.14)
80
+ googleapis-common-protos (>= 1.3.12, < 2.0)
81
+ grpc (~> 1.27)
82
+ i18n (1.8.11)
83
+ concurrent-ruby (~> 1.0)
84
+ jwt (2.3.0)
85
+ memoist (0.16.2)
86
+ minitest (5.15.0)
87
+ multi_json (1.15.0)
88
+ multipart-post (2.1.1)
89
+ mustermann (1.1.1)
90
+ ruby2_keywords (~> 0.0.1)
91
+ nio4r (2.5.8)
92
+ os (1.1.4)
93
+ public_suffix (4.0.6)
94
+ puma (5.5.2)
95
+ nio4r (~> 2.0)
96
+ rack (2.2.3)
97
+ rack-protection (2.1.0)
98
+ rack
99
+ rake (13.0.6)
100
+ retriable (3.1.2)
101
+ ruby2_keywords (0.0.5)
102
+ signet (0.16.0)
103
+ addressable (~> 2.8)
104
+ faraday (>= 0.17.3, < 2.0)
105
+ jwt (>= 1.5, < 3.0)
106
+ multi_json (~> 1.10)
107
+ sinatra (2.1.0)
108
+ mustermann (~> 1.0)
109
+ rack (~> 2.2)
110
+ rack-protection (= 2.1.0)
111
+ tilt (~> 2.0)
112
+ tilt (2.0.10)
113
+ tzinfo (2.0.4)
114
+ concurrent-ruby (~> 1.0)
115
+
116
+ PLATFORMS
117
+ x86_64-darwin-17
118
+ x86_64-darwin-19
119
+
120
+ DEPENDENCIES
121
+ cloudenvoy!
122
+ grpc (~> 1.40.0)
123
+ puma (~> 5.5.2)
124
+ rake
125
+ sinatra
126
+
127
+ RUBY VERSION
128
+ ruby 3.0.0p0
129
+
130
+ BUNDLED WITH
131
+ 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__)
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Require cloudenvoy and its extensions
4
+ require 'cloudenvoy'
5
+
6
+ Cloudenvoy.configure do |config|
7
+ #
8
+ # Secret used to authenticate job requests
9
+ #
10
+ config.secret = 'some-secret'
11
+
12
+ #
13
+ # GCP Configuration
14
+ #
15
+ config.gcp_project_id = 'some-project'
16
+ config.gcp_sub_prefix = 'my-app'
17
+
18
+ #
19
+ # Domain
20
+ #
21
+ # config.processor_host = 'https://xxxx.ngrok.io'
22
+ #
23
+ config.processor_host = 'http://localhost:3000'
24
+
25
+ #
26
+ # Uncomment to process messages via Pub/Sub.
27
+ # Requires a ngrok tunnel.
28
+ #
29
+ # config.mode = :production
30
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"