-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microservices Support missing #37
Comments
Hi @moparlakci thanks for writing in. Currently this library is intended to work under a http REQUEST scoped session. Hence microservice based request isn't something that this library would be a able to process at the moment. This is a possible candidate for a PR. Happy to review it if someone can give it a try. |
I think I fixed it myself by changing the TenancyCoreModule a little.. Just if you add a check to the following code inside `
|
Because otherwise any controller endpoint using a MessagePattern or EventPattern decorator is not useable with this package. |
@moparlakci true that and glad that you solved it on your own. Can you raise a PR for this with a unit test case as-well for the microservice change bit that you have made. I would review it and release a new change. |
Hello, changed the functions to use context in stead of req properties. But injection of the ExecutionContext is still a problem at the moment. the following injects a Request object into context, but its expecting a ExecuitionContext and therefore getType() method rasies an error.
|
Hi @sandeepsuvit, Can you check my fork? Couldnt use context functions, something to do with the injection of the CONTEXT token which is an alias for the REQUEST token. See my fork here Tests are passing.. Thanks in advance |
@sandeepsuvit any updates on this? I will also debug further.. |
This is exactly what i was trying to do @moparlakci . This entire library is written on Request architecture. anything which touches this flow will become request scopped. meaning nestjs will create new instance on every request for each repository each services. i think this is not efficient. if it would have been interceptor or some other logic then it would be more efficient. i have used this in production it this is causing issues with large traffic. I am re writing entire logic for multi tenancy. i would checked this before using this library. @moparlakci I think I can help you rewrite logic |
@moparlakci i tried your code. test cases are passing but
is not working. When i make http request it hangs is there any reason for not working this ? does not throw any error but application just hangs. i am not getting any response. |
Alright i now found the issue here. |
Hello
Thanks for the great tenancy module!
The only this that is missing is, microservices support.
We are using the Request/Response pattern from ClientProxy to talk to other microservices.
We use it also in our JwtStrategy (Passport), to validate user data from the database, which is stored in another microservice called 'auth'. We do that by sending a messagepattern to auth microservice.
But this is a tcp connection and therefore doesnt have Request object, so we get req.get is not a function error.
To give an example
We have an auth microservice with an auth module, and auth controller that looks like the below
`
`
in our JwtStrategy our validate function looks like below
`
`
in the Auth context we should be able to switch to another tenant connection, somehow.
and in the jwtStrategy we should send the Tenant Identifier by some means via a json property or so.
So a little change should be made to getTenantFromRequest or getTenant function, to check if the call is rpc or http..
So in our Auth Controller, the message comes in via TCP, RPC. And the nestjs-tenancy module cannot know which tenant to use. So basically microservices support is missing.
I hope we can add microservices support.
The text was updated successfully, but these errors were encountered: