From d3b26b13baee97ce92f82cdc4d6cbb93e7948918 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "rpc: more accurate checking of handler method signatures (#27287)" This reverts commit b91df06aa1e9bf6c5d8735c6dc4fa47769521e52. --- rpc/service.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rpc/service.go b/rpc/service.go index 8485cab3aa..cfdfba023a 100644 --- a/rpc/service.go +++ b/rpc/service.go @@ -214,8 +214,19 @@ func (c *callback) call(ctx context.Context, method string, args []reflect.Value return results[0].Interface(), nil } +// Is t context.Context or *context.Context? +func isContextType(t reflect.Type) bool { + for t.Kind() == reflect.Ptr { + t = t.Elem() + } + return t == contextType +} + // Does t satisfy the error interface? func isErrorType(t reflect.Type) bool { + for t.Kind() == reflect.Ptr { + t = t.Elem() + } return t.Implements(errorType) } @@ -234,7 +245,7 @@ func isPubSub(methodType reflect.Type) bool { if methodType.NumIn() < 2 || methodType.NumOut() != 2 { return false } - return methodType.In(1) == contextType && + return isContextType(methodType.In(1)) && isSubscriptionType(methodType.Out(0)) && isErrorType(methodType.Out(1)) }