sequel-pgt_outbox 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 24d2ec8fd8ddefdc27af445348e42d8324a5a4dc7591694ac9646df1ca8675e1
4
+ data.tar.gz: 3b5865ee09aa89409ae47cc3b61a364a95ae40365705cf354b028b5d22012c6e
5
+ SHA512:
6
+ metadata.gz: e9d7f8d7545faa4e8f86532520f74aef45332612a3824c0ae52122da160a67ac2241bde894234a3939df27dc6f2daa58be7d322cea76c84ebb8c210fc95ae87a
7
+ data.tar.gz: 6157a47c7e2f103389be623968dd4d1f095d85ae70381b4f90aa9990180f7cd9f350e41fe5161980fce1a74fdc38fe12bf326a9cad28030cd0ef9a86d186445a
data/.overcommit.yml ADDED
@@ -0,0 +1,345 @@
1
+ ---
2
+ PreCommit:
3
+ AuthorEmail:
4
+ enabled: true
5
+ AuthorName:
6
+ enabled: true
7
+ BerksfileCheck:
8
+ enabled: false
9
+ BrokenSymlinks:
10
+ enabled: true
11
+ BundleAudit:
12
+ enabled: true
13
+ BundleCheck:
14
+ enabled: true
15
+ BundleOutdated:
16
+ enabled: true
17
+ CaseConflicts:
18
+ enabled: true
19
+ ChamberCompare:
20
+ enabled: false
21
+ ChamberSecurity:
22
+ enabled: false
23
+ ChamberVerification:
24
+ enabled: false
25
+ CodeSpellCheck:
26
+ enabled: false
27
+ CoffeeLint:
28
+ enabled: false
29
+ CookStyle:
30
+ enabled: false
31
+ Credo:
32
+ enabled: false
33
+ CssLint:
34
+ enabled: false
35
+ DartAnalyzer:
36
+ enabled: false
37
+ Dogma:
38
+ enabled: false
39
+ ErbLint:
40
+ enabled: false
41
+ EsLint:
42
+ enabled: false
43
+ ExecutePermissions:
44
+ enabled: false
45
+ Fasterer:
46
+ enabled: false
47
+ FixMe:
48
+ enabled: true
49
+ FileSize:
50
+ enabled: false
51
+ Flay:
52
+ enabled: false
53
+ Foodcritic:
54
+ enabled: false
55
+ ForbiddenBranches:
56
+ enabled: true
57
+ branch_patterns: ['main', 'master']
58
+ GinkgoFocus:
59
+ enabled: false
60
+ GoFmt:
61
+ enabled: false
62
+ GolangciLint:
63
+ enabled: false
64
+ GoLint:
65
+ enabled: false
66
+ GoVet:
67
+ enabled: false
68
+ Hadolint:
69
+ enabled: false
70
+ HamlLint:
71
+ enabled: false
72
+ HardTabs:
73
+ enabled: false
74
+ Hlint:
75
+ enabled: false
76
+ HtmlHint:
77
+ enabled: false
78
+ HtmlTidy:
79
+ enabled: false
80
+ ImageOptim:
81
+ enabled: false
82
+ JavaCheckstyle:
83
+ enabled: false
84
+ Jscs:
85
+ enabled: false
86
+ JsHint:
87
+ enabled: false
88
+ JsLint:
89
+ enabled: false
90
+ Jsl:
91
+ enabled: false
92
+ JsonSyntax:
93
+ enabled: false
94
+ KtLint:
95
+ enabled: false
96
+ LicenseFinder:
97
+ enabled: false
98
+ LicenseHeader:
99
+ enabled: false
100
+ LocalPathsInGemfile:
101
+ enabled: false
102
+ Mdl:
103
+ enabled: false
104
+ MergeConflicts:
105
+ enabled: true
106
+ MixFormat:
107
+ enabled: false
108
+ PuppetMetadataJsonLint:
109
+ enabled: false
110
+ NginxTest:
111
+ enabled: false
112
+ Pep257:
113
+ enabled: false
114
+ Pep8:
115
+ enabled: false
116
+ PhpLint:
117
+ enabled: false
118
+ PhpCs:
119
+ enabled: false
120
+ PhpCsFixer:
121
+ enabled: false
122
+ PhpStan:
123
+ enabled: false
124
+ Pronto:
125
+ enabled: false
126
+ PuppetLint:
127
+ enabled: false
128
+ Pycodestyle:
129
+ enabled: false
130
+ Pydocstyle:
131
+ enabled: false
132
+ Pyflakes:
133
+ enabled: false
134
+ Pylint:
135
+ enabled: false
136
+ PythonFlake8:
137
+ enabled: false
138
+ RakeTarget:
139
+ enabled: false
140
+ RailsBestPractices:
141
+ enabled: false
142
+ RailsSchemaUpToDate:
143
+ enabled: false
144
+ Reek:
145
+ enabled: false
146
+ RstLint:
147
+ enabled: false
148
+ RSpec:
149
+ enabled: false
150
+ RuboCop:
151
+ enabled: true
152
+ RubyLint:
153
+ enabled: false
154
+ RubySyntax:
155
+ enabled: false
156
+ Scalariform:
157
+ enabled: false
158
+ Scalastyle:
159
+ enabled: false
160
+ ScssLint:
161
+ enabled: false
162
+ SemiStandard:
163
+ enabled: false
164
+ ShellCheck:
165
+ enabled: true
166
+ SlimLint:
167
+ enabled: false
168
+ Sorbet:
169
+ enabled: false
170
+ Sqlint:
171
+ enabled: false
172
+ Standard:
173
+ enabled: false
174
+ Stylelint:
175
+ enabled: false
176
+ SwiftLint:
177
+ enabled: false
178
+ TerraformFormat:
179
+ enabled: false
180
+ TsLint:
181
+ enabled: false
182
+ TrailingWhitespace:
183
+ enabled: true
184
+ TravisLint:
185
+ enabled: false
186
+ Vint:
187
+ enabled: false
188
+ W3cCss:
189
+ enabled: false
190
+ W3cHtml:
191
+ enabled: false
192
+ LineEndings:
193
+ enabled: false
194
+ XmlLint:
195
+ enabled: false
196
+ XmlSyntax:
197
+ enabled: false
198
+ YamlLint:
199
+ enabled: false
200
+ YamlSyntax:
201
+ enabled: true
202
+ YardCoverage:
203
+ enabled: false
204
+ YarnCheck:
205
+ enabled: false
206
+ CommitMsg:
207
+ CapitalizedSubject:
208
+ enabled: false
209
+ EmptyMessage:
210
+ enabled: true
211
+ GerritChangeId:
212
+ enabled: false
213
+ HardTabs:
214
+ enabled: false
215
+ MessageFormat:
216
+ enabled: true
217
+ expected_pattern_message: |-
218
+ /^(?<type>[a-z]+)(?<scope>\(\w+\))?!?: (?<subject>[A-Z].*)$/
219
+ The scope and ! are optional see
220
+ https://www.conventionalcommits.org/en/v1.0.0/#specification
221
+ Subject must start with a capital letter
222
+ pattern: '^(?<type>[a-z]+)(?<scope>\(\w+\))?!?: (?<subject>[A-Z].*)$'
223
+ sample_message: 'docs(readme): ISSUE-10 - Correct typo'
224
+ RussianNovel:
225
+ enabled: true
226
+ SingleLineSubject:
227
+ enabled: true
228
+ SpellCheck:
229
+ enabled: false
230
+ TextWidth:
231
+ enabled: true
232
+ max_subject_width: 72
233
+ TrailingPeriod:
234
+ enabled: true
235
+ PostCheckout:
236
+ BowerInstall:
237
+ enabled: false
238
+ BundleInstall:
239
+ enabled: false
240
+ ComposerInstall:
241
+ enabled: false
242
+ GitLfs:
243
+ enabled: false
244
+ IndexTags:
245
+ enabled: false
246
+ NpmInstall:
247
+ enabled: false
248
+ SubmoduleStatus:
249
+ enabled: false
250
+ YarnInstall:
251
+ enabled: false
252
+ PostCommit:
253
+ BowerInstall:
254
+ enabled: false
255
+ BundleInstall:
256
+ enabled: false
257
+ Commitplease:
258
+ enabled: false
259
+ ComposerInstall:
260
+ enabled: false
261
+ GitGuilt:
262
+ enabled: false
263
+ GitLfs:
264
+ enabled: false
265
+ IndexTags:
266
+ enabled: false
267
+ NpmInstall:
268
+ enabled: false
269
+ SubmoduleStatus:
270
+ enabled: false
271
+ YarnInstall:
272
+ enabled: false
273
+ PostMerge:
274
+ BowerInstall:
275
+ enabled: false
276
+ BundleInstall:
277
+ enabled: false
278
+ ComposerInstall:
279
+ enabled: false
280
+ GitLfs:
281
+ enabled: false
282
+ IndexTags:
283
+ enabled: false
284
+ NpmInstall:
285
+ enabled: false
286
+ SubmoduleStatus:
287
+ enabled: false
288
+ YarnInstall:
289
+ enabled: false
290
+ PostRewrite:
291
+ BowerInstall:
292
+ enabled: false
293
+ BundleInstall:
294
+ enabled: false
295
+ ComposerInstall:
296
+ enabled: false
297
+ IndexTags:
298
+ enabled: false
299
+ NpmInstall:
300
+ enabled: false
301
+ SubmoduleStatus:
302
+ enabled: false
303
+ YarnInstall:
304
+ enabled: false
305
+ PrePush:
306
+ Brakeman:
307
+ enabled: false
308
+ CargoTest:
309
+ enabled: false
310
+ FlutterTest:
311
+ enabled: false
312
+ GitLfs:
313
+ enabled: false
314
+ GolangciLint:
315
+ enabled: false
316
+ GoTest:
317
+ enabled: false
318
+ Minitest:
319
+ enabled: false
320
+ MixTest:
321
+ enabled: false
322
+ PhpUnit:
323
+ enabled: false
324
+ Pronto:
325
+ enabled: false
326
+ ProtectedBranches:
327
+ enabled: true
328
+ PubTest:
329
+ enabled: false
330
+ Pytest:
331
+ enabled: false
332
+ PythonNose:
333
+ enabled: false
334
+ RSpec:
335
+ enabled: false
336
+ RakeTarget:
337
+ enabled: false
338
+ TestUnit:
339
+ enabled: false
340
+ PreRebase:
341
+ MergedCommits:
342
+ enabled: false
343
+ PrepareCommitMsg:
344
+ ReplaceBranch:
345
+ enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ ---
2
+ require:
3
+ - rubocop-rake
4
+ - rubocop-minitest
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.3.0
8
+ NewCops: enable
9
+
10
+ Style/StringLiterals:
11
+ Enabled: true
12
+ EnforcedStyle: single_quotes
13
+
14
+ Style/StringLiteralsInInterpolation:
15
+ Enabled: true
16
+ EnforcedStyle: double_quotes
17
+
18
+ Layout/LineLength:
19
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-02-14
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Tj (bougyman) Vanderpoel
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.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+
5
+ require 'rubocop/rake_task'
6
+
7
+ RuboCop::RakeTask.new
8
+
9
+ desc 'Run tests'
10
+ task :spec do
11
+ ENV['COVERAGE'] = 'true'
12
+ sh 'bundle exec ./test/sequel/test_pgt_outbox.rb'
13
+ end
14
+
15
+ desc 'Create the test database'
16
+ task :createdb do
17
+ require 'uri'
18
+ uri = URI.parse(ENV.fetch("PGT_SPEC_DB", "postgres:///spgt_test"))
19
+ sh "createdb '#{File.basename(uri.path)}'"
20
+ end
21
+
22
+ desc 'Drop the test database'
23
+ task :dropdb do
24
+ require 'uri'
25
+ uri = URI.parse(ENV.fetch("PGT_SPEC_DB", "postgres:///spgt_test"))
26
+ sh "dropdb --if-exists '#{File.basename(uri.path)}'"
27
+ end
28
+
29
+ task resetdb: %i[dropdb createdb]
30
+
31
+ task default: %i[rubocop spec]
data/Readme.adoc ADDED
@@ -0,0 +1,82 @@
1
+ = Transaction Outbox for Postgres
2
+
3
+ This gem provides a way to implement the transaction outbox pattern using triggers (stored procedures) in Postgres.
4
+
5
+ It utilizes the ruby Sequel ORM to interact with the database, but once it's set up,
6
+ it doesn't require any ruby nor Sequel code for the outbox population to operate. It
7
+ all runs on the PostgreSQL cluster, guaranteeing no matter how the database writes
8
+ occur, the outbox events will always be generated.
9
+
10
+ == Installation
11
+
12
+ Install the gem and add to the application's Gemfile by executing:
13
+
14
+ ```bash
15
+ bundle add sequel-pgt_outbox
16
+ ```
17
+
18
+ If bundler is not being used to manage dependencies, install the gem by executing:
19
+
20
+ ```bash
21
+ gem install sequel-pgt_outbox
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Using the sequel cli
27
+
28
+ ```bash
29
+ sequel -r sequel/pgt_outbox postgres://localhost/mydb
30
+ Your database is stored in DB...
31
+ irb(main):001> DB.create_table(:foo) { primary_key :id; String :s; Integer :i }
32
+ => nil
33
+ irb(main):002> function = DB.pgt_setup_outbox(:foo)
34
+ => "pgt_outbox_foo_outbox"
35
+ irb(main):003> DB[:foo].insert(s: 'foo', i: 1)
36
+ => 1
37
+ irb(main):004> DB[:foo_outbox].first
38
+ => nil
39
+ irb(main):005> DB.pgt_outbox_events(:foo, function)
40
+ =>
41
+ #<Rubyists::PgtOutbox::Trigger:0x00007f1ae2fbc2b0
42
+ @db=#<Sequel::Postgres::Database database=spgt_test>,
43
+ @events=[:insert, :update, :delete],
44
+ @function="pgt_outbox_foo_outbox",
45
+ @name="pgt_outbox_foo_outbox",
46
+ @opts={when: nil},
47
+ @table=:foo,
48
+ @trigger_opts={after: true, each_row: true}>
49
+ irb(main):006> DB[:foo].insert(s: 'bar', i: 2)
50
+ => 2
51
+ irb(main):007> DB[:foo_outbox].first
52
+ =>
53
+ {id: 1,
54
+ attempts: 0,
55
+ completed: nil,
56
+ created: 2025-02-15 18:20:30.28394 +0000,
57
+ updated: 2025-02-15 18:20:30.28394 +0000,
58
+ attempted: nil,
59
+ event_type: "foo_created",
60
+ last_error: nil,
61
+ data_before: nil,
62
+ data_after: "{\"i\": 2, \"s\": \"bar\", \"id\": 2}",
63
+ metadata: nil}
64
+ ```
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
+
70
+ To install this gem onto your local machine, run `bundle exec rake install`. 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rubyists/sequel-pgt_outbox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/rubyists/sequel-pgt_outbox/blob/main/CODE_OF_CONDUCT.md).
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
79
+
80
+ ## Code of Conduct
81
+
82
+ Everyone interacting in the Sequel::PgtOutbox project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rubyists/sequel-pgt_outbox/blob/main/CODE_OF_CONDUCT.md).