-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0113ffb
Showing
26 changed files
with
5,703 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "master", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
root: true, | ||
// This tells ESLint to load the config from the package `eslint-config-acme` | ||
extends: [ "prettier"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# These are some examples of commonly ignored file patterns. | ||
# You should customize this list as applicable to your project. | ||
# Learn more about .gitignore: | ||
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore | ||
|
||
# Node artifact files | ||
**/node_modules/ | ||
**/dist/ | ||
**/build/ | ||
|
||
# sql dumps | ||
db/dumps/ | ||
|
||
.docker | ||
.env | ||
*.tar | ||
.DS_Store | ||
.turbo | ||
*.tsbuildinfo | ||
|
||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
yarn-error.log | ||
|
||
# Swap the comments on the following lines if you don't wish to use zero-installs | ||
# Documentation here: https://yarnpkg.com/features/zero-installs | ||
#!.yarn/cache | ||
.pnp.* | ||
|
||
|
||
cypress.env.json | ||
|
||
out/ | ||
|
||
.nyc_output | ||
coverage/ | ||
tests/.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# These are some examples of commonly ignored file patterns. | ||
# You should customize this list as applicable to your project. | ||
# Learn more about .gitignore: | ||
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore | ||
|
||
# Node artifact files | ||
**/node_modules/ | ||
**/dist/ | ||
**/build/ | ||
|
||
# sql dumps | ||
db/dumps/ | ||
|
||
.docker | ||
.env | ||
*.tar | ||
.DS_Store | ||
.turbo | ||
*.tsbuildinfo | ||
|
||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
yarn-error.log | ||
|
||
# Swap the comments on the following lines if you don't wish to use zero-installs | ||
# Documentation here: https://yarnpkg.com/features/zero-installs | ||
#!.yarn/cache | ||
.pnp.* | ||
|
||
|
||
cypress.env.json | ||
|
||
out/ | ||
|
||
.nyc_output | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules/ | ||
*.yaml | ||
*.yml | ||
*.env | ||
*.generated.* | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 IlijaNL | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.8' | ||
services: | ||
postgres: | ||
image: timescale/timescaledb-ha:pg14-latest | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: app | ||
ports: | ||
- '5432:5432' | ||
volumes: | ||
# used for initial setup | ||
- './db/dumps/:/docker-entrypoint-initdb.d/' | ||
restart: on-failure | ||
networks: | ||
- tbus | ||
networks: | ||
tbus: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE SCHEMA IF NOT EXISTS {{schema}}; | ||
|
||
CREATE TABLE IF NOT EXISTS {{schema}}."tbus_migrations" ( | ||
id integer PRIMARY KEY, | ||
name varchar(100) UNIQUE NOT NULL, | ||
hash varchar(40) NOT NULL, -- sha1 hex encoded hash of the file name and contents, to ensure it hasn't been altered since applying the migration | ||
"created_at" timestamptz NOT NULL DEFAULT now() | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
CREATE TABLE {{schema}}."cursors" ( | ||
"id" uuid NOT NULL DEFAULT gen_random_uuid(), | ||
"svc" text not null, | ||
"l_p" bigint not null default 0, | ||
"created_at" timestamptz NOT NULL DEFAULT now(), | ||
PRIMARY KEY ("id"), | ||
UNIQUE ("svc") | ||
); | ||
|
||
CREATE TABLE {{schema}}."events" ( | ||
"id" uuid NOT NULL DEFAULT gen_random_uuid(), | ||
"event_name" text NOT NULL, | ||
"event_data" jsonb NOT NULL, | ||
"pos" bigint not null default 0, | ||
"created_at" timestamptz NOT NULL DEFAULT now(), | ||
PRIMARY KEY ("id") | ||
); | ||
|
||
CREATE SEQUENCE {{schema}}.event_order as bigint start 1; | ||
|
||
CREATE FUNCTION {{schema}}.proc_set_position() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS | ||
$$ | ||
BEGIN | ||
-- this can be improved by partion locking | ||
PERFORM pg_advisory_xact_lock(1723683380); | ||
update {{schema}}."events" set pos = NEXTVAL('{{schema}}.event_order') where id = new.id; | ||
RETURN NULL; | ||
END; | ||
$$; | ||
|
||
-- it should break | ||
CREATE CONSTRAINT TRIGGER set_commit_order | ||
AFTER INSERT ON {{schema}}."events" | ||
DEFERRABLE INITIALLY DEFERRED | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE {{schema}}.proc_set_position(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "pg-tbus", | ||
"author": "IlijaNL", | ||
"version": "0.0.1", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.mjs", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsup ./src/index.ts --format cjs,esm --dts", | ||
"tc": "tsc --noEmit", | ||
"test": "tap --node-arg=--require=ts-node/register --no-check-coverage" | ||
}, | ||
"license": "MIT", | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org", | ||
"access": "public" | ||
}, | ||
"sideEffects": false, | ||
"dependencies": { | ||
"@sinclair/typebox": "^0.25.9", | ||
"ajv": "^8.8.2", | ||
"ajv-formats": "^2.1.1", | ||
"delay": "^5.0.0", | ||
"fast-json-stable-stringify": "^2.1.0", | ||
"lodash": "^4.17.21", | ||
"pg": "^8.8.0", | ||
"pg-boss": "^8.2.0", | ||
"pg-promise": "^10.12.0", | ||
"uuid": "^8.3.2" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "2.26.0", | ||
"@types/fs-extra": "^11.0.1", | ||
"@types/lodash": "^4.14.176", | ||
"@types/node": "^16.0.0", | ||
"@types/pg": "^8.6.4", | ||
"@types/tap": "^15.0.8", | ||
"@types/uuid": "^8.3.1", | ||
"eslint": "^8.4.1", | ||
"eslint-config-prettier": "^8.4.0", | ||
"fs-extra": "^11.1.0", | ||
"rimraf": "^3.0.2", | ||
"tap": "^16.3.4", | ||
"ts-node": "^10.7.0", | ||
"tsup": "^6.6.0", | ||
"typescript": "^4.9.0" | ||
} | ||
} |
Oops, something went wrong.