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
HandleOrForward functionality. #2
Comments
Contracts are a great way to write issues 👍
|
Can you share your thoughts, please? |
https://github.com/uber/ringpop-go/blob/dev/ringpop.go#L710 I visualized it as a way to know if it should be handled by this node or forwarded to someone else, both of which could be abstracted out via the So, HandleOrForward should return Either[V, Node]. V if there's value in this node or the actual Node to talk to get the data. If we went with abstracting this out into a function, we would have a function wrapping this, to return just Option[V], which takes care of forwarding logic too. |
Given the fact that we're going to take care of forwarding (isn't?) - shouldn't |
Even better would be if we can differentiate |
Pl take a stab at putting down the contract so that it's clear. |
sealed trait Node {
def get[R <: Response](r: GetRequest): R
def put[R <: Response)(r: PutRequest): R
}
abstract class AbstractNode extends Node {
def handleOrForward(key: Key, r: Request): Response = {
if (shouldHandle(key)) {
// Handle the request locally
} else {
forward(key)
}
}
def shouldHandleKey(key: Key): Boolean = { ... }
def forward(key: Key): Response = { ... }
} What do you think? |
This looks ok. Something that's not coming out clearly is And, when you say, |
I'm not sure. To me
I thought we discussed we'll only be supporting CH for the first cut. So I took that for granted, else we should have a |
I also think, having the partitioner come through explicitly via the contract is better, because, it would allow us to extend this whenever we need without having to worry about making too many changes. We know this is something we need to do anyways. Vinoth was already bringing up the prefix scan use-case :) |
I kinda visualise the trait Partitioner {
def shard(r: Request): Array[Byte]
def find(key: Array[Byte], replicaCount: Int): List[NodeInfo]
def find(key: Array[Byte]) = find(key, 1)
} @vinothkr 😱 I know you would do something like this. |
Picking this up! |
Any operation(get or put) on the cluster, should translate to a HandleOrForward operation.
based on the key, the node should be able to localize if it can handle the request or it should be able to forward the request an appropriate node.
@ashwanthkumar below is my stab at at the contract. Thoughts?
def handleOrForward(key: K): Node
PS: Is this a good way to write down issues.
The text was updated successfully, but these errors were encountered: