Closed kevbook closed 3 weeks ago
Just in case, that's too much of a change, node postgres
driver works for serverless too, especially for cloudflare workers. I think this would "mostly" be a drop-in replacement
The db prop in the constructor is for bypassing the internal driver. Have you tried this?
Ah, that makes sense, this works locally. I'll test it on the edge
import { neon } from '@neondatabase/serverless';
import PgBoss from 'pg-boss';
import { Config } from '$config/config';
// Create a postgres client and ensure connection (send a ping)
const postgres = neon(Config.pgBoss.connString, {
fullResults: true,
fetchOptions: { priority: 'high' },
});
const boss = new PgBoss({
application_name: Config.service.name,
migrate: false,
db: {
executeSql: async function (text: string, values: any[]) {
return postgres(text, values);
},
},
});
const id = await boss.send('help-me', { hello: 'world' });
console.log(`created job: ${id}`);
This enables us to use this in serverless environments. Below uses websockets internally
Basically, it kind of bypasses
.db.js