chain

package
v0.0.0-...-a36dcc1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 7 Imported by: 0

README

介绍

将执行具柄串联执行,用于任务初始定义串行执行,记录单个任务处理状态,统一管理。

Documentation

Index

Constants

View Source
const (
	PROCESS_STATUS_UNDO = iota
	PROCESS_STATUS_DOING
	PROCESS_STATUS_OK
	PROCESS_STATUS_FAIL
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrencyHandlers

type ConcurrencyHandlers struct {
	Concurrency bool
	Handlers    Handlers
}

func NewConcurrencyHandlers

func NewConcurrencyHandlers(concurrency bool, handlers Handlers) *ConcurrencyHandlers

func (*ConcurrencyHandlers) FormatCost

func (m *ConcurrencyHandlers) FormatCost() (str string)

func (*ConcurrencyHandlers) RunCtxHandler

func (m *ConcurrencyHandlers) RunCtxHandler(ctx ICtx) (err error)

func (*ConcurrencyHandlers) RunHandler

func (m *ConcurrencyHandlers) RunHandler() (err error)

type HandleCtxFunc

type HandleCtxFunc func(ctx ICtx) error

type HandleFunc

type HandleFunc func() error

type Handler

type Handler struct {
	IsPass       bool
	Name         string
	Cost         int64
	Handle       HandleFunc
	CtxHandle    HandleCtxFunc
	ReflectValue reflect.Value
	Status       int
}

func NewCtxHandler

func NewCtxHandler(isPass bool, name string, funcHandle HandleCtxFunc) Handler

func NewHandler

func NewHandler(isPass bool, name string, funcHandle HandleFunc) Handler

func NewReflectHandler

func NewReflectHandler(isPass bool, name string, reflectValue reflect.Value) Handler

type Handlers

type Handlers []Handler

func (*Handlers) AddHandler

func (m *Handlers) AddHandler(handler ...Handler)

func (*Handlers) ConcurrencyRunCtxHandler

func (m *Handlers) ConcurrencyRunCtxHandler(ctx ICtx) (err error)

func (*Handlers) ConcurrencyRunHandler

func (m *Handlers) ConcurrencyRunHandler() (err error)

func (*Handlers) FormatCost

func (m *Handlers) FormatCost() (str string)

func (*Handlers) FormatMaxCost

func (m *Handlers) FormatMaxCost() (str string)

func (Handlers) Len

func (s Handlers) Len() int

func (Handlers) Less

func (s Handlers) Less(i, j int) bool

func (*Handlers) RunCtxHandler

func (m *Handlers) RunCtxHandler(ctx ICtx) (err error)

func (*Handlers) RunHandler

func (m *Handlers) RunHandler() (err error)

func (*Handlers) RunReflectValueCall

func (m *Handlers) RunReflectValueCall() (err error)

func (Handlers) Swap

func (s Handlers) Swap(i, j int)

type ICtx

type ICtx interface {
	ValidateData() (err error)
}

type IParam

type IParam interface {
	ValidateData() bool
}

type IProcessor

type IProcessor interface {
	Process(input IParam) (err error, output IParam)
}
type Link struct {
	Head   *LinkItem
	Tail   *LinkItem
	Length int
}
func InitLink(head *LinkItem) (link *Link)

func (*Link) CheckSameName

func (l *Link) CheckSameName() (err error)

func (*Link) FormatCost

func (l *Link) FormatCost() (str string)

func (*Link) GetAllProcessorCost

func (l *Link) GetAllProcessorCost() (mapCost map[string]int64)

func (*Link) Handle

func (l *Link) Handle(input IParam) (err error)

func (*Link) HandleMap

func (l *Link) HandleMap(input map[string]interface{}) (err error)

func (*Link) HandleRpc

func (l *Link) HandleRpc(input []byte) (err error)

func (*Link) SetNextItem

func (link *Link) SetNextItem(linkItem *LinkItem)

type LinkItem

type LinkItem struct {
	IsPass    bool
	Id        int
	Name      string
	Cost      int64
	Processor IProcessor
	Status    int
	Next      *LinkItem
}

ctx->ctx->ctx

func NewLinkItem

func NewLinkItem(isPass bool, name string, processor IProcessor) (linkItem *LinkItem)

func (*LinkItem) SetNext

func (item *LinkItem) SetNext(linkItem *LinkItem)

Jump to

Keyboard shortcuts

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