Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultPanicHadler = new(PanicHandler)
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
Name string
// contains filtered or unexported fields
}
func NewChain ¶
func NewChain(name string, paincChain RpcHandler, errChange ErrorChangeFun, handlers ...RpcHandler) *Chain
func (*Chain) Execute ¶
func (this *Chain) Execute(ctx context.Context, request *RpcRequest, response *RpcResponse) error
type ErrorChangeFun ¶
type ErrorChangeFun func(ctx context.Context, err error, request *RpcRequest, response *RpcResponse) error
type PanicHandler ¶
type PanicHandler int
func (PanicHandler) Execute ¶
func (PanicHandler) Execute(request *RpcRequest, response *RpcResponse) error
this handler is process ,panic in last of chain
type RpcHandler ¶
type RpcHandler interface {
Execute(req *RpcRequest, resp *RpcResponse) error
}
type RpcRequest ¶
type RpcRequest struct {
MessageId string `json:"message_id"`
Arg interface{} `json:"arg"`
Ctx context.Context `json:"-"`
Cancel context.CancelFunc `json:"-"`
}
func (*RpcRequest) GetArg ¶
func (this *RpcRequest) GetArg() interface{}
func (*RpcRequest) GetContext ¶
func (this *RpcRequest) GetContext() context.Context
func (*RpcRequest) GetMessageID ¶
func (this *RpcRequest) GetMessageID() string
func (*RpcRequest) SetContext ¶
func (this *RpcRequest) SetContext(ctx context.Context)
type RpcResponse ¶
type RpcResponse struct {
MessageId string `json:"message_id"`
Error string `json:"error"`
Result interface{} `json:"result"`
Status int64 `json:"status"`
}
func NewRpcResponse ¶
func NewRpcResponse(msgId string) *RpcResponse
Click to show internal directories.
Click to hide internal directories.