PhysarumSM / service-registry

Apache License 2.0
0 stars 0 forks source link

Does SendRequest() need to create a new node each time? #5

Closed t-lin closed 4 years ago

t-lin commented 4 years ago

https://github.com/Multi-Tier-Cloud/hash-lookup/blob/34fdbc06b5534642acc7bdb212ab852c786d659a/hl-common/hl-common.go#L51

What's the rationale or original reason? Can't remember if this was discussed in the meeting.

I can definitely see pros/cons:

hivanco commented 4 years ago

I figured usually you'd want to reuse the same node for all communications, which is why I made the function below it, SendRequestWithHostRouting(), which takes in an existing node and uses it to send a request. Indeed, in the most critical use case, when the proxy queries hash lookup, it calls GetHashWithHostRouting(), which in turn calls SendRequestWithHostRouting() to avoid creating a new node each time.

hivanco commented 4 years ago

To answer your original question, I wrote SendRequest() for the case where all you want to do is make a single request, so instead of the caller having to write the new node setup code, I put it in SendRequest(). For ex. hl-cli will make a single call to one of Add/Get/List/DeleteHash(), and those functions just call SendRequest(). Another ex. When the proxy boots for the first time, it needs to get the hash of its designated microservice before it can set up its own permanent node, so it does call GetHash() once, creating that temporary node in the process.

t-lin commented 4 years ago

Alright, thanks. The CLI example seems like a good use-case, and I think it's good to provide extra flexibility.

The LCA manager currently calls GetHash() (which calls GetRequest()) so I think I can change that to the other function types, it'd probably speed up the request and search.