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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8bd773adfe87f0e49c1670e33ecca0654fbfad1fa2e7ce45ae2cb820c1c7012
4
- data.tar.gz: fc401a6aa31f68b9138bc52c77b66b9707d6d21d7e19cd6aaae11cbecb1a75e5
3
+ metadata.gz: 4caf2ea67d821c6523a55d6a0d3049216977a51f7e7660be453e70bdf33a92a6
4
+ data.tar.gz: 194c131bb03da874172331f3787ff76edd874eb704e802f13ef24396ad7bab30
5
5
  SHA512:
6
- metadata.gz: 07d4494017e73cf4cb14c3d822d22c0b595ed8a669c4fe967cf1d9a29411a078a9fdc70d9507e70ac52a4b4801e3bce31295db008bd8b613f71efc70198d7200
7
- data.tar.gz: dadea963a4ff4a566585d8f4462f6625de9064254c2781a0d62fbc6c3d3819c49fa67cce9917a59970b575ffc091b3b39478229859ced3b65a4a8e7f8d00b184
6
+ metadata.gz: 57cb75713b8e617724e9424b0781e9e40853bdd1e6b2687b2361acca406740edb739f8552aa62581832983f0f5685de05d72e03d52991a902975f20cd43ff55d
7
+ data.tar.gz: 67034935f6b83ee47b8afaaf8bbf7199d2466b929eee885834bf7d5c9fe5f3021d5767b21632852dabdd27a7b86105c7d8617459732da7084c3ea46d41407568
@@ -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: Test
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.x'
16
- - '2.6.x'
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 2.6
30
- uses: actions/setup-ruby@v1
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
@@ -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/.rubocop.yml CHANGED
@@ -5,6 +5,11 @@ AllCops:
5
5
  - 'gemfiles/**/*'
6
6
  - 'vendor/**/*'
7
7
 
8
+ # Ruby 3.0: curly braces around last argument has meaning
9
+ # See: https://github.com/rubocop/rubocop/issues/7641
10
+ Style/BracesAroundHashParameters:
11
+ Enabled: false
12
+
8
13
  Metrics/ClassLength:
9
14
  Max: 150
10
15
 
data/Appraisals CHANGED
@@ -1,25 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-5.2' do
4
- gem 'rails', '5.2'
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
- appraise 'rails-6.0' do
8
- gem 'rails', '6.0'
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,12 +1,43 @@
1
1
  # Changelog
2
2
 
3
- ## [v0.3.1](https://github.com/keypup-io/cloudenvoy/tree/v0.3.1) (2020-10-05)
3
+ ## [v0.5.rc1](https://github.com/keypup-io/cloudenvoy/tree/v0.5.rc1) (2022-01-05)
4
4
 
5
- [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.3.0...v0.3.1)
5
+ [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.2...v0.5.rc1)
6
+
7
+ **Improvements:**
8
+ - Ruby 3: Rework method arguments to be compatible with Ruby 3
9
+ - Tests: Separate test environment for Ruby 2 and Ruby 3
10
+ - Tests: Do not load Rails by default and skip Rails-specific tests in non-Rails appraisals
11
+
12
+ ## [v0.4.2](https://github.com/keypup-io/cloudenvoy/tree/v0.4.2) (2021-10-25)
13
+
14
+ [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.1...v0.4.2)
15
+
16
+ **Bug fix:**
17
+ - Message processing: fix subscription parsing for topic names with dots.
18
+
19
+ ## [v0.4.1](https://github.com/keypup-io/cloudenvoy/tree/v0.4.1) (2020-10-06)
20
+
21
+ [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.4.0...v0.4.1)
22
+
23
+ **Bug fix:**
24
+ - Logging: log publisher and subscriber errors during execution
25
+ - Rake tasks: fix early return statement when publisher or subscriber list is empty
26
+
27
+ ## [v0.4.0](https://github.com/keypup-io/cloudenvoy/tree/v0.4.0) (2020-10-05)
28
+
29
+ [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.3.1...v0.4.0)
6
30
 
7
31
  **Bug fix:**
8
32
  - Logging: fix log processing with `semantic_logger` `v4.7.2`. Accept any args on block passed to the logger.
9
33
 
34
+ ## [v0.3.1](https://github.com/keypup-io/cloudenvoy/tree/v0.3.1) (2020-10-05)
35
+
36
+ [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.3.0...v0.3.1)
37
+
38
+ **Improvements:**
39
+ - Development: auto-create topics in development mode when registering subscriptions.
40
+
10
41
  ## [v0.3.0](https://github.com/keypup-io/cloudenvoy/tree/v0.3.0) (2020-09-26)
11
42
 
12
43
  [Full Changelog](https://github.com/keypup-io/cloudenvoy/compare/v0.2.0...v0.3.0)
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
 
@@ -22,10 +25,8 @@ module Cloudenvoy
22
25
  rescue InvalidSubscriberError
23
26
  # 404: Message delivery will be retried
24
27
  head :not_found
25
- rescue StandardError => e
28
+ rescue StandardError
26
29
  # 422: Message delivery will be retried
27
- Cloudenvoy.logger.error(e)
28
- Cloudenvoy.logger.error(e.backtrace.join("\n"))
29
30
  head :unprocessable_entity
30
31
  end
31
32
 
@@ -42,7 +43,7 @@ module Cloudenvoy
42
43
  # Get raw body
43
44
  content = request.body.read
44
45
 
45
- # Return content parsed as JSON and add job retries count
46
+ # Return content parsed as JSON
46
47
  JSON.parse(content).except('token')
47
48
  end
48
49
  end
data/cloudenvoy.gemspec CHANGED
@@ -40,8 +40,4 @@ Gem::Specification.new do |spec|
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-2.5.5
1
+ ruby-3.0.0
@@ -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 '2.5.5'
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.5.2'
13
+
11
14
  # Messaging via GCP Pub/Sub
12
15
  gem 'cloudenvoy', path: '../../'
13
16