Documentation ¶
Index ¶
- Constants
- func FormatSubscriptionID(id int64) string
- func MakeSubscriptionID(fun interface{}) int64
- func ParseSubscriptionID(id string) (int64, error)
- type DispatchService
- func (s *DispatchService) Publish(event Event)
- func (s *DispatchService) Stop()
- func (s *DispatchService) Subscribe(eventName string, subscriptionID int64, handler Handler)
- func (s *DispatchService) SubscribeSync(eventName string, subscriptionID int64, handler Handler)
- func (s *DispatchService) Unsubscribe(eventName string, subscriptionID int64)
- type Event
- type Handler
Constants ¶
View Source
const DefaultSubscriptionID = -1
Variables ¶
This section is empty.
Functions ¶
func FormatSubscriptionID ¶
func MakeSubscriptionID ¶
func MakeSubscriptionID(fun interface{}) int64
MakeSubscriptionID creates subscription ID from a function
func ParseSubscriptionID ¶
Types ¶
type DispatchService ¶
type DispatchService struct {
// contains filtered or unexported fields
}
func NewDispatchService ¶
func NewDispatchService(logger logger.Logger) *DispatchService
func (*DispatchService) Publish ¶
func (s *DispatchService) Publish(event Event)
func (*DispatchService) Stop ¶
func (s *DispatchService) Stop()
func (*DispatchService) Subscribe ¶
func (s *DispatchService) Subscribe(eventName string, subscriptionID int64, handler Handler)
Subscribe attaches handler to listen for events with eventName. Do not rely on the order of handlers, they may be shuffled.
func (*DispatchService) SubscribeSync ¶
func (s *DispatchService) SubscribeSync(eventName string, subscriptionID int64, handler Handler)
SubscribeSync attaches handler to listen for events with eventName. Sync handlers are dispatched first, the events are ordered. Do not rely on the order of handlers, they may be shuffled.
func (*DispatchService) Unsubscribe ¶
func (s *DispatchService) Unsubscribe(eventName string, subscriptionID int64)
Click to show internal directories.
Click to hide internal directories.