Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct{}
Base implements a default component for Component.
func (*Base) AfterInit ¶
func (c *Base) AfterInit()
AfterInit was called after the component is initialized.
func (*Base) BeforeClose ¶ added in v1.1.14
func (c *Base) BeforeClose()
BeforeClose was called before the component to shutdown.
type CompWithOptions ¶ added in v1.0.0
CompWithOptions combines Component and options
type Component ¶
type Component interface { Init() AfterInit() BeforeClose() Close() }
Component is the interface that represent a component.
type Components ¶ added in v1.0.0
type Components struct {
// contains filtered or unexported fields
}
Components stores a slice of CompWithOptions
func (*Components) List ¶ added in v1.0.0
func (cs *Components) List() []CompWithOptions
List returns all components with it's options
func (*Components) Register ¶ added in v1.0.0
func (cs *Components) Register(c Component, options ...Option)
Register registers a component to hub with options
type Handler ¶
type Handler struct { Receiver reflect.Value // receiver of method Method reflect.Method // method stub Type reflect.Type // low-level type of method IsRawArg bool // whether the data need to serialize Code uint32 // Route compressed code }
Handler represents a message.Message's handler's meta information.
type Option ¶
type Option func(options *options)
Option used to customize handler
func WithDictionary ¶ added in v1.0.0
WithDictionary set dictionary for compressed route
func WithRenameHandlerFunc ¶ added in v1.0.0
WithRenameHandlerFunc override handler name by specific function such as: strings.ToUpper/strings.ToLower
func WithScheduleFunc ¶ added in v1.0.0
func WithScheduleFunc(fn scheduler.ScheduleFunc) Option
WithScheduleFunc set the func of the service schedule
type Service ¶
type Service struct { Name string // name of service Type reflect.Type // type of the receiver Receiver reflect.Value // receiver of methods for the service Handlers map[string]*Handler // registered methods ScheduleFunc scheduler.ScheduleFunc // tasks are pushed in and wait to be handled Options options // options }
Service implements a specific service, some of it's methods will be called when the correspond events is occurred.
func NewService ¶
NewService create a new Service from component
func (*Service) ExtractHandler ¶
ExtractHandler extract the set of methods from the receiver value which satisfy the following conditions: - exported method of exported type - two arguments, both of exported type - the first argument is *session.Session - the second argument is []byte or a pointer