handler

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

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, monitor monitoring.Monitor, 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL