boulder icon indicating copy to clipboard operation
boulder copied to clipboard

Better compile-time type checking for gRPC server implementations

Open aarongable opened this issue 1 year ago • 0 comments

Replaced our embeds of foopb.UnimplementedFooServer with foopb.UnsafeFooServer. Per the grpc-go docs this reduces the "forwards compatibility" of our implementations, but that is only a concern for codebases that are implementing gRPC interfaces maintained by third parties, and which want to be able to update those third-party dependencies without updating their own implementations in lockstep. Because we update our protos and our implementations simultaneously, we can remove this safety net to replace runtime type checking with compile-time type checking.

However, that replacement is not enough, because we never pass our implementation objects to a function which asserts that they match a specific interface. So this PR also replaces our reflect-based unittests with idiomatic interface assertions. I do not view this as a perfect solution, as it relies on people implementing new gRPC servers to add this line, but it is no worse than the status quo which relied on people adding the "TestImplementation" test.

Fixes https://github.com/letsencrypt/boulder/issues/7497

aarongable avatar May 25 '24 00:05 aarongable