cherryHandler

package
v1.1.26 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultQueueHash

func DefaultQueueHash(executor IExecutor, queueNum int) int

Types

type Component

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

Component handler component

func NewComponent

func NewComponent(opts ...Option) *Component

func (*Component) AddAfterFilter added in v1.1.1

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

func (*Component) AddBeforeFilter added in v1.1.1

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

func (*Component) GetHandler added in v1.1.17

func (c *Component) GetHandler(route string) (*cherryMessage.Route, *HandlerGroup, facade.IHandler, bool)

func (*Component) Init

func (c *Component) Init()

func (*Component) Name

func (c *Component) Name() string

func (*Component) OnAfterInit added in v1.1.6

func (c *Component) OnAfterInit()

func (*Component) OnStop

func (c *Component) OnStop()

func (*Component) PostEvent

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

PostEvent 发布事件

func (*Component) ProcessLocal added in v1.1.17

func (c *Component) ProcessLocal(session *cherrySession.Session, msg *cherryMessage.Message)

func (*Component) ProcessRemote added in v1.1.17

func (c *Component) ProcessRemote(group *HandlerGroup, executor *ExecutorRemote)

func (*Component) Register

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

func (*Component) Register2Group

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

type ExecutorEvent added in v1.1.9

type ExecutorEvent struct {
	Event      facade.IEvent
	EventSlice []facade.EventFunc
}

func (*ExecutorEvent) Invoke added in v1.1.9

func (e *ExecutorEvent) Invoke()

func (*ExecutorEvent) String added in v1.1.9

func (e *ExecutorEvent) String() string

type ExecutorLocal added in v1.1.9

type ExecutorLocal struct {
	facade.IApplication
	Session      *cherrySession.Session
	Msg          *cherryMessage.Message
	HandlerFn    *facade.HandlerFn
	Ctx          context.Context
	AfterFilters []FilterFn
}

func (*ExecutorLocal) Invoke added in v1.1.9

func (m *ExecutorLocal) Invoke()

func (*ExecutorLocal) String added in v1.1.9

func (m *ExecutorLocal) String() string

type ExecutorRemote added in v1.1.9

type ExecutorRemote struct {
	facade.IApplication
	HandlerFn    *facade.HandlerFn
	RemotePacket *cherryProto.RemotePacket
	NatsMsg      *nats.Msg
}

func (*ExecutorRemote) Invoke added in v1.1.9

func (r *ExecutorRemote) Invoke()

func (*ExecutorRemote) String added in v1.1.9

func (r *ExecutorRemote) String() string

type FilterFn

type FilterFn func(ctx context.Context, 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.EventFunc)

func (*Handler) AddLocal

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

func (*Handler) AddLocals

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

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() *Component

func (*Handler) Event

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

func (*Handler) Events

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

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) Response added in v1.1.16

func (h *Handler) Response(ctx context.Context, session *cherrySession.Session, data interface{})

func (*Handler) ResponseCode added in v1.1.16

func (h *Handler) ResponseCode(ctx context.Context, session *cherrySession.Session, code int32)

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 IExecutor added in v1.1.5

type IExecutor interface {
	Invoke()
	String() string
}

type Option added in v1.1.1

type Option func(options *options)

func WithAfterFilter added in v1.1.1

func WithAfterFilter(afterFilters ...FilterFn) Option

func WithBeforeFilter added in v1.1.1

func WithBeforeFilter(beforeFilters ...FilterFn) Option

func WithNameFunc added in v1.1.1

func WithNameFunc(fn func(string) string) Option

func WithPrintRouteLog added in v1.1.1

func WithPrintRouteLog(enable bool) Option

type Queue

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

type QueueHash

type QueueHash func(executor IExecutor, queueNum int) int

type SessionHandler added in v1.1.20

type SessionHandler struct {
	Handler
}

func (*SessionHandler) Name added in v1.1.20

func (p *SessionHandler) Name() string

func (*SessionHandler) OnInit added in v1.1.20

func (p *SessionHandler) OnInit()

Jump to

Keyboard shortcuts

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