Services in a single proto file register encoders that are not in their service
Closed this issue · 2 comments
staceytay commented
When defining multiple services in a proto file, for example
service SSOService {
// ORION:URL: OPTIONS/POST /ssoservice/login/
rpc Login (LoginRequest) returns (LoginResponse) {}
}
service SSOServiceInternal {
// ORION:URL: GET /ssoservice-internal/backend-token/
rpc GetBackendToken (GetBackendTokenRequest) returns (GetBackendTokenResponse) {}
}
will result in sso.proto.orion.pb.go
having
func RegisterSSOServiceOrionServer(srv orion.ServiceFactory, orionServer orion.Server) {
orionServer.RegisterService(&_SSOService_serviceDesc, srv)
RegisterSSOServiceLoginEncoder(orionServer, nil)
RegisterSSOServiceInternalGetBackendTokenEncoder(orionServer, nil)
}
func RegisterSSOServiceInternalOrionServer(srv orion.ServiceFactory, orionServer orion.Server) {
orionServer.RegisterService(&_SSOServiceInternal_serviceDesc, srv)
RegisterSSOServiceLoginEncoder(orionServer, nil)
RegisterSSOServiceInternalGetBackendTokenEncoder(orionServer, nil)
}
I find this is unexpected, I'm thinking that the expected results should be
func RegisterSSOServiceOrionServer(srv orion.ServiceFactory, orionServer orion.Server) {
orionServer.RegisterService(&_SSOService_serviceDesc, srv)
RegisterSSOServiceLoginEncoder(orionServer, nil)
}
func RegisterSSOServiceInternalOrionServer(srv orion.ServiceFactory, orionServer orion.Server) {
orionServer.RegisterService(&_SSOServiceInternal_serviceDesc, srv)
RegisterSSOServiceInternalGetBackendTokenEncoder(orionServer, nil)
}
ankurs commented
Thanks for finding this out, this is a bug, will fix it
staceytay commented
Workaround at present is to make sure that all custom encoders are registered after registering the server to prevent previously registered custom encoders from being overwritten