Documentation ¶
Index ¶
- func Pcall(method *reflect.Method, args []reflect.Value) (rets []any, err error)
- type Handler
- type HandlerPool
- func (h *HandlerPool) GetHandle(targetName string, methodName string) *Handler
- func (h *HandlerPool) ProcessHandler(handler *Handler, receiver reflect.Value, args ...any) (methodType MethodType, rets []any, err error)
- func (h *HandlerPool) ProcessHandlerMessage(receiverName string, receiver reflect.Value, methodName string, args ...any) (methodType MethodType, rets []any, err error)
- func (h *HandlerPool) Register(name string, target any) (err error)
- type MethodType
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler struct { Type reflect.Type // low-level type of method Method *reflect.Method MethodType MethodType }
Handler represents a message.Message's handler's meta information.
type HandlerPool ¶
type HandlerPool struct {
// contains filtered or unexported fields
}
func NewHandlerPool ¶
func NewHandlerPool() *HandlerPool
func (*HandlerPool) GetHandle ¶ added in v1.0.2
func (h *HandlerPool) GetHandle(targetName string, methodName string) *Handler
func (*HandlerPool) ProcessHandler ¶ added in v1.0.2
func (h *HandlerPool) ProcessHandler(handler *Handler, receiver reflect.Value, args ...any) (methodType MethodType, rets []any, err error)
ProcessHandler handle方法反射调用
@receiver h @param handler @param receiver receiver的 reflect.Value @param args @return methodType 方法类型 @return rets @return err
func (*HandlerPool) ProcessHandlerMessage ¶
func (h *HandlerPool) ProcessHandlerMessage(receiverName string, receiver reflect.Value, methodName string, args ...any) (methodType MethodType, rets []any, err error)
ProcessHandlerMessage handle方法反射调用
@receiver h @param receiverName 缓存中注册的名字 @param receiverInstance receiver的实例 @param methodName 方法名 @param args 入参 @return methodType 方法类型 @return rets @return error
type MethodType ¶ added in v1.0.2
type MethodType int
MethodType 支持的方法签名类型
const ( MtNone MethodType = iota // 无 MtFullStyle // 完全形态签名:(receiver) func(eventType bcore.EventType, delta time.Duration) bcore.Result MtSimpleAction // 简单任务签名:(receiver) func() MtSimpleActionWithErr // 简单任务带错误返回的签名:(receiver) func() error MtSimpleActionWithBool // 简单任务带bool返回的签名:(receiver) func() bool MtSimpleActionWithResult // 简单任务带 bcore.Result 返回的签名:(receiver) func() bcore.Result )
type Option ¶
type Option func(options *options)
Option used to customize handler
func WithNameFunc ¶
WithNameFunc override handler name by specific function such as: strings.ToUpper/strings.ToLower
func WithTaskGoProvider ¶
func WithTaskGoProvider(taskGoProvider func(task func())) Option
WithTaskGoProvider 注册延迟动态绑定的异步任务派发线程
@param taskGoProvider @return Option
Click to show internal directories.
Click to hide internal directories.