Add a generic RPC that calls a json in, json out ruby method
This is an idea on how to make it easier for developers outside the Gitaly team to build new Git-based features. Once the migration is done, all Git features will have to be implemented in Gitaly. Our current process is quite involved and requires knowledge of Protobuf, gRPC and Go in addition to Ruby.
Git features run the fastest if they involve just one Gitaly call. So to build interesting new Git features in GitLab, we want to make it easy to add high-level Gitaly calls that use Rugged inside gitaly-ruby. If you need to be a Gitaly expert to add a Gitaly call it becomes a lot harder to ship new features.
What if we create a generic RPC that allows us to call a unary method in gitaly-ruby.
service GenericRubyService {
rpc GenericRubyUnaryCall(GenericRubyUnaryCallRequest) returns (GenericRubyUnaryCallResponse) {}
}
message GenericRubyUnaryCallRequest {
Repository repository = 1;
string call_name = 2;
// JSON data decoded by ruby
bytes request = 3;
}
message GenericRubyUnaryCallResponse {
bytes response = 1;
}
Then in gitaly-ruby we'd have a hash that maps call names to objects, and the objects have a perform
method that takes a repository and a Ruby hash.
Then a developer adding a Git feature would add a class in gitaly-ruby, add their class to the 'call name' -> 'object' map, and be able to call it from gitlab-ce.
We can create metrics per 'call name' to see how these things behave. If something has special needs (stream responses, a Go implementation) we can create a custom RPC later.
This is just a sketch, I hope it's not too specific. Came up after discussion with @DouweM .