2019-06-03 18:44:43 +01:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
2021-10-27 01:00:27 +03:00
|
|
|
"go.unistack.org/micro/v3/server"
|
2019-06-03 18:44:43 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type rpcHandler struct {
|
2024-12-27 01:25:15 +03:00
|
|
|
opts server.HandlerOptions
|
|
|
|
handler interface{}
|
|
|
|
name string
|
2019-06-03 18:44:43 +01:00
|
|
|
}
|
|
|
|
|
2021-04-26 19:04:27 +03:00
|
|
|
func newRPCHandler(handler interface{}, opts ...server.HandlerOption) server.Handler {
|
2020-11-03 02:15:31 +03:00
|
|
|
options := server.NewHandlerOptions(opts...)
|
2019-06-03 18:44:43 +01:00
|
|
|
|
|
|
|
hdlr := reflect.ValueOf(handler)
|
|
|
|
name := reflect.Indirect(hdlr).Type().Name()
|
|
|
|
|
|
|
|
return &rpcHandler{
|
2024-12-27 01:25:15 +03:00
|
|
|
name: name,
|
|
|
|
handler: handler,
|
|
|
|
opts: options,
|
2019-06-03 18:44:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcHandler) Name() string {
|
|
|
|
return r.name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcHandler) Handler() interface{} {
|
|
|
|
return r.handler
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *rpcHandler) Options() server.HandlerOptions {
|
|
|
|
return r.opts
|
|
|
|
}
|