scalecube-js
scalecube-js copied to clipboard
optimize scalecube - serverLifePeriodMS option
General description
every microservice container can act as a seed for another microservice container in our distributed env.
it results in inflation of unnecessary listeners which are added to the project.
every microservice that acts as a seed creates a "server-side" logic which means using a global listener that checks if it's been called.
my suggestion is to add to microservice API another property which called "serverLifePeriodMS: number"
if (serverLifePeriodMS === undefined) {
// server listener will live forever
} else {
// server will stop listen after serverLifePeriodMS is done
}
this option is good when we creating an empty microservice that is used only to get proxies of other microservice containers, we can pass serverLifePeriodMS = 0.
or if we are running on the browser and we know that our services will load after x period of time, then we can set our serverLifePeriodMS to be 2*x.
this option is valid for the browser because it is unusual for service to be "destroyed" in the browser.
this is another reason why cluster-browser does not implement a "keep-alive" check.
API
Design proposition
A clear and concise description of the design proposition.
-
[x] Is backward compatible
-
[x] Adds new API
Pull Request
[Link]
New API
Code snippet
export interface MicroserviceOptions {
// ... all previus methods unchanged
serverLifePeriodMS : number
}
Ready for implementation
-
[x] External dependencies have been resolved
-
[ ] API has been approved
-
[ ] Test cases have been prepared
-
[ ] Discussed with Technical lead
Definition of Done
-
[ ] Developer review
-
[ ] QA review
-
[ ] All tests are implemented
-
[ ] Documentation