From 8c1c86f021a676faf814a99ac599e5d78259e5e7 Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 9 Nov 2017 17:46:44 +0900 Subject: [PATCH] ing --- gateway/handle.go | 5 +++-- gateway/server_handler.go | 4 +++- gateway/server_handlers.go | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gateway/handle.go b/gateway/handle.go index 6ec4390..ca2d4ae 100644 --- a/gateway/handle.go +++ b/gateway/handle.go @@ -1,18 +1,19 @@ package gateway import ( + "context" "io" "git.loafle.net/commons_go/rpc" "git.loafle.net/commons_go/rpc/protocol" ) -func Handle(sh ServerHandler, codec protocol.ServerCodec, r io.Reader, w io.Writer) error { +func Handle(ctx context.Context, sh ServerHandler, codec protocol.ServerCodec, r io.Reader, w io.Writer) error { return rpc.Handle(sh, codec, r, w, func(codecReq protocol.ServerCodecRequest) (result interface{}, err error) { var params []string if params, err = codecReq.Params(); nil != err { return nil, err } - return sh.Invoke(codecReq.Method(), params) + return sh.Invoke(ctx, codecReq.Method(), params) }) } diff --git a/gateway/server_handler.go b/gateway/server_handler.go index 88178f3..1bf118f 100644 --- a/gateway/server_handler.go +++ b/gateway/server_handler.go @@ -1,11 +1,13 @@ package gateway import ( + "context" + "git.loafle.net/commons_go/rpc" ) type ServerHandler interface { rpc.ServerHandler - Invoke(method string, params []string) (result interface{}, err error) + Invoke(ctx context.Context, method string, params []string) (result interface{}, err error) } diff --git a/gateway/server_handlers.go b/gateway/server_handlers.go index 7f822f4..fd8b9a0 100644 --- a/gateway/server_handlers.go +++ b/gateway/server_handlers.go @@ -1,6 +1,7 @@ package gateway import ( + "context" "errors" "git.loafle.net/commons_go/rpc" @@ -10,7 +11,7 @@ type ServerHandlers struct { rpc.ServerHandlers } -func (sh *ServerHandlers) Invoke(method string, params []string) (result interface{}, err error) { +func (sh *ServerHandlers) Invoke(ctx context.Context, method string, params []string) (result interface{}, err error) { return nil, errors.New("Server: Handler method[Invoke] of Server is not implement") }