@stablemates/workhorse-kysely
v0.9.0
Published
Public beta Kysely provider for Workhorse
Readme
@stablemates/workhorse-kysely
The Kysely provider for enqueuing Workhorse tasks through Kysely transactions.
Public beta: Workhorse is usable for evaluation and early production adoption. A 0.x minor release may change behaviour, so read the changelog before you upgrade. It will not ask you to recreate your database: migrations are ordered, and inside a major line a migration only adds, so a running deployment upgrades in place.
Install
npm install @stablemates/workhorse @stablemates/workhorse-kysely kysely pgEnqueue in a transaction
import { createKyselyAdapter } from "@stablemates/workhorse-kysely";
const workhorse = createKyselyAdapter(database, {
pool,
close: () => database.destroy(),
});
await database.transaction().execute(async (transaction) => {
// Application writes through transaction...
await workhorse.forTransaction(transaction).enqueue("email.send", {
recipient: "[email protected]",
});
});Package boundary
The adapter never destroys a caller-owned Kysely database unless close is configured.
Workhorse core owns schema installation and changes.
Pass the pg pool used by PostgresDialect as pool. Workers take their heartbeat and
LISTEN/NOTIFY connections from it, and refuse to start without it unless sharedHeartbeats is
set. Database errors become KyselyQueryError, with the original error in cause and its
PostgreSQL code copied to code.
Next
- Read the Kysely integration guide and API reference.
- Browse the repository or report a problem in GitHub issues.
License
Apache-2.0. See LICENSE and NOTICE in the package.
