I was thinking about how we could specify this. Initially, a JSON file could work for us. We specify comma separated predicate prefixes with a group number.
Internally, these can be mapped to a map[string]int. We can reserve group no. 0 and group no. 1 for the cluster-wide and the default group respectively.
Then we can have the following APIs
getPredicates(group int) - To know which predicates to transfer to a new node which is part of the group.
getGroup(predicate string) - To know which group to send queries and mutations to.
We’d also need to have the modulos, where we say fp(predicate) % N + k = groupId, for some N and some k. I think for such cases JSON might not be ideal.
Given that we’d be using modulos, we won’t be able to get predicates given a group id. We can only go from predicate → group id, not the other way round.
Yes, we do have both the options. And we process the rules in the order they’re specified. So, if some predicate matches a condition listed higher, that’s the group id it would belong to.
Okay, if I understand correctly the N and k would be some sort of globals that he’d specify as part of the config?
A JSON format could still work here, instead of supplying an int, we just need a way for the user to specify that he wants the group to be calculated using modulos. Maybe he can use % .