Setup Postgres-based message queue

This commit is contained in:
Steffo 2024-10-23 03:44:20 +02:00
parent b29211c387
commit 0df82ac931
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 8 additions and 1 deletions

View file

@ -1,6 +1,7 @@
import Postgres from "@@npm/postgres"
import { getLogger } from "@logtape/logtape"
import { exportJwk, generateCryptoKeyPair, KvStore } from "@fedify/fedify"
import { exportJwk, generateCryptoKeyPair, KvStore, MessageQueue } from "@fedify/fedify"
import { PostgresMessageQueue } from "@fedify/postgres"
import { PostgresKvStore } from "@fedify/postgres/kv"
@ -50,6 +51,11 @@ export class Database {
return new PostgresKvStore(this.sql, {})
}
useAsMessageQueue(): MessageQueue {
l.info`Creating Postgres message queue...`
return new PostgresMessageQueue(this.sql, {})
}
async #doQueryFile<T>(path: string, variables: Postgres.ParameterOrJSON<any>[] = []): Promise<Postgres.RowList<T[]>> {
try {
l.debug`Running query at ${path}...`

View file

@ -23,6 +23,7 @@ export class DotinoVeloce {
this.federation = createFederation<ContextData>({
kv: db.useAsKvStore(),
queue: db.useAsMessageQueue(),
})
this.federation