Fail to Reflect Set During Conversion
This blog records the failure when trying to set the response value using reflect to provide an adaptor for wrapping the original PRC interceptor to the custom interceptor format defined by our tech products.
The difference between them is the custom interceptor moves the response from an argument to a response. This blog introduces the challenges encountered while designing an adaptor.
Signatures of Original RPC Interceptor And Custom Interceptor
// package rpc
// original RPC interceptor signature
type Interceptor func(ctx context.Context,
request, response interface{}, processor Processor) uint32
type Processor func(ctx context.Context, request, response interface{}) uint32
// package custom
// interceptor in the tech team
type CustomInterceptor interface {
Wrap(HandlerFn) HandlerFn
}
type HandlerFn func(ctx context.Context, req interface{}) (interface{}, error)