cherryHandler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultWorkerExecutor

func DefaultWorkerExecutor(handler cherryInterfaces.IHandler, worker *Worker)

DefaultWorkerExecutor

Types

type FilterFn

type FilterFn func(msg *UnhandledMessage) bool

type Handler

type Handler struct {
	cherryInterfaces.AppContext
	WorkerGroup
	// contains filtered or unexported fields
}

func (*Handler) AfterInit

func (h *Handler) AfterInit()

func (*Handler) GetEvent

func (h *Handler) GetEvent(name string) ([]cherryInterfaces.EventFn, bool)

func (*Handler) GetEvents

func (h *Handler) GetEvents() map[string][]cherryInterfaces.EventFn

func (*Handler) GetLocal

func (h *Handler) GetLocal(funcName string) (*cherryInterfaces.InvokeFn, bool)

func (*Handler) GetLocals

func (h *Handler) GetLocals() map[string]*cherryInterfaces.InvokeFn

func (*Handler) GetRemote

func (h *Handler) GetRemote(funcName string) (*cherryInterfaces.InvokeFn, bool)

func (*Handler) GetRemotes

func (h *Handler) GetRemotes() map[string]*cherryInterfaces.InvokeFn

func (*Handler) GetWorker

func (h *Handler) GetWorker(message interface{}) *Worker

func (*Handler) HandlerComponent

func (h *Handler) HandlerComponent() *HandlerComponent

func (*Handler) Init

func (h *Handler) Init()

func (*Handler) Name

func (h *Handler) Name() string

func (*Handler) PostEvent

func (h *Handler) PostEvent(e cherryInterfaces.IEvent)

func (*Handler) PreInit

func (h *Handler) PreInit()

func (*Handler) PutMessage

func (h *Handler) PutMessage(message interface{})

func (*Handler) RegisterEvent

func (h *Handler) RegisterEvent(eventName string, fn cherryInterfaces.EventFn)

RegisterEvent

func (*Handler) RegisterLocal

func (h *Handler) RegisterLocal(name string, fn interface{})

func (*Handler) RegisterLocals

func (h *Handler) RegisterLocals(sliceFn ...interface{})

func (*Handler) RegisterRemote

func (h *Handler) RegisterRemote(name string, fn interface{})

func (*Handler) RegisterRemotes

func (h *Handler) RegisterRemotes(sliceFn ...interface{})

func (*Handler) SetName

func (h *Handler) SetName(name string)

func (*Handler) Stop

func (h *Handler) Stop()

type HandlerComponent

type HandlerComponent struct {
	cherryInterfaces.BaseComponent // base component
	HandlerComponentOptions        // opts
	// contains filtered or unexported fields
}

handlerComponent Handler component

func NewComponent

func NewComponent() *HandlerComponent

func (*HandlerComponent) DoHandle

func (h *HandlerComponent) DoHandle(msg *UnhandledMessage)

func (*HandlerComponent) GetHandler

func (h *HandlerComponent) GetHandler(route *cherryRoute.Route) cherryInterfaces.IHandler

func (*HandlerComponent) Init

func (h *HandlerComponent) Init()

func (*HandlerComponent) Name

func (h *HandlerComponent) Name() string

func (*HandlerComponent) PostEvent

func (h *HandlerComponent) PostEvent(event cherryInterfaces.IEvent)

PostEvent 发布事件

func (*HandlerComponent) RegisterWithName

func (h *HandlerComponent) RegisterWithName(name string, handler cherryInterfaces.IHandler)

func (*HandlerComponent) Registers

func (h *HandlerComponent) Registers(handlers ...cherryInterfaces.IHandler)

func (*HandlerComponent) Stop

func (h *HandlerComponent) Stop()

type HandlerComponentOptions

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

func (*HandlerComponentOptions) AfterFilter

func (c *HandlerComponentOptions) AfterFilter(afterFilters ...FilterFn)

func (*HandlerComponentOptions) BeforeFilter

func (c *HandlerComponentOptions) BeforeFilter(beforeFilters ...FilterFn)

func (*HandlerComponentOptions) GetAfterFilter

func (c *HandlerComponentOptions) GetAfterFilter() []FilterFn

func (*HandlerComponentOptions) GetBeforeFilter

func (c *HandlerComponentOptions) GetBeforeFilter() []FilterFn

func (*HandlerComponentOptions) NodeRoute

func (*HandlerComponentOptions) NodeRoute(nodeType string, routeFunc cherryInterfaces.RouteFunction)

NodeRoute 结点路由规则 nodeType:结点类型,routeFunc 路由规则

func (*HandlerComponentOptions) SetNameFn

func (c *HandlerComponentOptions) SetNameFn(fn func(string) string)

type UnhandledMessage

type UnhandledMessage struct {
	Session cherryInterfaces.ISession
	Route   *cherryRoute.Route
	Msg     *cherryMessage.Message
}

type Worker

type Worker struct {
	Index       int              // index
	MessageChan chan interface{} // message chan
}

type WorkerExecuteFn

type WorkerExecuteFn func(handler cherryInterfaces.IHandler, worker *Worker)

type WorkerGroup

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

func (*WorkerGroup) SetQueueSize

func (w *WorkerGroup) SetQueueSize(size int)

func (*WorkerGroup) SetWorkerCRC32Hash

func (w *WorkerGroup) SetWorkerCRC32Hash(workerSize int)

func (*WorkerGroup) SetWorkerExecutor

func (w *WorkerGroup) SetWorkerExecutor(workerExecuteFn WorkerExecuteFn)

func (*WorkerGroup) SetWorkerHash

func (w *WorkerGroup) SetWorkerHash(workerSize int, hashFn WorkerHashFn)

func (*WorkerGroup) SetWorkerRandHash

func (w *WorkerGroup) SetWorkerRandHash(workerSize int)

func (*WorkerGroup) WorkerMap

func (w *WorkerGroup) WorkerMap() map[int]*Worker

type WorkerHashFn

type WorkerHashFn func(msg interface{}) int

Jump to

Keyboard shortcuts

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