Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHandlerID ¶
GetHandlerID calculate handler func's address as id
Types ¶
type Interface ¶
type Interface interface { // Register register new handler for topic // // Args: // * topic: specific the topic that will trigger the handler // * handler: the func that used to process event // // handler will be invoked when eventengine received an event in specific topic. // // you can register same handler with different topic. // if you register same handler with same topic, // only one handler will be accepted. Register(topic types.EventTopic, handler Handler) // UnRegister remove handler for topic // // if one handler register in different topic, // only the handler in specific topic will be removed. UnRegister(topic types.EventTopic, handler Handler) // Publish publish new event Publish(ctx context.Context, evt *types.Event) }
type OptFunc ¶
type OptFunc func(*eventStoreManagerOpt) error
OptFunc options for EventEngine
func WithLogger ¶
func WithLogger(logger *gutils.LoggerType) OptFunc
WithLogger set event store's logger
default to gutils' internal logger
func WithSuppressPanic ¶
WithSuppressPanic set whether suppress event handler's panic
default to false
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type event driven engine
Usage ¶
you -> produce event -> trigger multiply handlers
- create an engine by `NewEventEngine`
- register handlers with specified event type by `engine.Register`
- produce event to trigger handlers by `engine.Publish`
func (*Type) Register ¶
func (e *Type) Register(topic types.EventTopic, handler Handler)
Register register handler
func (*Type) UnRegister ¶
func (e *Type) UnRegister(topic types.EventTopic, handler Handler)
UnRegister unregister handler
Click to show internal directories.
Click to hide internal directories.