Add `debug` library, adapt pipeline to it
This commit is contained in:
parent
8f414a9aee
commit
520c35db60
|
@ -83,5 +83,7 @@ export { sentry as sentryMiddleware } from 'npm:@hono/sentry@^1.0.0';
|
||||||
export * as Comlink from 'npm:comlink@^4.4.1';
|
export * as Comlink from 'npm:comlink@^4.4.1';
|
||||||
export { EventEmitter } from 'npm:tseep@^1.1.3';
|
export { EventEmitter } from 'npm:tseep@^1.1.3';
|
||||||
export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0';
|
export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0';
|
||||||
|
// @deno-types="npm:@types/debug@^4.1.12"
|
||||||
|
export { default as Debug } from 'npm:debug@^4.3.4';
|
||||||
|
|
||||||
export type * as TypeFest from 'npm:type-fest@^4.3.0';
|
export type * as TypeFest from 'npm:type-fest@^4.3.0';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as eventsDB from '@/db/events.ts';
|
||||||
import { addRelays } from '@/db/relays.ts';
|
import { addRelays } from '@/db/relays.ts';
|
||||||
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
||||||
import { findUser } from '@/db/users.ts';
|
import { findUser } from '@/db/users.ts';
|
||||||
import { type Event, LRUCache } from '@/deps.ts';
|
import { Debug, type Event, LRUCache } from '@/deps.ts';
|
||||||
import { isEphemeralKind } from '@/kinds.ts';
|
import { isEphemeralKind } from '@/kinds.ts';
|
||||||
import * as mixer from '@/mixer.ts';
|
import * as mixer from '@/mixer.ts';
|
||||||
import { publish } from '@/pool.ts';
|
import { publish } from '@/pool.ts';
|
||||||
|
@ -18,6 +18,8 @@ import { verifySignatureWorker } from '@/workers/verify.ts';
|
||||||
|
|
||||||
import type { EventData } from '@/types.ts';
|
import type { EventData } from '@/types.ts';
|
||||||
|
|
||||||
|
const debug = Debug('ditto:pipeline');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common pipeline function to process (and maybe store) events.
|
* Common pipeline function to process (and maybe store) events.
|
||||||
* It is idempotent, so it can be called multiple times for the same event.
|
* It is idempotent, so it can be called multiple times for the same event.
|
||||||
|
@ -26,7 +28,7 @@ async function handleEvent(event: Event): Promise<void> {
|
||||||
if (!(await verifySignatureWorker(event))) return;
|
if (!(await verifySignatureWorker(event))) return;
|
||||||
const wanted = reqmeister.isWanted(event);
|
const wanted = reqmeister.isWanted(event);
|
||||||
if (encounterEvent(event)) return;
|
if (encounterEvent(event)) return;
|
||||||
console.info(`pipeline: Event<${event.kind}> ${event.id}`);
|
debug(`Event<${event.kind}> ${event.id}`);
|
||||||
const data = await getEventData(event);
|
const data = await getEventData(event);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -115,7 +117,7 @@ async function trackHashtags(event: Event): Promise<void> {
|
||||||
if (!tags.length) return;
|
if (!tags.length) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.info('tracking tags:', tags);
|
debug('tracking tags:', tags);
|
||||||
await TrendsWorker.addTagUsages(event.pubkey, tags, date);
|
await TrendsWorker.addTagUsages(event.pubkey, tags, date);
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
Loading…
Reference in New Issue