Merge branch 'firehose-kinds' into 'main'

Add FIREHOSE_KINDS variable

See merge request soapbox-pub/ditto!501
This commit is contained in:
Alex Gleason 2024-09-20 02:56:03 +00:00
commit cc2b5cf66a
2 changed files with 7 additions and 1 deletions

View file

@ -209,6 +209,12 @@ class Conf {
static get firehoseConcurrency(): number { static get firehoseConcurrency(): number {
return Math.ceil(Number(Deno.env.get('FIREHOSE_CONCURRENCY') ?? (Conf.pg.poolSize * 0.25))); return Math.ceil(Number(Deno.env.get('FIREHOSE_CONCURRENCY') ?? (Conf.pg.poolSize * 0.25)));
} }
/** Nostr event kinds of events to listen for on the firehose. */
static get firehoseKinds(): number[] {
return (Deno.env.get('FIREHOSE_KINDS') ?? '0, 1, 3, 5, 6, 7, 9735, 10002')
.split(/[, ]+/g)
.map(Number);
}
/** Whether to enable Ditto cron jobs. */ /** Whether to enable Ditto cron jobs. */
static get cronEnabled(): boolean { static get cronEnabled(): boolean {
return optionalBooleanSchema.parse(Deno.env.get('CRON_ENABLED')) ?? true; return optionalBooleanSchema.parse(Deno.env.get('CRON_ENABLED')) ?? true;

View file

@ -19,7 +19,7 @@ const sem = new Semaphore(Conf.firehoseConcurrency);
export async function startFirehose(): Promise<void> { export async function startFirehose(): Promise<void> {
const store = await Storages.client(); const store = await Storages.client();
for await (const msg of store.req([{ kinds: [0, 1, 3, 5, 6, 7, 9735, 10002], limit: 0, since: nostrNow() }])) { for await (const msg of store.req([{ kinds: Conf.firehoseKinds, limit: 0, since: nostrNow() }])) {
if (msg[0] === 'EVENT') { if (msg[0] === 'EVENT') {
const event = msg[2]; const event = msg[2];
console.debug(`NostrEvent<${event.kind}> ${event.id}`); console.debug(`NostrEvent<${event.kind}> ${event.id}`);