@reventlessdev/reventless-postgres 3.0.0-alpha.1
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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +202 -0
- package/__mocks__/emptyModule.js +1 -0
- package/lib/bs/.compiler.log +2 -0
- package/lib/bs/ReventlessPostgres.cmi +0 -0
- package/lib/bs/ReventlessPostgres.cmj +0 -0
- package/lib/bs/ReventlessPostgres.cmt +0 -0
- package/lib/bs/ReventlessPostgres.mlmap +9 -0
- package/lib/bs/build.ninja +0 -0
- package/lib/bs/compiler-info.json +8 -0
- package/lib/bs/src/DcbEventLogStorage_Postgres-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/DcbEventLogStorage_Postgres-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/DcbEventLogStorage_Postgres-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/DcbEventLogStorage_Postgres.ast +0 -0
- package/lib/bs/src/DcbEventLogStorage_Postgres.res +352 -0
- package/lib/bs/src/DcbEventLogStorage_Postgres.res.mjs +385 -0
- package/lib/bs/src/EventLogStorage_Postgres-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/EventLogStorage_Postgres-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/EventLogStorage_Postgres-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/EventLogStorage_Postgres.ast +0 -0
- package/lib/bs/src/EventLogStorage_Postgres.res +176 -0
- package/lib/bs/src/EventLogStorage_Postgres.res.mjs +207 -0
- package/lib/bs/src/PgChangeFeed-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/PgChangeFeed-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/PgChangeFeed-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/PgChangeFeed.ast +0 -0
- package/lib/bs/src/PgChangeFeed.res +145 -0
- package/lib/bs/src/PgChangeFeed.res.mjs +90 -0
- package/lib/bs/src/PgDriver-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/PgDriver-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/PgDriver-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/PgDriver-ReventlessPostgres.cmti +0 -0
- package/lib/bs/src/PgDriver.ast +0 -0
- package/lib/bs/src/PgDriver.iast +0 -0
- package/lib/bs/src/PgDriver.res +111 -0
- package/lib/bs/src/PgDriver.res.mjs +85 -0
- package/lib/bs/src/PgDriver.resi +68 -0
- package/lib/bs/src/PgSchema-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/PgSchema-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/PgSchema-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/PgSchema.ast +0 -0
- package/lib/bs/src/PgSchema.res +256 -0
- package/lib/bs/src/PgSchema.res.mjs +46 -0
- package/lib/bs/src/QueryDbStorage_Postgres-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/QueryDbStorage_Postgres-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/QueryDbStorage_Postgres-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/QueryDbStorage_Postgres.ast +0 -0
- package/lib/bs/src/QueryDbStorage_Postgres.res +244 -0
- package/lib/bs/src/QueryDbStorage_Postgres.res.mjs +225 -0
- package/lib/bs/src/QueryEnginePostgres-ReventlessPostgres.cmi +0 -0
- package/lib/bs/src/QueryEnginePostgres-ReventlessPostgres.cmj +0 -0
- package/lib/bs/src/QueryEnginePostgres-ReventlessPostgres.cmt +0 -0
- package/lib/bs/src/QueryEnginePostgres.ast +0 -0
- package/lib/bs/src/QueryEnginePostgres.res +127 -0
- package/lib/bs/src/QueryEnginePostgres.res.mjs +172 -0
- package/lib/bs/tests/PostgresIntegrationTest-ReventlessPostgres.cmi +0 -0
- package/lib/bs/tests/PostgresIntegrationTest-ReventlessPostgres.cmj +0 -0
- package/lib/bs/tests/PostgresIntegrationTest-ReventlessPostgres.cmt +0 -0
- package/lib/bs/tests/PostgresIntegrationTest.ast +0 -0
- package/lib/bs/tests/PostgresIntegrationTest.res +236 -0
- package/lib/bs/tests/PostgresIntegrationTest.res.mjs +328 -0
- package/lib/ocaml/.compiler.log +2 -0
- package/lib/ocaml/DcbEventLogStorage_Postgres-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/DcbEventLogStorage_Postgres-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/DcbEventLogStorage_Postgres-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/DcbEventLogStorage_Postgres.ast +0 -0
- package/lib/ocaml/DcbEventLogStorage_Postgres.res +352 -0
- package/lib/ocaml/EventLogStorage_Postgres-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/EventLogStorage_Postgres-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/EventLogStorage_Postgres-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/EventLogStorage_Postgres.ast +0 -0
- package/lib/ocaml/EventLogStorage_Postgres.res +176 -0
- package/lib/ocaml/PgChangeFeed-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/PgChangeFeed-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/PgChangeFeed-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/PgChangeFeed.ast +0 -0
- package/lib/ocaml/PgChangeFeed.res +145 -0
- package/lib/ocaml/PgDriver-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/PgDriver-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/PgDriver-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/PgDriver-ReventlessPostgres.cmti +0 -0
- package/lib/ocaml/PgDriver.ast +0 -0
- package/lib/ocaml/PgDriver.iast +0 -0
- package/lib/ocaml/PgDriver.res +111 -0
- package/lib/ocaml/PgDriver.resi +68 -0
- package/lib/ocaml/PgSchema-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/PgSchema-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/PgSchema-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/PgSchema.ast +0 -0
- package/lib/ocaml/PgSchema.res +256 -0
- package/lib/ocaml/PostgresIntegrationTest-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/PostgresIntegrationTest-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/PostgresIntegrationTest-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/PostgresIntegrationTest.ast +0 -0
- package/lib/ocaml/PostgresIntegrationTest.res +236 -0
- package/lib/ocaml/QueryDbStorage_Postgres-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/QueryDbStorage_Postgres-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/QueryDbStorage_Postgres-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/QueryDbStorage_Postgres.ast +0 -0
- package/lib/ocaml/QueryDbStorage_Postgres.res +244 -0
- package/lib/ocaml/QueryEnginePostgres-ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/QueryEnginePostgres-ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/QueryEnginePostgres-ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/QueryEnginePostgres.ast +0 -0
- package/lib/ocaml/QueryEnginePostgres.res +127 -0
- package/lib/ocaml/ReventlessPostgres.cmi +0 -0
- package/lib/ocaml/ReventlessPostgres.cmj +0 -0
- package/lib/ocaml/ReventlessPostgres.cmt +0 -0
- package/lib/ocaml/ReventlessPostgres.mlmap +9 -0
- package/package.json +56 -0
- package/rescript.json +36 -0
- package/src/DcbEventLogStorage_Postgres.res +352 -0
- package/src/DcbEventLogStorage_Postgres.res.mjs +385 -0
- package/src/EventLogStorage_Postgres.res +176 -0
- package/src/EventLogStorage_Postgres.res.mjs +207 -0
- package/src/PgChangeFeed.res +145 -0
- package/src/PgChangeFeed.res.mjs +90 -0
- package/src/PgDriver.res +111 -0
- package/src/PgDriver.res.mjs +85 -0
- package/src/PgDriver.resi +68 -0
- package/src/PgSchema.res +256 -0
- package/src/PgSchema.res.mjs +46 -0
- package/src/QueryDbStorage_Postgres.res +244 -0
- package/src/QueryDbStorage_Postgres.res.mjs +225 -0
- package/src/QueryEnginePostgres.res +127 -0
- package/src/QueryEnginePostgres.res.mjs +172 -0
- package/tests/PostgresIntegrationTest.res +236 -0
- package/tests/PostgresIntegrationTest.res.mjs +328 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 3.0.0-alpha.1 (2026-07-05)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **postgres:** add reventless-postgres backend + local-platform integration ([6913200](https://github.com/ReventlessDev/reventless-core/commit/69132001f9271e832a5af33416acd5b645feaf47))
|
|
11
|
+
* **postgres:** cold-start pool foundation for AWS Postgres adapters ([b393449](https://github.com/ReventlessDev/reventless-core/commit/b393449769b6cd92abd03d2d5e7f564fe092938e))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2019-2026 Martin Lorenz
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "12.3.0",
|
|
3
|
+
"bsc_path": "/home/runner/work/reventless-core/reventless-core/node_modules/@rescript/linux-x64/bin/bsc.exe",
|
|
4
|
+
"bsc_hash": "75e3a59c95cc953608fd3dd6ea6ed68141bba4414a20a52f114261b8a48385fa",
|
|
5
|
+
"rescript_config_hash": "48ea15db3d741cf15a2ff49dd0b47d86badf2b548ecb3859a896faf1e3a82a15",
|
|
6
|
+
"runtime_path": "/home/runner/work/reventless-core/reventless-core/node_modules/@rescript/runtime",
|
|
7
|
+
"generated_at": "1783244877502"
|
|
8
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
// Postgres-backed DCB event log storage — the exact-semantics backend.
|
|
2
|
+
//
|
|
3
|
+
// Unlike DynamoDB (which emulates the append condition with per-(tag,type) fence
|
|
4
|
+
// sentinel rows), Postgres evaluates the actual DcbTag.query atomically inside
|
|
5
|
+
// `dcb_append` (PgSchema.res): scoped advisory locks + exact check + insert, one
|
|
6
|
+
// round trip, transaction-scoped. See docs/plans/postgres-storage-adapter.md §B.
|
|
7
|
+
//
|
|
8
|
+
// Reads apply the xmin read barrier so returned head positions are stable
|
|
9
|
+
// forever (an event committed late — lower position, later commit — can never be
|
|
10
|
+
// skipped by a checkpointing reader). Positions are the opaque cursor
|
|
11
|
+
// `<xid8>:<position>` (both zero-padded to 20 digits → string sort == numeric
|
|
12
|
+
// sort); the append condition's `after` decodes to the same two-column
|
|
13
|
+
// comparison, making read → decide → conditional-append exact end to end.
|
|
14
|
+
|
|
15
|
+
open ReventlessCore
|
|
16
|
+
open Reventless
|
|
17
|
+
|
|
18
|
+
// Lock strategy for concurrent appends (B4). Advisory (default) is safe under
|
|
19
|
+
// PgBouncer transaction mode; RowLocks avoids advisory-lock connection pinning
|
|
20
|
+
// on RDS Proxy at the cost of a companion `dcb_scope` table.
|
|
21
|
+
type lockStrategy = [#AdvisoryLocks | #RowLocks]
|
|
22
|
+
let strategyParam = s =>
|
|
23
|
+
switch s {
|
|
24
|
+
| #AdvisoryLocks => "advisory"
|
|
25
|
+
| #RowLocks => "rows"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Injected by reventless-local to feed the projection-checkpoint low-watermark
|
|
29
|
+
// (ProjectionPending, Dcb axis). Standalone/deploy use passes nothing.
|
|
30
|
+
type onAppended = array<(string, int)> => unit
|
|
31
|
+
let noTracking: onAppended = _ => ()
|
|
32
|
+
|
|
33
|
+
// SELECT list shared by read and readStream. `data`/`meta` are jsonb (returned
|
|
34
|
+
// already parsed); `tags` is text[] (a JS array); the cursor and recorded_at are
|
|
35
|
+
// computed in SQL so the row maps straight to a rawSequencedEvent.
|
|
36
|
+
let selectColumns = "
|
|
37
|
+
lpad(transaction_id::text, 20, '0') || ':' || lpad(position::text, 20, '0') AS cursor,
|
|
38
|
+
event_type,
|
|
39
|
+
tags,
|
|
40
|
+
data,
|
|
41
|
+
meta,
|
|
42
|
+
to_char(recorded_at AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"') AS recorded_at
|
|
43
|
+
"
|
|
44
|
+
|
|
45
|
+
// Decode a 'key=value' tag string (split on the first '=') back to a DcbTag.tag.
|
|
46
|
+
let decodeTag = (s: string): DcbTag.tag =>
|
|
47
|
+
switch s->String.indexOf("=") {
|
|
48
|
+
| -1 => {key: s, value: ""}
|
|
49
|
+
| i => {
|
|
50
|
+
key: s->String.slice(~start=0, ~end=i),
|
|
51
|
+
value: s->String.slice(~start=i + 1, ~end=s->String.length),
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let decodeTags = (v: option<JSON.t>): array<DcbTag.tag> =>
|
|
56
|
+
switch v {
|
|
57
|
+
| Some(JSON.Array(arr)) =>
|
|
58
|
+
arr->Array.filterMap(x =>
|
|
59
|
+
switch x {
|
|
60
|
+
| JSON.String(s) => Some(decodeTag(s))
|
|
61
|
+
| _ => None
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
| _ => []
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let rowToEvent = (row: dict<JSON.t>): DcbEventLog_Adapter.rawSequencedEvent => {
|
|
68
|
+
let str = key =>
|
|
69
|
+
switch row->Dict.get(key) {
|
|
70
|
+
| Some(JSON.String(s)) => s
|
|
71
|
+
| _ => ""
|
|
72
|
+
}
|
|
73
|
+
let meta = switch row->Dict.get("meta") {
|
|
74
|
+
| Some(metaJson) => metaJson->S.parseJsonOrThrow(Reventless.Message.metaSchema)
|
|
75
|
+
| None => JsError.throwWithMessage("missing meta column in dcb_event row")
|
|
76
|
+
}
|
|
77
|
+
{
|
|
78
|
+
DcbEventLog_Adapter.position: str("cursor"),
|
|
79
|
+
eventType: str("event_type"),
|
|
80
|
+
data: row->Dict.get("data")->Option.getOr(JSON.Encode.null),
|
|
81
|
+
tags: decodeTags(row->Dict.get("tags")),
|
|
82
|
+
meta,
|
|
83
|
+
recordedAt: str("recorded_at"),
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// A tiny positional-parameter builder. Postgres uses `$1, $2, …` (not `?`), so we
|
|
88
|
+
// accumulate params and mint tokens as we build the WHERE. A token may be reused
|
|
89
|
+
// (same `$N`) to reference one param twice — used for the `after` cursor columns.
|
|
90
|
+
type paramBuilder = {mutable params: array<JSON.t>}
|
|
91
|
+
let mkBuilder = () => {params: []}
|
|
92
|
+
let param = (b: paramBuilder, v: JSON.t): string => {
|
|
93
|
+
b.params->Array.push(v)
|
|
94
|
+
"$" ++ Int.toString(b.params->Array.length)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Build the read WHERE + params for a query. `applyFence` gates the xmin read
|
|
98
|
+
// barrier (true for consumer reads, so cursors are stable). `after` is the
|
|
99
|
+
// decoded (tx, pos) cursor pair as numeric strings.
|
|
100
|
+
let buildReadWhere = (
|
|
101
|
+
b: paramBuilder,
|
|
102
|
+
~name: string,
|
|
103
|
+
~query: DcbTag.query,
|
|
104
|
+
~after: option<(string, string)>,
|
|
105
|
+
~applyFence: bool,
|
|
106
|
+
): string => {
|
|
107
|
+
let parts = [`log_name = ${b->param(JSON.Encode.string(name))}`]
|
|
108
|
+
if applyFence {
|
|
109
|
+
parts->Array.push("transaction_id < pg_snapshot_xmin(pg_current_snapshot())")
|
|
110
|
+
}
|
|
111
|
+
switch after {
|
|
112
|
+
| Some((tx, pos)) =>
|
|
113
|
+
let txP = b->param(JSON.Encode.string(tx))
|
|
114
|
+
let posP = b->param(JSON.Encode.string(pos))
|
|
115
|
+
parts->Array.push(
|
|
116
|
+
`(transaction_id > ${txP}::xid8 OR (transaction_id = ${txP}::xid8 AND position > ${posP}::bigint))`,
|
|
117
|
+
)
|
|
118
|
+
| None => ()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if query->Array.length > 0 {
|
|
122
|
+
let clauseSqls = query->Array.map(clause => {
|
|
123
|
+
let clauseParts = []
|
|
124
|
+
switch clause.eventTypes {
|
|
125
|
+
| Some(types) if types->Array.length > 0 =>
|
|
126
|
+
let ph = types->Array.map(t => b->param(JSON.Encode.string(t)))->Array.join(",")
|
|
127
|
+
clauseParts->Array.push(`event_type IN (${ph})`)
|
|
128
|
+
| _ => ()
|
|
129
|
+
}
|
|
130
|
+
switch clause.tags {
|
|
131
|
+
| Some(tags) if tags->Array.length > 0 =>
|
|
132
|
+
let arr =
|
|
133
|
+
tags
|
|
134
|
+
->Array.map(t => b->param(JSON.Encode.string(t.key ++ "=" ++ t.value)))
|
|
135
|
+
->Array.join(",")
|
|
136
|
+
clauseParts->Array.push(`tags @> ARRAY[${arr}]::text[]`)
|
|
137
|
+
| _ => ()
|
|
138
|
+
}
|
|
139
|
+
clauseParts->Array.length == 0 ? "TRUE" : "(" ++ clauseParts->Array.join(" AND ") ++ ")"
|
|
140
|
+
})
|
|
141
|
+
parts->Array.push("(" ++ clauseSqls->Array.join(" OR ") ++ ")")
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
parts->Array.join(" AND ")
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Strip the zero-padding a cursor carries for string-sortability, leaving a
|
|
148
|
+
// plain decimal both `::xid8` and `::bigint` parse unambiguously ("0" if empty).
|
|
149
|
+
let stripZeros = (s: string): string => {
|
|
150
|
+
let t = s->String.replaceRegExp(%re("/^0+/"), "")
|
|
151
|
+
t == "" ? "0" : t
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Split a '<xid8>:<position>' cursor into its two numeric-string columns.
|
|
155
|
+
let decodeCursor = (pos: DcbTag.sequencePosition): option<(string, string)> =>
|
|
156
|
+
switch pos->String.split(":") {
|
|
157
|
+
| [tx, p] => Some((stripZeros(tx), stripZeros(p)))
|
|
158
|
+
| _ => None
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Rows-per-page for readStream keyset pagination.
|
|
162
|
+
let pageSize = 500
|
|
163
|
+
|
|
164
|
+
let isConflict = (exn: exn): bool => {
|
|
165
|
+
let msg = exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("")
|
|
166
|
+
msg->String.includes("dcb_conflict") ||
|
|
167
|
+
msg->String.includes("duplicate key") ||
|
|
168
|
+
msg->String.includes("23505")
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let countAll = async (pool: PgDriver.pool): int =>
|
|
172
|
+
switch await pool->PgDriver.queryOne("SELECT COUNT(*)::bigint AS c FROM dcb_event", []) {
|
|
173
|
+
| Some(row) =>
|
|
174
|
+
switch row->Dict.get("c") {
|
|
175
|
+
| Some(JSON.String(s)) => s->Int.fromString->Option.getOr(0)
|
|
176
|
+
| Some(JSON.Number(n)) => Float.toInt(n)
|
|
177
|
+
| _ => 0
|
|
178
|
+
}
|
|
179
|
+
| None => 0
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let makeStorage = (
|
|
183
|
+
~pool: PgDriver.pool,
|
|
184
|
+
~name: string,
|
|
185
|
+
~indexes as _,
|
|
186
|
+
~partitionTag as _,
|
|
187
|
+
~crossPartitionTagKeys as _=?,
|
|
188
|
+
~opts as _,
|
|
189
|
+
~lockStrategy: lockStrategy=#AdvisoryLocks,
|
|
190
|
+
~onAppended=noTracking,
|
|
191
|
+
) => {
|
|
192
|
+
// Fenced head cursor: the highest (transaction_id, position) visible under the
|
|
193
|
+
// xmin barrier. Stable across reads, so it is a safe consistency marker.
|
|
194
|
+
let currentHead = async (): option<string> =>
|
|
195
|
+
switch await pool->PgDriver.queryOne(
|
|
196
|
+
"SELECT lpad(transaction_id::text, 20, '0') || ':' || lpad(position::text, 20, '0') AS head
|
|
197
|
+
FROM dcb_event
|
|
198
|
+
WHERE log_name = $1 AND transaction_id < pg_snapshot_xmin(pg_current_snapshot())
|
|
199
|
+
ORDER BY transaction_id DESC, position DESC
|
|
200
|
+
LIMIT 1",
|
|
201
|
+
[JSON.Encode.string(name)],
|
|
202
|
+
) {
|
|
203
|
+
| Some(row) =>
|
|
204
|
+
switch row->Dict.get("head") {
|
|
205
|
+
| Some(JSON.String(s)) => Some(s)
|
|
206
|
+
| _ => None
|
|
207
|
+
}
|
|
208
|
+
| None => None
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let runQuery = async (~query, ~after): array<DcbEventLog_Adapter.rawSequencedEvent> => {
|
|
212
|
+
let b = mkBuilder()
|
|
213
|
+
let where = buildReadWhere(b, ~name, ~query, ~after, ~applyFence=true)
|
|
214
|
+
let sql = `SELECT ${selectColumns} FROM dcb_event WHERE ${where} ORDER BY transaction_id ASC, position ASC`
|
|
215
|
+
(await pool->PgDriver.query(sql, b.params))->Array.map(rowToEvent)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let read = async (~query: DcbTag.query, ~after=?): DcbEventLog_Adapter.rawReadResult => {
|
|
219
|
+
let afterCols = after->Option.flatMap(decodeCursor)
|
|
220
|
+
let events = await runQuery(~query, ~after=afterCols)
|
|
221
|
+
switch await currentHead() {
|
|
222
|
+
| Some(head) => {DcbEventLog_Adapter.events, headPosition: head}
|
|
223
|
+
| None => ({DcbEventLog_Adapter.events: events}: DcbEventLog_Adapter.rawReadResult)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
let append = async (
|
|
228
|
+
newEvents: array<DcbEventLog_Adapter.rawStoredEvent>,
|
|
229
|
+
~condition=?,
|
|
230
|
+
): result<DcbTag.sequencePosition, ReventlessInfra.DcbEventLog.appendError> => {
|
|
231
|
+
let eventsJson = JSON.Array(
|
|
232
|
+
newEvents->Array.map(ev =>
|
|
233
|
+
JSON.Object(
|
|
234
|
+
Dict.fromArray([
|
|
235
|
+
("event_type", JSON.Encode.string(ev.eventType)),
|
|
236
|
+
(
|
|
237
|
+
"tags",
|
|
238
|
+
JSON.Array(ev.tags->Array.map(t => JSON.Encode.string(t.key ++ "=" ++ t.value))),
|
|
239
|
+
),
|
|
240
|
+
("data", ev.data),
|
|
241
|
+
("meta", ev.meta->S.reverseConvertToJsonOrThrow(Reventless.Message.metaSchema)),
|
|
242
|
+
]),
|
|
243
|
+
)
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
let conditionParam = switch condition {
|
|
247
|
+
| Some(cond: DcbTag.appendCondition) =>
|
|
248
|
+
let queryJson = JSON.Array(
|
|
249
|
+
cond.query->Array.map(clause =>
|
|
250
|
+
JSON.Object(
|
|
251
|
+
Dict.fromArray([
|
|
252
|
+
(
|
|
253
|
+
"eventTypes",
|
|
254
|
+
switch clause.eventTypes {
|
|
255
|
+
| Some(types) => JSON.Array(types->Array.map(JSON.Encode.string))
|
|
256
|
+
| None => JSON.Encode.null
|
|
257
|
+
},
|
|
258
|
+
),
|
|
259
|
+
(
|
|
260
|
+
"tags",
|
|
261
|
+
switch clause.tags {
|
|
262
|
+
| Some(tags) =>
|
|
263
|
+
JSON.Array(tags->Array.map(t => JSON.Encode.string(t.key ++ "=" ++ t.value)))
|
|
264
|
+
| None => JSON.Encode.null
|
|
265
|
+
},
|
|
266
|
+
),
|
|
267
|
+
]),
|
|
268
|
+
)
|
|
269
|
+
),
|
|
270
|
+
)
|
|
271
|
+
let fields = [("query", queryJson)]
|
|
272
|
+
switch cond.after {
|
|
273
|
+
| Some(a) => fields->Array.push(("after", JSON.Encode.string(a)))
|
|
274
|
+
| None => ()
|
|
275
|
+
}
|
|
276
|
+
JSON.Encode.string(JSON.stringify(JSON.Object(Dict.fromArray(fields))))
|
|
277
|
+
| None => JSON.Encode.null
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
let rows = await pool->PgDriver.query(
|
|
282
|
+
"SELECT dcb_append($1, $2::jsonb, $3::jsonb, $4) AS pos",
|
|
283
|
+
[
|
|
284
|
+
JSON.Encode.string(name),
|
|
285
|
+
JSON.Encode.string(JSON.stringify(eventsJson)),
|
|
286
|
+
conditionParam,
|
|
287
|
+
JSON.Encode.string(strategyParam(lockStrategy)),
|
|
288
|
+
],
|
|
289
|
+
)
|
|
290
|
+
switch rows->Array.get(0)->Option.flatMap(r => r->Dict.get("pos")) {
|
|
291
|
+
| Some(JSON.String(cursor)) =>
|
|
292
|
+
// Feed the projection checkpoint (Dcb axis): (msgId, numeric position).
|
|
293
|
+
onAppended(
|
|
294
|
+
newEvents->Array.filterMap(ev =>
|
|
295
|
+
switch decodeCursor(cursor) {
|
|
296
|
+
| Some((_, pos)) =>
|
|
297
|
+
pos->Int.fromString->Option.map(p => (ev.meta.Reventless.Message.msgId, p))
|
|
298
|
+
| None => None
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
)
|
|
302
|
+
Ok(cursor)
|
|
303
|
+
| _ => Error(ReventlessInfra.DcbEventLog.StorageFailure("dcb_append returned no position"))
|
|
304
|
+
}
|
|
305
|
+
} catch {
|
|
306
|
+
| exn =>
|
|
307
|
+
isConflict(exn)
|
|
308
|
+
? Error(ReventlessInfra.DcbEventLog.Conflict)
|
|
309
|
+
: Error(
|
|
310
|
+
ReventlessInfra.DcbEventLog.StorageFailure(
|
|
311
|
+
exn->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("storage error"),
|
|
312
|
+
),
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ~strongConsistency is a genuine no-op here: every read applies the xmin
|
|
318
|
+
// barrier, so it is always safely consistent (at the cost of a few ms lag).
|
|
319
|
+
//
|
|
320
|
+
// Keyset pagination on (transaction_id, position): one ordered SQL source, no
|
|
321
|
+
// per-clause fan-out / k-way merge / dedup (the DynamoDB runtime's layers have
|
|
322
|
+
// no Postgres counterpart). Each page reads strictly after the previous page's
|
|
323
|
+
// last row; a short page ends the stream.
|
|
324
|
+
let readStream = (~query: DcbTag.query, ~after=?, ~strongConsistency as _=?) =>
|
|
325
|
+
Stream.paginateEffect(after->Option.flatMap(decodeCursor), cursor =>
|
|
326
|
+
Effect.promise(() => {
|
|
327
|
+
let b = mkBuilder()
|
|
328
|
+
let where = buildReadWhere(b, ~name, ~query, ~after=cursor, ~applyFence=true)
|
|
329
|
+
let sql = `SELECT ${selectColumns}, transaction_id::text AS tx_raw, position::text AS pos_raw FROM dcb_event WHERE ${where} ORDER BY transaction_id ASC, position ASC LIMIT ${Int.toString(pageSize)}`
|
|
330
|
+
pool->PgDriver.query(sql, b.params)
|
|
331
|
+
})->Effect.map(rows => {
|
|
332
|
+
let events = rows->Array.map(rowToEvent)
|
|
333
|
+
// Continue only on a full page; the next `after` is this page's last row.
|
|
334
|
+
let next = if rows->Array.length < pageSize {
|
|
335
|
+
None
|
|
336
|
+
} else {
|
|
337
|
+
switch rows->Array.get(rows->Array.length - 1) {
|
|
338
|
+
| Some(lastRow) =>
|
|
339
|
+
switch (lastRow->Dict.get("tx_raw"), lastRow->Dict.get("pos_raw")) {
|
|
340
|
+
| (Some(JSON.String(tx)), Some(JSON.String(p))) => Some(Some((tx, p)))
|
|
341
|
+
| _ => None
|
|
342
|
+
}
|
|
343
|
+
| None => None
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
(events, next)
|
|
347
|
+
})
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
let ops: DcbEventLog_Adapter.operations = {read, append, readStream}
|
|
351
|
+
(name, ops, {DcbEventLog_Adapter.resources: [], operations: Pulumi.Output.make(ops)})
|
|
352
|
+
}
|