PubSubInterceptor
PubSubInterceptor = (
next) =>PubSubInterceptorFn
Defined in: packages/pubsub/src/types.ts:202
A connectrpc-style interceptor for pubsub transport operations.
Interceptors form a middleware chain around transport publish, delivery, and
lifecycle operations. Each interceptor receives a next function and returns
a new function that can run logic before and/or after calling next.
const logger: PubSubInterceptor = (next) => async (ctx) => { if (ctx.operation === "publish" || ctx.operation === "handle") { const start = performance.now(); try { return await next(ctx); } finally { console.log(`${ctx.operation}: ${performance.now() - start}ms`); } } return next(ctx);};
// Narrowing on operation:const metrics: PubSubInterceptor = (next) => async (ctx) => { if (ctx.operation === "committed") { counter.increment("committed"); } return next(ctx);};