Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
408764c
feat(supaworker): extract super simple iterface for starting in edge fn
jumski Jan 3, 2025
f369a4b
feat(worker): add Heartbeat class for periodic heartbeat management
jumski Jan 3, 2025
c680f74
fix(MessageExecutor): remove unnecessary abort check before archiving…
jumski Jan 3, 2025
3cffa63
feat(worker): add configurable maxPgConnections for PostgreSQL
jumski Jan 3, 2025
3988cfe
fix(supaworker): update handler return type to allow any promise
jumski Jan 3, 2025
d6fef1f
fix(worker): consolidate WorkerConfig initialization
jumski Jan 3, 2025
f2b6663
feat(worker): introduce ExecutionQueue and Logger for improved task m…
jumski Jan 4, 2025
d4929a6
refactor(worker): replace ExecutionQueue with ExecutionController
jumski Jan 4, 2025
398c625
feat(supaworker): backport `read_with_poll` from pgmq 1.5.0
jumski Jan 5, 2025
53816f8
refactor(worker): remove redundant executeMessage method
jumski Jan 5, 2025
57626b6
feat(worker): add maxConcurrency configuration option
jumski Jan 5, 2025
9a78235
refactor(supaworker): use single waitUntil
jumski Jan 5, 2025
22f380e
feat(supaworker): add function name tracking to heartbeat
jumski Jan 5, 2025
6833c2b
feat(supaworker): make edgeFunctionName readonly and conditional in s…
jumski Jan 5, 2025
c4f7eb9
fix(supaworker): update message re-queue logic to use setVt
jumski Jan 5, 2025
7363dd1
chore: rename supabase-worker to supaworker
jumski Jan 6, 2025
1523069
chore(supaworker): remove all old files
jumski Jan 6, 2025
8724e89
feat(repo): merge main from /home/jumski/Code/jumski/feedwise
jumski Jan 6, 2025
ebf37c3
chore(supaworker): setup proper deno.json and import map
jumski Jan 6, 2025
2d29296
chore(nx): add @nx/node with eslint
jumski Jan 6, 2025
c9b5ae9
chore(supaworker-tests): intitial
jumski Jan 6, 2025
7a5ef18
chore(nx): add @nx/vite
jumski Jan 6, 2025
57e8dc4
chore(nx): update nx.json with vite
jumski Jan 6, 2025
f168b03
chore(supaworker-tests): setup @nx/vite with vitest
jumski Jan 6, 2025
2390b39
chore(supaworker-tests): setup barebones simple test environment with…
jumski Jan 6, 2025
8541a13
chore(supaworker-tests): add supabase project
jumski Jan 6, 2025
9f7b728
feat(supaworker-tests): add sql migration
jumski Jan 6, 2025
2952932
feat(supaworker-tests): add sh-tests
jumski Jan 6, 2025
6bd0dff
style: code style
jumski Jan 6, 2025
f629275
chore: add supabase/cli script
jumski Jan 6, 2025
73440a0
chore(supaworker-tests): setup supabase db-only local instance
jumski Jan 7, 2025
2df643f
chore(supaworker-tests): setup nx target for pgtap and starting supabase
jumski Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ Thumbs.db

.nx/cache
.nx/workspace-data

vite.config.*.timestamp*
vitest.config.*.timestamp*
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"denoland.vscode-deno"
"denoland.vscode-deno",
"dbaeumer.vscode-eslint"
]
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"deno.enablePaths": ["packages/supabase-worker"],
"deno.enablePaths": [
"packages/supabase-worker"
],
"deno.unstable": true,
"deno.importMap": "./import_map.json"
}
40 changes: 40 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const nx = require('@nx/eslint-plugin');

module.exports = [
...nx.configs['flat/base'],
...nx.configs['flat/typescript'],
...nx.configs['flat/javascript'],
{
ignores: ['**/dist'],
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
{
files: [
'**/*.ts',
'**/*.tsx',
'**/*.js',
'**/*.jsx',
'**/*.cjs',
'**/*.mjs',
],
// Override or add rules here
rules: {},
},
];
3 changes: 2 additions & 1 deletion import_map.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"imports": {
"@pgflow/supabase-worker": "./pkgs/supabase-worker/mod.ts"
"@pgflow/supaworker": "./pkgs/supaworker/mod.ts",
"postgres": "https://deno.land/x/postgresjs@v3.4.5/mod.js"
}
}
36 changes: 32 additions & 4 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": ["default"],
"sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"]
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.cjs",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/src/test-setup.[jt]s"
],
"sharedGlobals": [
"{workspaceRoot}/.github/workflows/ci.yml"
]
},
"nxCloudId": "676490227393fa777407053a",
"plugins": ["@nx/js/typescript", "@nx/deno"]
"plugins": [
"@nx/js/typescript",
"@nx/eslint/plugin",
"@axhxrx/nx-deno"
],
"targetDefaults": {
"@nx/esbuild:esbuild": {
"cache": true,
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
]
}
}
}
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,30 @@
"private": true,
"devDependencies": {
"@axhxrx/nx-deno": "^1.0.2",
"@nx/js": "20.2.2",
"@eslint/js": "^9.8.0",
"@nx/esbuild": "20.3.0",
"@nx/eslint": "20.2.2",
"@nx/eslint-plugin": "20.3.0",
"@nx/js": "20.3.0",
"@nx/node": "^20.3.0",
"@nx/vite": "^20.2.2",
"@nx/web": "20.3.0",
"@swc-node/register": "~1.9.1",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
"@types/node": "~18.16.9",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.3.1",
"esbuild": "^0.19.2",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.0.0",
"jsdom": "~22.1.0",
"nx": "20.2.2",
"prettier": "^2.6.2",
"tslib": "^2.3.0",
"typescript": "~5.6.2"
"typescript": "~5.6.2",
"typescript-eslint": "^8.13.0",
"vite": "^5.0.0",
"vitest": "^1.3.1"
}
}
9 changes: 0 additions & 9 deletions pkgs/supabase-worker/deno.lock

This file was deleted.

1 change: 0 additions & 1 deletion pkgs/supabase-worker/mod.ts

This file was deleted.

109 changes: 0 additions & 109 deletions pkgs/supabase-worker/src/Worker.ts

This file was deleted.

10 changes: 0 additions & 10 deletions pkgs/supabase-worker/src/sql.ts

This file was deleted.

6 changes: 0 additions & 6 deletions pkgs/supabase-worker/src/supabase-worker.test.ts

This file was deleted.

7 changes: 0 additions & 7 deletions pkgs/supabase-worker/src/supabase-worker.ts

This file was deleted.

7 changes: 0 additions & 7 deletions pkgs/supabase-worker/src/types.ts

This file was deleted.

3 changes: 3 additions & 0 deletions pkgs/supaworker-tests/eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../../eslint.config.cjs');

module.exports = [...baseConfig];
40 changes: 40 additions & 0 deletions pkgs/supaworker-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@pgflow/supaworker-tests",
"version": "0.0.1",
"private": true,
"nx": {
"name": "supaworker-tests",
"projectType": "application",
"sourceRoot": "pkgs/supaworker-tests/src",
"targets": {
"supabase:start": {
"executor": "nx:run-commands",
"options": {
"cwd": "pkgs/supaworker-tests",
"commands": [
"supabase db start"
],
"parallel": false
}
},
"test:pgtap": {
"dependsOn": [
{
"target": "supabase:start"
}
],
"executor": "nx:run-commands",
"options": {
"cwd": "pkgs/supaworker-tests",
"commands": [
"supabase db test"
],
"parallel": false
}
}
}
},
"devDependencies": {
"supabase": "^2.2.1"
}
}
31 changes: 31 additions & 0 deletions pkgs/supaworker-tests/sh-tests/worker-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

source .env

# Default to 100000 if no argument provided
MSG_COUNT=${1:-5000}

psql "$DB_URL" -v msg_count="$MSG_COUNT" << SQL

DELETE FROM pgmq.q_pgflow;
DELETE FROM pgmq.a_pgflow;
DELETE FROM supaworker.workers;

-- 'counter' sequence for incrementing in task handlers
CREATE SEQUENCE IF NOT EXISTS pgflow_counter_seq;
ALTER SEQUENCE pgflow_counter_seq RESTART WITH 1;

-- job id sequence
CREATE SEQUENCE IF NOT EXISTS pgflow_value_seq;
ALTER SEQUENCE pgflow_value_seq RESTART WITH 1;

-- enqueue a bunch of messages
SELECT pgmq.send(
'pgflow',
('{"value": ' || nextval('pgflow_value_seq')::text || '}')::jsonb
)
FROM generate_series(1, :msg_count) as i;

SELECT supaworker.spawn(queue_name => 'pgflow-worker-2');

SQL
5 changes: 5 additions & 0 deletions pkgs/supaworker-tests/sh-tests/worker-test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source .env

psql "$DB_URL" -f queries/supaworker_jobs_per_second.sql
Loading
Loading