cloudenvoy 0.4.2 → 0.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint_rubocop.yml +20 -0
- data/.github/workflows/{test.yml → test_ruby_2.5_2.6.yml} +8 -13
- data/.github/workflows/test_ruby_2.7.yml +36 -0
- data/.github/workflows/test_ruby_3.x.yml +35 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +17 -16
- data/Appraisals +24 -4
- data/CHANGELOG.md +18 -0
- data/README.md +39 -2
- data/cloudenvoy.gemspec +2 -6
- data/examples/rails/.ruby-version +1 -1
- data/examples/rails/Gemfile +4 -1
- data/examples/rails/Gemfile.lock +92 -85
- data/examples/rails/README.md +5 -1
- data/examples/rails/app/subscribers/hello_subscriber.rb +1 -1
- data/examples/rails/config/environments/production.rb +1 -1
- data/examples/rails/config/puma.rb +3 -3
- data/examples/sinatra/Gemfile +4 -1
- data/examples/sinatra/Gemfile.lock +40 -28
- data/examples/sinatra/README.md +4 -0
- data/examples/sinatra/app/subscribers/hello_subscriber.rb +1 -1
- data/examples/sinatra/app.rb +4 -4
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_5.2.gemfile +1 -0
- data/gemfiles/rails_6.0.gemfile +1 -0
- data/gemfiles/rails_6.1.gemfile +8 -0
- data/gemfiles/rails_7.0.gemfile +8 -0
- data/gemfiles/semantic_logger_3.4.gemfile +1 -0
- data/gemfiles/semantic_logger_4.6.gemfile +1 -0
- data/gemfiles/semantic_logger_4.7.0.gemfile +1 -0
- data/gemfiles/semantic_logger_4.7.2.gemfile +1 -0
- data/lib/cloudenvoy/backend/google_pub_sub.rb +37 -5
- data/lib/cloudenvoy/backend/memory_pub_sub.rb +25 -1
- data/lib/cloudenvoy/config.rb +1 -1
- data/lib/cloudenvoy/message.rb +2 -2
- data/lib/cloudenvoy/pub_sub_client.rb +13 -1
- data/lib/cloudenvoy/publisher.rb +39 -5
- data/lib/cloudenvoy/publisher_logger.rb +1 -1
- data/lib/cloudenvoy/version.rb +1 -1
- data/lib/cloudenvoy.rb +13 -0
- metadata +15 -57
- data/gemfiles/rails_5.2.gemfile.lock +0 -264
- data/gemfiles/rails_6.0.gemfile.lock +0 -280
- data/gemfiles/semantic_logger_3.4.gemfile.lock +0 -279
- data/gemfiles/semantic_logger_4.6.gemfile.lock +0 -279
- data/gemfiles/semantic_logger_4.7.0.gemfile.lock +0 -279
- data/gemfiles/semantic_logger_4.7.2.gemfile.lock +0 -279
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb4f27d4f01e971d8542f5768166caa9d797ad9799372bf167ddfe5e970ecb51
|
4
|
+
data.tar.gz: 5f2ed34bde0799fc94d574203f4589ede66b90da39a4f8e9bf4b6a8b41fac483
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a71d84e06873d76352df8ccef0ee32f95a439e62447bf90e2a57694816753337186b6f57ad9864911d8bfec270eff31b8ccd0183c36f894ce030cd1b5c6ccb8
|
7
|
+
data.tar.gz: ac0be67ec3bc95c2b9cc32745dcbd72c87fcd06cf329dbf007cde92139b8c70a712545afc7e69bb44bd61397641989e1af7f8ff41bdeb82efe5400ca84993a58
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Rubocop
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- uses: zhulik/redis-action@1.1.0
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: '3.0.1'
|
15
|
+
bundler-cache: true
|
16
|
+
- name: Lint codebase
|
17
|
+
run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
20
|
+
bundle exec rubocop
|
@@ -1,10 +1,6 @@
|
|
1
|
-
name:
|
1
|
+
name: Ruby 2.5/2.6
|
2
2
|
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
3
|
+
on: [push, pull_request]
|
8
4
|
|
9
5
|
jobs:
|
10
6
|
build:
|
@@ -12,30 +8,29 @@ jobs:
|
|
12
8
|
strategy:
|
13
9
|
matrix:
|
14
10
|
ruby:
|
15
|
-
- '2.5.
|
16
|
-
- '2.6.
|
11
|
+
- '2.5.9'
|
12
|
+
- '2.6.7'
|
17
13
|
appraisal:
|
18
14
|
- 'rails-5.2'
|
19
15
|
- 'rails-6.0'
|
16
|
+
- 'rails-6.1'
|
20
17
|
- 'semantic_logger-3.4'
|
21
18
|
- 'semantic_logger-4.6'
|
22
19
|
- 'semantic_logger-4.7.0'
|
23
20
|
- 'semantic_logger-4.7.2'
|
24
21
|
steps:
|
25
|
-
- name: Setup System
|
26
|
-
run: sudo apt-get install libsqlite3-dev
|
27
22
|
- uses: actions/checkout@v2
|
28
23
|
- uses: zhulik/redis-action@1.1.0
|
29
|
-
- name: Set up Ruby
|
30
|
-
uses:
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
31
26
|
with:
|
32
27
|
ruby-version: ${{ matrix.ruby }}
|
28
|
+
bundler-cache: true
|
33
29
|
- name: Build and test with Rake
|
34
30
|
env:
|
35
31
|
APPRAISAL_CONTEXT: ${{ matrix.appraisal }}
|
36
32
|
run: |
|
37
33
|
gem install bundler
|
38
34
|
bundle install --jobs 4 --retry 3
|
39
|
-
bundle exec rubocop
|
40
35
|
bundle exec appraisal ${APPRAISAL_CONTEXT} bundle
|
41
36
|
bundle exec appraisal ${APPRAISAL_CONTEXT} rspec
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Ruby 2.7
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby:
|
11
|
+
- '2.7.5'
|
12
|
+
appraisal:
|
13
|
+
- 'rails-5.2'
|
14
|
+
- 'rails-6.0'
|
15
|
+
- 'rails-6.1'
|
16
|
+
- 'rails-7.0'
|
17
|
+
- 'semantic_logger-3.4'
|
18
|
+
- 'semantic_logger-4.6'
|
19
|
+
- 'semantic_logger-4.7.0'
|
20
|
+
- 'semantic_logger-4.7.2'
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
- uses: zhulik/redis-action@1.1.0
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Build and test with Rake
|
30
|
+
env:
|
31
|
+
APPRAISAL_CONTEXT: ${{ matrix.appraisal }}
|
32
|
+
run: |
|
33
|
+
gem install bundler
|
34
|
+
bundle install --jobs 4 --retry 3
|
35
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} bundle
|
36
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} rspec
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: Ruby 3.x
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby:
|
11
|
+
- '3.0.1'
|
12
|
+
# - '3.1.0'
|
13
|
+
appraisal:
|
14
|
+
- 'rails-6.1'
|
15
|
+
- 'rails-7.0'
|
16
|
+
- 'semantic_logger-3.4'
|
17
|
+
- 'semantic_logger-4.6'
|
18
|
+
- 'semantic_logger-4.7.0'
|
19
|
+
- 'semantic_logger-4.7.2'
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- uses: zhulik/redis-action@1.1.0
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
bundler-cache: true
|
28
|
+
- name: Build and test with Rake
|
29
|
+
env:
|
30
|
+
APPRAISAL_CONTEXT: ${{ matrix.appraisal }}
|
31
|
+
run: |
|
32
|
+
gem install bundler
|
33
|
+
bundle install --jobs 4 --retry 3
|
34
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} bundle
|
35
|
+
bundle exec appraisal ${APPRAISAL_CONTEXT} rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
|
3
3
|
AllCops:
|
4
|
+
NewCops: enable
|
4
5
|
Exclude:
|
5
6
|
- 'gemfiles/**/*'
|
6
7
|
- 'vendor/**/*'
|
7
8
|
|
9
|
+
Layout/LineLength:
|
10
|
+
Max: 160
|
11
|
+
|
8
12
|
Metrics/ClassLength:
|
9
13
|
Max: 150
|
10
14
|
|
@@ -12,14 +16,20 @@ Metrics/ModuleLength:
|
|
12
16
|
Max: 150
|
13
17
|
|
14
18
|
Metrics/AbcSize:
|
15
|
-
Max:
|
16
|
-
|
17
|
-
Metrics/LineLength:
|
18
|
-
Max: 120
|
19
|
+
Max: 30
|
19
20
|
|
20
21
|
Metrics/MethodLength:
|
21
22
|
Max: 20
|
22
23
|
|
24
|
+
Metrics/BlockLength:
|
25
|
+
Exclude:
|
26
|
+
- cloudenvoy.gemspec
|
27
|
+
- lib/tasks/**/*
|
28
|
+
- 'spec/**/*'
|
29
|
+
|
30
|
+
Metrics/ParameterLists:
|
31
|
+
CountKeywordArgs: false
|
32
|
+
|
23
33
|
RSpec/ExpectInHook:
|
24
34
|
Enabled: false
|
25
35
|
|
@@ -29,19 +39,10 @@ RSpec/EmptyLineAfterHook:
|
|
29
39
|
RSpec/ScatteredSetup:
|
30
40
|
Enabled: false
|
31
41
|
|
32
|
-
|
33
|
-
|
34
|
-
- cloudenvoy.gemspec
|
35
|
-
- lib/tasks/**/*
|
36
|
-
- 'spec/**/*'
|
42
|
+
RSpec/MessageSpies:
|
43
|
+
Enabled: false
|
37
44
|
|
38
45
|
Style/Documentation:
|
39
46
|
Exclude:
|
40
47
|
- 'examples/**/*'
|
41
|
-
- 'spec/**/*'
|
42
|
-
|
43
|
-
Metrics/ParameterLists:
|
44
|
-
CountKeywordArgs: false
|
45
|
-
|
46
|
-
RSpec/MessageSpies:
|
47
|
-
Enabled: false
|
48
|
+
- 'spec/**/*'
|
data/Appraisals
CHANGED
@@ -1,25 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
if RUBY_VERSION < '3'
|
4
|
+
appraise 'rails-5.2' do
|
5
|
+
gem 'rails', '5.2'
|
6
|
+
gem 'rspec-rails'
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise 'rails-6.0' do
|
10
|
+
gem 'rails', '6.0'
|
11
|
+
gem 'rspec-rails'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise 'rails-6.1' do
|
16
|
+
gem 'rails', '6.1'
|
17
|
+
gem 'rspec-rails'
|
5
18
|
end
|
6
19
|
|
7
|
-
|
8
|
-
|
20
|
+
if RUBY_VERSION >= '2.7'
|
21
|
+
appraise 'rails-7.0' do
|
22
|
+
gem 'rails', '7.0'
|
23
|
+
gem 'rspec-rails'
|
24
|
+
end
|
9
25
|
end
|
10
26
|
|
11
27
|
appraise 'semantic_logger-3.4' do
|
28
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
12
29
|
gem 'semantic_logger', '3.4.1'
|
13
30
|
end
|
14
31
|
|
15
32
|
appraise 'semantic_logger-4.6' do
|
33
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
16
34
|
gem 'semantic_logger', '4.6.1'
|
17
35
|
end
|
18
36
|
|
19
37
|
appraise 'semantic_logger-4.7.0' do
|
38
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
20
39
|
gem 'semantic_logger', '4.7.0'
|
21
40
|
end
|
22
41
|
|
23
42
|
appraise 'semantic_logger-4.7.2' do
|
43
|
+
gem 'activesupport', '6.1' # ruby 2.5 / 2.6 compatibility
|
24
44
|
gem 'semantic_logger', '4.7.2'
|
25
45
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.6.rc1](https://github.com/keypup-io/cloudenvoy/tree/v0.6.rc1) (2022-04-11)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.5.0...v0.6.rc1)
|
6
|
+
|
7
|
+
**Improvements:**
|
8
|
+
- Pub/sub: Add `publish_all` method to publish multiple messages in one batch
|
9
|
+
- Ruby: Drop support for Ruby `2.3`
|
10
|
+
- Style: Upgrade rubocop to `0.93.0`
|
11
|
+
|
12
|
+
## [v0.5.0](https://github.com/keypup-io/cloudenvoy/tree/v0.5.0) (2022-03-11)
|
13
|
+
|
14
|
+
[Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.2...v0.5.0)
|
15
|
+
|
16
|
+
**Improvements:**
|
17
|
+
- Ruby 3: Rework method arguments to be compatible with Ruby 3
|
18
|
+
- Tests: Separate test environment for Ruby 2 and Ruby 3
|
19
|
+
- Tests: Do not load Rails by default and skip Rails-specific tests in non-Rails appraisals
|
20
|
+
|
3
21
|
## [v0.4.2](https://github.com/keypup-io/cloudenvoy/tree/v0.4.2) (2021-10-25)
|
4
22
|
|
5
23
|
[Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.1...v0.4.2)
|
data/README.md
CHANGED
@@ -133,7 +133,12 @@ rails s -p 3000
|
|
133
133
|
|
134
134
|
Open a Rails console and send a message
|
135
135
|
```ruby
|
136
|
+
# One message at a time
|
136
137
|
DummyPublisher.publish('Hello pub/sub')
|
138
|
+
|
139
|
+
# Publish multiple messages in one batch
|
140
|
+
# Only available since v0.6.rc1
|
141
|
+
DummyPublisher.publish_all(['Hello pub/sub', 'Hello again!', 'Hello again and again!'])
|
137
142
|
```
|
138
143
|
|
139
144
|
Your Rails logs should display the following:
|
@@ -249,10 +254,21 @@ DummySubscriber.setup
|
|
249
254
|
## Publishing messages
|
250
255
|
|
251
256
|
### Sending messages
|
257
|
+
**Note**: The `publish_all` method is only available since `v0.6.rc1`
|
252
258
|
|
253
259
|
Cloudenvoy provides a helper method to publish arbitrary messages to any topic.
|
254
260
|
```ruby
|
261
|
+
# Publish a single message
|
255
262
|
Cloudenvoy.publish('my-topic', { 'some' => 'payload' }, { 'optional' => 'message attribute' })
|
263
|
+
|
264
|
+
# Publish multiple messages in one batch
|
265
|
+
# Only available since v0.6.rc1
|
266
|
+
Cloudenvoy.publish_all('my-topic', [
|
267
|
+
# Message 1
|
268
|
+
[{ 'some' => 'msg1 payload' }, { 'optional' => 'msg1 attribute' }],
|
269
|
+
# Message 2
|
270
|
+
[{ 'some' => 'msg2 payload' }, { 'optional' => 'msg2 attribute' }]
|
271
|
+
])
|
256
272
|
```
|
257
273
|
|
258
274
|
This helper is useful for sending basic messages however it is not the preferred way of sending messages as you will quickly clutter your application with message formatting logic over time.
|
@@ -289,8 +305,21 @@ Then in your user model you can do the following:
|
|
289
305
|
class User < ApplicationRecord
|
290
306
|
after_create :publish_user
|
291
307
|
|
308
|
+
# Example: publish multiple messages in one batch
|
309
|
+
# Only available since v0.6.rc1
|
310
|
+
#
|
311
|
+
#
|
312
|
+
# Set user status to 'active' without involving callbacks
|
313
|
+
# then manually publish the new state of users in one batch
|
314
|
+
def self.enable_all_users
|
315
|
+
User.update_all(status: 'active', updated_at: Time.current)
|
316
|
+
UserPublisher.publish_all(User.all)
|
317
|
+
end
|
318
|
+
|
292
319
|
private
|
293
320
|
|
321
|
+
# Example: publish one message at a time
|
322
|
+
#
|
294
323
|
# Publish users after they have been created
|
295
324
|
def publish_user
|
296
325
|
UserPublisher.publish(self)
|
@@ -601,9 +630,17 @@ end
|
|
601
630
|
|
602
631
|
## Development
|
603
632
|
|
604
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
633
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
634
|
+
|
635
|
+
For tests, run `rake` to run the tests. Note that Rails is not in context by default, which means Rails-specific test will not run.
|
636
|
+
For tests including Rails-specific tests, run `bundle exec appraisal rails-7.0 rake`
|
637
|
+
For all context-specific tests (incl. Rails), run the [appraisal tests](Appraisals) using `bundle exec appraisal rake`.
|
638
|
+
|
639
|
+
You can run `bin/console` for an interactive prompt that will allow you to experiment.
|
640
|
+
|
641
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
605
642
|
|
606
|
-
To
|
643
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
607
644
|
|
608
645
|
## Contributing
|
609
646
|
|
data/cloudenvoy.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'Cross-application messaging using GCP Pub/Sub (alpha)'
|
13
13
|
spec.homepage = 'https://github.com/keypup-io/cloudenvoy'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
16
16
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = 'https://github.com/keypup-io/cloudenvoy'
|
@@ -35,13 +35,9 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'appraisal'
|
36
36
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
37
37
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
38
|
-
spec.add_development_dependency 'rubocop', '0.
|
38
|
+
spec.add_development_dependency 'rubocop', '0.93.0'
|
39
39
|
spec.add_development_dependency 'rubocop-rspec', '1.37.0'
|
40
40
|
spec.add_development_dependency 'semantic_logger'
|
41
41
|
spec.add_development_dependency 'timecop'
|
42
42
|
spec.add_development_dependency 'webmock'
|
43
|
-
|
44
|
-
spec.add_development_dependency 'rails'
|
45
|
-
spec.add_development_dependency 'rspec-rails'
|
46
|
-
spec.add_development_dependency 'sqlite3'
|
47
43
|
end
|
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.0.0
|
data/examples/rails/Gemfile
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
5
|
|
6
|
-
ruby '
|
6
|
+
ruby '3.0.0'
|
7
7
|
|
8
8
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
9
9
|
gem 'rails', '~> 6.0.2'
|
10
10
|
|
11
|
+
# Server
|
12
|
+
gem 'puma', '~> 5.6.4'
|
13
|
+
|
11
14
|
# Messaging via GCP Pub/Sub
|
12
15
|
gem 'cloudenvoy', path: '../../'
|
13
16
|
|