Skip to content
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

Investigate a better way to get the current Microservice rather than the Globals #337

Open
einari opened this issue Oct 22, 2024 · 0 comments

Comments

@einari
Copy link
Contributor

einari commented Oct 22, 2024

In the @cratis/applications package we have an object called Globals, this can be used to configure the current microservice. This is useful to be able to provide the x-cratis-microservice header or query parameter to commands and queries.
However, when running in a federated module scenario with this package being one of the shared packages, this becomes a global object for everyone and it is basically the last microservice that wins. In React we have the <ApplicationModel/> context that deals with this, which is good for React and hooks - however, when working with @cratis/applications.react.mvvm this quickly becomes a problem again, as it becomes problematic injecting commands or queries into view models.

We need an elegant solution to deal with this in a good way. We've invested in tsyringe as the IoC container. If we could get it to work with interception, we could basically intercept any resolved dependency and then call the setMicroservice() method on commands and queries relative to the current microservice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant