Add @UseCls decorator
(relates to #18)
Consider adding a @UseCls() method decorator to set up the context for a method automagically, when it is run outside of a request context.
// This is currently NOT supported
@Injectable()
export class CronController {
constructor(
private readonly someService: SomeService
)
@Cron('45 * * * * *')
@UseCls()
handleCron() {
this.cls.set(CLS_ID, uuid())
this.someService.doTheThing();
}
}
The decorator would need to replace the method's implementation by wrapping the actual call with the cls.run() method. This would be the prefered way of entering the CLS context for invoking CLS-aware code that does not go through a controller, where a middleware or enhancer take care of setting up the context.
Delaying this feature after I figure out #30 It should also seamlessly resolve Proxy Providers.
I guess you missed the declaration of cls field on CronController class