Raft: Implement an abstraction to interact with the Raft cluster
Dragonboat library has some interfaces to interact with a Raft cluster such as SyncRead, SyncPropose, Propose, etc. Each of them is used for a particular purpose. They have different semantic as well as performance implications.
As the library is flexible and generic, those interfaces don't enforce data schema, application error codes, retrying, logging, etc. In Gitaly, we would like to have a more restrictive method to interact with the cluster. Otherwise, they might become a foot gun leading to some serious consequences.
It makes a lot of sense to implement an abstraction with some batteries included. All interactions of the cluster must go through this abstraction layer. This issue tracks this work. It targets the two synchronous operations: SyncRead
and SyncWrite
. In the future, we need to support more sophisticated asynchronous methods such as Propose
. That interface allows hooking into different stages of the request.
I expect the abstraction looks something like follows:
requester := NewRequester[*gitalypb.RegisterStorageRequest, *gitalypb.RegisterStorageResponse](
cluster.nodes[1].nodeHost, 1, testhelper.NewLogger(t), requestOption{
timeout: 1 * time.Second,
},
)
result, response, err := requester.SyncWrite(ctx, &gitalypb.RegisterStorageRequest{StorageName: "storage-2"})