I have a NextJS app that pulls events from a queue and handles them. It does this by implementing handler classes for each event type and calling the handle function on them. Is it possible to have something similar to "request-scoped providers" for such polled events? I want that to inject logging trace ids for correlating the logs to events.
#Scoped logger for tracing ids on a long running task
3 messages · Page 1 of 1 (latest)
If I could react to those events as if they come in an http request that'd be perfect as I could just make provider request scoped. But they don't come as http requests so I am a bit lost.
This should be possible by manually constructing Request scoped DI subtrees (according to Kamil), but I have zero experience with that (https://github.com/nestjs/docs.nestjs.com/pull/2507#discussion_r1004212593). I've created a library that uses AsyncLocalStorage to track async context (nestjs-cls) and have been using that instead.
GitHub
PR Checklist
Please check if your PR fulfills the following requirements:
The commit message follows our guidelines: https://github.com/nestjs/docs.nestjs.com/blob/master/CONTRIBUTING.md
PR Type...