handler

package
v0.0.0-...-5c26a38 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core struct {
	TxHandler  sdk.TxHandler
	SrcManager sdk.ResourceManager
}

Core core parameters for handler Impl

type FuncBox

type FuncBox interface {
	OpenTxHandlerBox() map[TranCode]TxHandleFunc
	OpenSrcHandlerBox() map[TranCode]SrcHandleFunc
}

FuncBox handler functions with TranCode

type Handler

type Handler interface {
	HandleMessage(ctx context.Context, msg Message)
	RegisterEvent() error
	GetEvent() <-chan sdk.Event
	// RegisterTxHandleFunc(trancode TranCode, handleFunc TxHandleFunc) error
	// RegisterSrcHandlerFunc(trancode TranCode, handleFunc SrcHandleFunc) error
	FillHandlerFunc(box FuncBox) error
}

Handler client handler for transaction

type Impl

type Impl struct {
	// contains filtered or unexported fields
}

Impl implement for handler

func NewHandler

func NewHandler(core Core, param Params) *Impl

NewHandler return new Impl

func (*Impl) FillHandlerFunc

func (h *Impl) FillHandlerFunc(box FuncBox) error

FillHandlerFunc regisnter handler functions in the box

func (*Impl) GetEvent

func (h *Impl) GetEvent() <-chan sdk.Event

GetEvent return event channel

func (*Impl) HandleMessage

func (h *Impl) HandleMessage(ctx context.Context, msg Message)

HandleMessage handle message

func (*Impl) RegisterEvent

func (h *Impl) RegisterEvent(channel, ccName string, event string) error

RegisterEvent register fabric event, event messges will be boradcast throw channel h.events

type Message

type Message struct {
	// ...
	TranCode TranCode
	TranData []byte
	Result   chan<- Result
}

Message message for handler, result will be return throw channel Result

type Params

type Params struct {
	TxTimeout uint32 // Second
	PoolSize  uint32 // Concurrent handler size
}

Params handler params

type Result

type Result struct {
	RspCode  uint32
	RspData  []byte
	TranCode TranCode
	TxID     string
	Err      error
}

Result handle result

type SrcHandleFunc

type SrcHandleFunc func(ctx context.Context, msg Message, handler sdk.ResourceManager) Result

SrcHandleFunc resource management handle function

type TranCode

type TranCode string

TranCode transaction code

type TranType

type TranType int

TranType handler function type

const (
	TypeTxHandler TranType = iota
	TypeSrcHandler
)

handler func type

type TxHandleFunc

type TxHandleFunc func(ctx context.Context, msg Message, handler sdk.TxHandler) Result

TxHandleFunc transaction handle function

Jump to

Keyboard shortcuts

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