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

Allow ServiceInstanceIdRegistry to manually register id selected by user #11

Open
swarmshine opened this issue Jul 3, 2020 · 0 comments

Comments

@swarmshine
Copy link
Member

ServiceInstanceIdRegistry allows you to receive unique id from pool of generated ids on demand.
It is handy when you do not care about id numbers, acquired by your application instances:

Application A

fun main(){
  // 7
  val appId = registry.register("my-app")
}

Application B

fun main(){
  //13
  val appId = registry.register("my-app")
}

It is useful to have an opportunity to explicitly select which id which application instance will receive.
For example you have a cluster of applications of two types: red-apps and black-apps.
And to distinct them by id you can give them particular ids:

red-app #10     black-app #20
red-app #11     black-app #21
red-app #12
red-app #13

We can add new method to registry that allows user explicitly provide desirable identifier.
Then we can provide this id through command arguments during application startup.

java -jar red-app.jar --desirableId=10
fun main(args: String[]){
  val desirableId = idFromArguments(args)
  //10
  val appId = registry.register("red-app", desirableId)
}

This way we can control what id will be received by application during startup.
It is very handy during problem investigations: by id of application it is easily to detect a node.

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