cherryHandler

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "handler_component"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

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

Component handler component

func NewComponent

func NewComponent(opts ...Option) *Component

func (*Component) AddAfterFilter

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

func (*Component) AddBeforeFilter

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

func (*Component) GetHandler

func (c *Component) GetHandler(handlerName string) (*HandlerGroup, cfacade.IHandler, bool)

func (*Component) Init

func (c *Component) Init()

func (*Component) Name

func (c *Component) Name() string

func (*Component) OnAfterInit

func (c *Component) OnAfterInit()

func (*Component) OnStop

func (c *Component) OnStop()

func (*Component) PostEvent

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

PostEvent 发布事件

func (*Component) ProcessLocal

func (c *Component) ProcessLocal(session *csession.Session, msg *cmsg.Message)

func (*Component) ProcessRemote

func (c *Component) ProcessRemote(route string, data []byte, natsMsg *nats.Msg) int32

func (*Component) Register

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

func (*Component) Register2Group

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

type Executor

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

func (*Executor) Index

func (p *Executor) Index() int

func (*Executor) SetIndex

func (p *Executor) SetIndex(index int)

type ExecutorEvent

type ExecutorEvent struct {
	Executor
	// contains filtered or unexported fields
}

func (*ExecutorEvent) Event

func (p *ExecutorEvent) Event() cfacade.IEvent

func (*ExecutorEvent) Invoke

func (p *ExecutorEvent) Invoke()

func (*ExecutorEvent) QueueHash

func (p *ExecutorEvent) QueueHash(queueNum int) int

type ExecutorLocal

type ExecutorLocal struct {
	Executor
	cfacade.IApplication
	// contains filtered or unexported fields
}

func (*ExecutorLocal) Context

func (p *ExecutorLocal) Context() context.Context

func (*ExecutorLocal) Invoke

func (p *ExecutorLocal) Invoke()

func (*ExecutorLocal) Message

func (p *ExecutorLocal) Message() *cmsg.Message

func (*ExecutorLocal) QueueHash

func (p *ExecutorLocal) QueueHash(queueNum int) int

func (*ExecutorLocal) Session

func (p *ExecutorLocal) Session() *csession.Session

type ExecutorRemote

type ExecutorRemote struct {
	Executor
	cfacade.IApplication
	// contains filtered or unexported fields
}

func (*ExecutorRemote) Data

func (p *ExecutorRemote) Data() []byte

func (*ExecutorRemote) Invoke

func (p *ExecutorRemote) Invoke()

func (*ExecutorRemote) QueueHash

func (p *ExecutorRemote) QueueHash(queueNum int) int

func (*ExecutorRemote) Route

func (p *ExecutorRemote) Route() *cmessage.Route

func (*ExecutorRemote) UnmarshalData

func (p *ExecutorRemote) UnmarshalData() (interface{}, error)

type FilterFn

type FilterFn func(ctx context.Context, session *csession.Session, message *cmsg.Message) bool

type Handler

type Handler struct {
	cfacade.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 cfacade.EventFn, hashFn ...cfacade.QueueHashFn)

func (*Handler) AddLocal

func (h *Handler) AddLocal(name string, fn interface{}, hashFn ...cfacade.QueueHashFn)

func (*Handler) AddLocals

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

func (*Handler) AddRemote

func (h *Handler) AddRemote(name string, fn interface{}, hashFn ...cfacade.QueueHashFn)

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) (*cfacade.EventInfo, bool)

func (*Handler) Events

func (h *Handler) Events() map[string]*cfacade.EventInfo

func (*Handler) LocalHandler

func (h *Handler) LocalHandler(funcName string) (*cfacade.MethodInfo, bool)

func (*Handler) LocalHandlers

func (h *Handler) LocalHandlers() map[string]*cfacade.MethodInfo

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 cfacade.IEvent)

func (*Handler) RemoteHandler

func (h *Handler) RemoteHandler(funcName string) (*cfacade.MethodInfo, bool)

func (*Handler) RemoteHandlers

func (h *Handler) RemoteHandlers() map[string]*cfacade.MethodInfo

func (*Handler) Response

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

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 ...cfacade.IHandler) *HandlerGroup

func (*HandlerGroup) AddHandlers

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

func (*HandlerGroup) InQueue

func (h *HandlerGroup) InQueue(hashFn cfacade.QueueHashFn, executor cfacade.IExecutor)

func (*HandlerGroup) SetQueueHash

func (h *HandlerGroup) SetQueueHash(fn cfacade.QueueHashFn)

type Option

type Option func(options *options)

func WithAfterFilter

func WithAfterFilter(afterFilters ...FilterFn) Option

func WithBeforeFilter

func WithBeforeFilter(beforeFilters ...FilterFn) Option

func WithNameFunc

func WithNameFunc(fn func(string) string) Option

type Queue

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

Jump to

Keyboard shortcuts

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