rpc/server/servlet_handlers.go
crusader e3a873a067 ing
2018-03-22 20:51:20 +09:00

45 lines
1.2 KiB
Go

package server
import (
"git.loafle.net/commons_go/logging"
"git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/protocol"
"git.loafle.net/commons_go/rpc/registry"
)
type ServletHandlers struct {
rpc.ServletHandlers
RPCInvoker registry.RPCInvoker
}
func (sh *ServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec protocol.RegistryCodec) (result interface{}, err error) {
// if !sh.RPCInvoker.HasMethod(requestCodec.Method()) {
// return nil, fmt.Errorf("RPC Servlet Handler: Method[%s] is not exist", requestCodec.Method())
// }
result, err = sh.RPCInvoker.Invoke(requestCodec)
// if nil != err {
// params, pErr := requestCodec.Params()
// if nil != pErr {
// logging.Logger().Errorf("RPC Servlet Handler: Read Param of Method[%s] returns error %v", requestCodec.Method(), pErr)
// }
// logging.Logger().Errorf("RPC Servlet Handler: Method[%s] params[%v] returns error %v", requestCodec.Method(), params, err)
// }
return
}
func (sh *ServletHandlers) GetRPCInvoker() registry.RPCInvoker {
return sh.RPCInvoker
}
func (sh *ServletHandlers) Validate() {
sh.ServletHandlers.Validate()
if nil == sh.RPCInvoker {
logging.Logger().Panicf("RPC Servlet Handler: RPC Invoker must be specified")
}
}