cherryHandler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultQueueHash

func DefaultQueueHash(executor facade.IExecutor, queueNum int) int

Types

type Component

type Component struct {
	Options
	facade.Component
	// contains filtered or unexported fields
}

Component handler handlerComponent

func NewComponent

func NewComponent() *Component

func (*Component) Init

func (h *Component) Init()

func (*Component) Name

func (h *Component) Name() string

func (*Component) OnStop

func (h *Component) OnStop()

func (*Component) PostEvent

func (h *Component) PostEvent(event facade.IEvent)

PostEvent 发布事件

func (*Component) PostMessage

func (h *Component) PostMessage(session *cherrySession.Session, msg *cherryMessage.Message)

本地handler执行, remote用于远程rpc调用执行

func (*Component) Register

func (h *Component) Register(handlerGroup *HandlerGroup)

func (*Component) Register2Group

func (h *Component) Register2Group(handler ...facade.IHandler)

type EventExecutor

type EventExecutor struct {
	Event   facade.IEvent
	EventFn []facade.EventFn
}

func (*EventExecutor) Invoke

func (e *EventExecutor) Invoke()

func (*EventExecutor) String

func (e *EventExecutor) String() string

type FilterFn

type FilterFn func(session *cherrySession.Session, message *cherryMessage.Message) bool

type Handler

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

func (*Handler) AddAfterFilter

func (h *Handler) AddAfterFilter(afterFilters ...FilterFn)

func (*Handler) AddBeforeFilter

func (h *Handler) AddBeforeFilter(beforeFilters ...FilterFn)

func (*Handler) AddEvent

func (h *Handler) AddEvent(eventName string, fn facade.EventFn)

AddEvent

func (*Handler) AddLocal

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

func (*Handler) AddLocals

func (h *Handler) AddLocals(localFns ...interface{})

func (*Handler) AddOnClose

func (h *Handler) AddOnClose(listener ...cherrySession.SessionListener)

func (*Handler) AddOnCreate

func (h *Handler) AddOnCreate(listener ...cherrySession.SessionListener)

func (*Handler) AddRemote

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

func (*Handler) AddRemotes

func (h *Handler) AddRemotes(remoteFns ...interface{})

func (*Handler) Component

func (h *Handler) Component() IComponent

func (*Handler) Event

func (h *Handler) Event(name string) ([]facade.EventFn, bool)

func (*Handler) Events

func (h *Handler) Events() map[string][]facade.EventFn

func (*Handler) LocalHandler

func (h *Handler) LocalHandler(funcName string) (*facade.HandlerFn, bool)

func (*Handler) LocalHandlers

func (h *Handler) LocalHandlers() map[string]*facade.HandlerFn

func (*Handler) Name

func (h *Handler) Name() string

func (*Handler) OnAfterInit

func (h *Handler) OnAfterInit()

func (*Handler) OnInit

func (h *Handler) OnInit()

func (*Handler) OnPreInit

func (h *Handler) OnPreInit()

func (*Handler) OnStop

func (h *Handler) OnStop()

func (*Handler) PostEvent

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

func (*Handler) RemoteHandler

func (h *Handler) RemoteHandler(funcName string) (*facade.HandlerFn, bool)

func (*Handler) RemoteHandlers

func (h *Handler) RemoteHandlers() map[string]*facade.HandlerFn

func (*Handler) SetName

func (h *Handler) SetName(name string)

type HandlerGroup

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

func NewGroup

func NewGroup(queueNum, queueCap int) *HandlerGroup

func NewGroupWithHandler

func NewGroupWithHandler(handlers ...facade.IHandler) *HandlerGroup

func (*HandlerGroup) AddHandlers

func (h *HandlerGroup) AddHandlers(handlers ...facade.IHandler)

func (*HandlerGroup) SetQueueHash

func (h *HandlerGroup) SetQueueHash(fn QueueHash)

type IComponent

type IComponent interface {
	Register(handlerGroup *HandlerGroup)
	PostEvent(event facade.IEvent)
	PostMessage(session *cherrySession.Session, msg *cherryMessage.Message)
	AddBeforeFilter(beforeFilters ...FilterFn)
	AddAfterFilter(afterFilters ...FilterFn)
}

type MessageExecutor

type MessageExecutor struct {
	App           facade.IApplication
	Session       *cherrySession.Session
	Msg           *cherryMessage.Message
	HandlerFn     *facade.HandlerFn
	BeforeFilters []FilterFn
	AfterFilters  []FilterFn
}

func (*MessageExecutor) Invoke

func (m *MessageExecutor) Invoke()

func (*MessageExecutor) String

func (m *MessageExecutor) String() string

type Options

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

func (*Options) AddAfterFilter

func (c *Options) AddAfterFilter(afterFilters ...FilterFn)

func (*Options) AddBeforeFilter

func (c *Options) AddBeforeFilter(beforeFilters ...FilterFn)

func (*Options) PrintRouteLog

func (c *Options) PrintRouteLog(enable bool)

func (*Options) SetNameFn

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

type Queue

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

type QueueHash

type QueueHash func(executor facade.IExecutor, queueNum int) int

type SysRPCExecutor

type SysRPCExecutor struct {
	HandlerFn *facade.HandlerFn
}

func (*SysRPCExecutor) Invoke

func (s *SysRPCExecutor) Invoke()

func (*SysRPCExecutor) String

func (s *SysRPCExecutor) String() string

type UserRPCExecutor

type UserRPCExecutor struct {
	HandlerFn *facade.HandlerFn
}

func (*UserRPCExecutor) Invoke

func (u *UserRPCExecutor) Invoke()

func (*UserRPCExecutor) String

func (u *UserRPCExecutor) String() string

Jump to

Keyboard shortcuts

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