ing
This commit is contained in:
parent
eac00359db
commit
8c1c86f021
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user