Open xiaokhkh opened 1 year ago
@xiaokhkh thanks for writing in. Yes you are correct the tenant can be resolved only by a request context until its available (since the information of the tenant is embedded inside the request context). But i did't get you last point on Can we improve the performance of tenant mode by saving service instances or manually obtaining models?
- Are you saying you have a solution for this and you want to submit a pr?
@sandeepsuvit pr is about manual get model above the above requirements.
The last question is the idea when doing the above requirements. but it has not been fully implemented. I might achieve it(improve the performance) in the direction or other idea?
@xiaokhkh your solution looks promising. I can evaluate it if you can provide a working example.
Hi guys, an example of use when I add a service to a Bull queue:
myapi | 2023-03-22T04:09:56.482Z ioredis:redis write command[221.20.0.5:6379]: 0 -> hmset('xxx:mail-queue:9,attemptsMade,1,stacktrace,["TypeError: req.get is not a function\n at Function.getTenantFromRequest (/home/node/app/node_modules/@needle-innovision/nestjs-tenancy/dist/tenancy-core ...
The request context is not available... I believe the solution would be to pass the tenantId manually from the Job parameters.
Hi @sandeepsuvit , Thank you very much for developing this interesting module for multi tenancy and its helping me a lot.
All service need request context, because scope of "TENANT-CONTEXT" Request context be destroy when i called method of tenant service because i use Subscription Publishing Mode. [error] req is undefine
so i write this
Manual service will not spread [request] scope.
If need i will submit the pr.
A question Can we improve the performance of tenant mode by saving service instances or manually obtaining models?
Thanks for all of your efforts. Looking forward to your reply :)