rails-transactional-outbox 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +13 -0
  3. data/.github/workflows/ci.yml +49 -0
  4. data/.gitignore +13 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +150 -0
  7. data/CHANGELOG.md +5 -0
  8. data/Gemfile +19 -0
  9. data/Gemfile.lock +142 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +285 -0
  12. data/Rakefile +10 -0
  13. data/bin/console +15 -0
  14. data/bin/rails_transactional_outbox_health_check +13 -0
  15. data/bin/setup +8 -0
  16. data/lib/rails-transactional-outbox.rb +3 -0
  17. data/lib/rails_transactional_outbox/configuration.rb +33 -0
  18. data/lib/rails_transactional_outbox/error_handlers/null_error_handler.rb +9 -0
  19. data/lib/rails_transactional_outbox/error_handlers.rb +6 -0
  20. data/lib/rails_transactional_outbox/event_type.rb +37 -0
  21. data/lib/rails_transactional_outbox/exponential_backoff.rb +9 -0
  22. data/lib/rails_transactional_outbox/health_check.rb +48 -0
  23. data/lib/rails_transactional_outbox/monitor.rb +47 -0
  24. data/lib/rails_transactional_outbox/outbox_entries_processor.rb +56 -0
  25. data/lib/rails_transactional_outbox/outbox_entry_factory.rb +32 -0
  26. data/lib/rails_transactional_outbox/outbox_model.rb +78 -0
  27. data/lib/rails_transactional_outbox/railtie.rb +11 -0
  28. data/lib/rails_transactional_outbox/record_processor.rb +35 -0
  29. data/lib/rails_transactional_outbox/record_processors/active_record_processor.rb +39 -0
  30. data/lib/rails_transactional_outbox/record_processors/base_processor.rb +15 -0
  31. data/lib/rails_transactional_outbox/record_processors.rb +6 -0
  32. data/lib/rails_transactional_outbox/reliable_model/reliable_callback.rb +41 -0
  33. data/lib/rails_transactional_outbox/reliable_model/reliable_callbacks_registry.rb +26 -0
  34. data/lib/rails_transactional_outbox/reliable_model.rb +81 -0
  35. data/lib/rails_transactional_outbox/runner.rb +106 -0
  36. data/lib/rails_transactional_outbox/runner_sleep_interval.rb +14 -0
  37. data/lib/rails_transactional_outbox/tracers/datadog_tracer.rb +35 -0
  38. data/lib/rails_transactional_outbox/tracers/null_tracer.rb +9 -0
  39. data/lib/rails_transactional_outbox/tracers.rb +7 -0
  40. data/lib/rails_transactional_outbox/version.rb +7 -0
  41. data/lib/rails_transactional_outbox.rb +54 -0
  42. data/lib/tasks/rails_transactional_outbox.rake +11 -0
  43. data/rails-transactional-outbox.gemspec +44 -0
  44. metadata +188 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f6343854fdf11162d383989d784559a868d52eb17b5b2eb0ec00b52c7d91997c
4
+ data.tar.gz: 351f3beae606216af85b13f42a2262675c8de21fb2f77588c9ad0c249c4cc187
5
+ SHA512:
6
+ metadata.gz: 43707b7e3083d3c8512c03e9db85601f10fa77664a180b87abd34ca5b641b51ffb2e3b4add3eea7129fd1adad480f667c0531a43fc783b4548f18792d32bd6a5
7
+ data.tar.gz: e8ac0f50cacfa30d0b8fab99299cdafec95fb5cf9d1451824957dd21a2cd7fc207b9fbc728ee2b4d5c2b63de287036558d39916bd7470eb6ae4ac10cef443ed7
@@ -0,0 +1,13 @@
1
+ version: 2.1
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: ruby:2.7.2
6
+ steps:
7
+ - checkout
8
+ - run:
9
+ name: Run the default task
10
+ command: |
11
+ gem install bundler -v 2.2.11
12
+ bundle install
13
+ bundle exec rake
@@ -0,0 +1,49 @@
1
+ name: CI
2
+ on: [pull_request, push]
3
+ jobs:
4
+ rubocop:
5
+ strategy:
6
+ fail-fast: true
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 2.7
13
+ bundler-cache: true
14
+ - run: bundle exec rubocop
15
+ rspec:
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.7', '3.0', '3.1' ]
20
+ runs-on: ubuntu-latest
21
+ env:
22
+ DATABASE_URL: "postgresql://postgres:postgres@127.0.0.1:5432/rails-transactional-outbox-test"
23
+ POSTGRES_URL: "postgresql://postgres:postgres@127.0.0.1:5432"
24
+ services:
25
+ postgres:
26
+ image: postgres:14
27
+ env:
28
+ POSTGRES_USER: postgres
29
+ POSTGRES_PASSWORD: postgres
30
+ POSTGRES_DB: rails-transactional-outbox-test
31
+ ports:
32
+ - 5432:5432
33
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
34
+ redis:
35
+ image: redis
36
+ ports:
37
+ - 6379:6379
38
+ options: >-
39
+ --health-cmd "redis-cli ping"
40
+ --health-interval 10s
41
+ --health-timeout 5s
42
+ --health-retries 5
43
+ steps:
44
+ - uses: actions/checkout@v2
45
+ - uses: ruby/setup-ruby@v1
46
+ with:
47
+ ruby-version: ${{ matrix.ruby }}
48
+ bundler-cache: true
49
+ - run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .ruby-version
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,150 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+ - rubocop-rake
5
+
6
+ inherit_mode:
7
+ merge:
8
+ - Exclude
9
+
10
+ AllCops:
11
+ NewCops: enable
12
+ TargetRubyVersion: 2.7
13
+ Exclude:
14
+ - "db/**/*"
15
+ - "bin/**/*"
16
+ - "tmp/**/*"
17
+ - "log/**/*"
18
+ - "vendor/**/*"
19
+ - "spec/rails_helper.rb"
20
+
21
+ Layout/ArgumentAlignment:
22
+ EnforcedStyle: with_fixed_indentation
23
+
24
+ Layout/ArrayAlignment:
25
+ EnforcedStyle: with_fixed_indentation
26
+
27
+ Layout/EmptyLineBetweenDefs:
28
+ AllowAdjacentOneLineDefs: true
29
+
30
+ Layout/EndAlignment:
31
+ EnforcedStyleAlignWith: variable
32
+
33
+ Layout/FirstArgumentIndentation:
34
+ EnforcedStyle: consistent
35
+
36
+ Layout/FirstArrayElementIndentation:
37
+ EnforcedStyle: consistent
38
+
39
+ Layout/FirstHashElementIndentation:
40
+ EnforcedStyle: consistent
41
+
42
+ Layout/MultilineMethodCallIndentation:
43
+ EnforcedStyle: indented
44
+
45
+ Layout/MultilineOperationIndentation:
46
+ EnforcedStyle: indented
47
+
48
+ Layout/ParameterAlignment:
49
+ EnforcedStyle: with_fixed_indentation
50
+
51
+ Layout/SpaceBeforeBrackets:
52
+ Enabled: false
53
+
54
+ Lint/UnusedMethodArgument:
55
+ AllowUnusedKeywordArguments: true
56
+
57
+ Metrics/ParameterLists:
58
+ MaxOptionalParameters: 4
59
+
60
+ RSpec/ExpectChange:
61
+ EnforcedStyle: block
62
+
63
+ RSpec/LetSetup:
64
+ Enabled: false
65
+
66
+ RSpec/MultipleExpectations:
67
+ Max: 20
68
+
69
+ Style/Alias:
70
+ EnforcedStyle: prefer_alias_method
71
+
72
+ Style/ClassAndModuleChildren:
73
+ EnforcedStyle: nested
74
+
75
+ Style/CommandLiteral:
76
+ EnforcedStyle: percent_x
77
+
78
+ Style/RescueStandardError:
79
+ EnforcedStyle: implicit
80
+
81
+ Style/StringLiterals:
82
+ EnforcedStyle: double_quotes
83
+ ConsistentQuotesInMultiline: true
84
+
85
+ Style/StringLiteralsInInterpolation:
86
+ EnforcedStyle: double_quotes
87
+
88
+ Style/RaiseArgs:
89
+ EnforcedStyle: compact
90
+
91
+ Style/RegexpLiteral:
92
+ EnforcedStyle: percent_r
93
+
94
+ Style/Documentation:
95
+ Enabled: false
96
+
97
+ RSpec/NestedGroups:
98
+ Max: 10
99
+
100
+ RSpec/MultipleMemoizedHelpers:
101
+ Enabled: false
102
+
103
+ Lint/AmbiguousBlockAssociation:
104
+ Exclude:
105
+ - 'spec/**/*'
106
+
107
+ Naming/FileName:
108
+ Exclude:
109
+ - 'lib/rails-transactional-outbox.rb'
110
+
111
+ RSpec/ExampleLength:
112
+ Max: 15
113
+
114
+ Metrics/AbcSize:
115
+ Exclude:
116
+ - 'lib/rails_transactional_outbox/runner.rb'
117
+ - 'lib/rails_transactional_outbox/outbox_entries_processor.rb'
118
+
119
+ Metrics/MethodLength:
120
+ Max: 20
121
+ Exclude:
122
+ - 'lib/rails_transactional_outbox/runner.rb'
123
+
124
+ RSpec/DescribeClass:
125
+ Exclude:
126
+ - 'spec/integration_spec.rb'
127
+
128
+ Naming/VariableNumber:
129
+ EnforcedStyle: snake_case
130
+
131
+ Lint/EmptyClass:
132
+ Exclude:
133
+ - 'lib/rails_transactional_outbox/error_handlers.rb'
134
+ - 'lib/rails_transactional_outbox/record_processors.rb'
135
+
136
+ Metrics/BlockLength:
137
+ Exclude:
138
+ - 'lib/rails_transactional_outbox/reliable_model.rb'
139
+
140
+ Lint/ConstantDefinitionInBlock:
141
+ Exclude:
142
+ - 'spec/spec_helper.rb'
143
+
144
+ RSpec/AnyInstance:
145
+ Exclude:
146
+ - 'spec/rails_transactional_outbox/outbox_model_spec.rb'
147
+
148
+ RSpec/VerifiedDoubles:
149
+ Exclude:
150
+ - 'spec/rails_transactional_outbox/runner_spec.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-08-23
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rails-transactional-outbox.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "crypt_keeper", github: "jmazzi/crypt_keeper"
11
+ gem "ddtrace"
12
+ gem "pg"
13
+ gem "rspec", "~> 3.0"
14
+ gem "rubocop", require: false
15
+ gem "rubocop-performance"
16
+ gem "rubocop-rake"
17
+ gem "rubocop-rspec"
18
+ gem "sentry-ruby"
19
+ gem "timecop"
data/Gemfile.lock ADDED
@@ -0,0 +1,142 @@
1
+ GIT
2
+ remote: https://github.com/jmazzi/crypt_keeper.git
3
+ revision: 1a1d7fe4f3ff4da86c530c90c5da2b99aeb467a9
4
+ specs:
5
+ crypt_keeper (2.3.0)
6
+ activerecord (~> 7.0.0, >= 4.2)
7
+ activesupport (~> 7.0.0, >= 4.2)
8
+
9
+ PATH
10
+ remote: .
11
+ specs:
12
+ rails-transactional-outbox (0.1.0)
13
+ activerecord (>= 5)
14
+ activesupport (>= 3.2)
15
+ concurrent-ruby
16
+ dry-monitor
17
+ redis
18
+ sigurd
19
+ zeitwerk
20
+
21
+ GEM
22
+ remote: https://rubygems.org/
23
+ specs:
24
+ activemodel (7.0.3.1)
25
+ activesupport (= 7.0.3.1)
26
+ activerecord (7.0.3.1)
27
+ activemodel (= 7.0.3.1)
28
+ activesupport (= 7.0.3.1)
29
+ activesupport (7.0.3.1)
30
+ concurrent-ruby (~> 1.0, >= 1.0.2)
31
+ i18n (>= 1.6, < 2)
32
+ minitest (>= 5.1)
33
+ tzinfo (~> 2.0)
34
+ ast (2.4.2)
35
+ concurrent-ruby (1.1.10)
36
+ ddtrace (1.2.0)
37
+ debase-ruby_core_source (= 0.10.16)
38
+ libddprof (~> 0.6.0.1.0)
39
+ libddwaf (~> 1.3.0.2.0)
40
+ msgpack
41
+ debase-ruby_core_source (0.10.16)
42
+ diff-lcs (1.5.0)
43
+ dry-configurable (0.15.0)
44
+ concurrent-ruby (~> 1.0)
45
+ dry-core (~> 0.6)
46
+ dry-core (0.8.1)
47
+ concurrent-ruby (~> 1.0)
48
+ dry-events (0.3.0)
49
+ concurrent-ruby (~> 1.0)
50
+ dry-core (~> 0.5, >= 0.5)
51
+ dry-monitor (0.6.3)
52
+ dry-configurable (~> 0.13, >= 0.13.0)
53
+ dry-core (~> 0.5, >= 0.5)
54
+ dry-events (~> 0.2)
55
+ zeitwerk (~> 2.5)
56
+ exponential-backoff (0.0.4)
57
+ ffi (1.15.5)
58
+ i18n (1.12.0)
59
+ concurrent-ruby (~> 1.0)
60
+ json (2.6.2)
61
+ libddprof (0.6.0.1.0)
62
+ libddprof (0.6.0.1.0-x86_64-linux)
63
+ libddwaf (1.3.0.2.0-x86_64-darwin)
64
+ ffi (~> 1.0)
65
+ libddwaf (1.3.0.2.0-x86_64-linux)
66
+ ffi (~> 1.0)
67
+ minitest (5.16.3)
68
+ msgpack (1.5.3)
69
+ parallel (1.22.1)
70
+ parser (3.1.2.1)
71
+ ast (~> 2.4.1)
72
+ pg (1.4.3)
73
+ rainbow (3.1.1)
74
+ rake (13.0.6)
75
+ redis (4.8.0)
76
+ regexp_parser (2.5.0)
77
+ rexml (3.2.5)
78
+ rspec (3.11.0)
79
+ rspec-core (~> 3.11.0)
80
+ rspec-expectations (~> 3.11.0)
81
+ rspec-mocks (~> 3.11.0)
82
+ rspec-core (3.11.0)
83
+ rspec-support (~> 3.11.0)
84
+ rspec-expectations (3.11.0)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.11.0)
87
+ rspec-mocks (3.11.1)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.11.0)
90
+ rspec-support (3.11.0)
91
+ rubocop (1.35.1)
92
+ json (~> 2.3)
93
+ parallel (~> 1.10)
94
+ parser (>= 3.1.2.1)
95
+ rainbow (>= 2.2.2, < 4.0)
96
+ regexp_parser (>= 1.8, < 3.0)
97
+ rexml (>= 3.2.5, < 4.0)
98
+ rubocop-ast (>= 1.20.1, < 2.0)
99
+ ruby-progressbar (~> 1.7)
100
+ unicode-display_width (>= 1.4.0, < 3.0)
101
+ rubocop-ast (1.21.0)
102
+ parser (>= 3.1.1.0)
103
+ rubocop-performance (1.14.3)
104
+ rubocop (>= 1.7.0, < 2.0)
105
+ rubocop-ast (>= 0.4.0)
106
+ rubocop-rake (0.6.0)
107
+ rubocop (~> 1.0)
108
+ rubocop-rspec (2.12.1)
109
+ rubocop (~> 1.31)
110
+ ruby-progressbar (1.11.0)
111
+ sentry-ruby (5.4.1)
112
+ concurrent-ruby (~> 1.0, >= 1.0.2)
113
+ sigurd (0.1.0)
114
+ concurrent-ruby (~> 1)
115
+ exponential-backoff
116
+ timecop (0.9.5)
117
+ tzinfo (2.0.5)
118
+ concurrent-ruby (~> 1.0)
119
+ unicode-display_width (2.2.0)
120
+ zeitwerk (2.6.0)
121
+
122
+ PLATFORMS
123
+ x86_64-darwin-18
124
+ x86_64-darwin-21
125
+ x86_64-linux
126
+
127
+ DEPENDENCIES
128
+ crypt_keeper!
129
+ ddtrace
130
+ pg
131
+ rails-transactional-outbox!
132
+ rake (~> 13.0)
133
+ rspec (~> 3.0)
134
+ rubocop
135
+ rubocop-performance
136
+ rubocop-rake
137
+ rubocop-rspec
138
+ sentry-ruby
139
+ timecop
140
+
141
+ BUNDLED WITH
142
+ 2.2.11
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Karol Galanciak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.