Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher binds functions to be called indirectly by unrelated code.
func FromPlugins ¶
func FromPlugins(m *plugin.Manager) (*Dispatcher, error)
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
NewDispatcher returns an event dispatcher, ready for use.
func NewDispatcherLimit ¶
func NewDispatcherLimit(limit int) *Dispatcher
NewDispatcherLimit returns an event dispatcher with a buffer size of limit.
func (*Dispatcher) Bind ¶
func (d *Dispatcher) Bind(name string, handler Handler)
Bind adds the given handler to the list of handlersIndex for the event.
func (*Dispatcher) Emit ¶
func (d *Dispatcher) Emit(name string, data map[string]interface{})
Emit will call bound handlersIndex for the given in event.
This method does not block unless the underlying channel becomes full. The map received by this method is not copied; avoid writing to it once it has been passed into this method.
func (*Dispatcher) Loop ¶
func (d *Dispatcher) Loop()
Loop emits events in an infinite loop until the dispatcher is stopped.
If the Dispatcher is not running when Loop is called, it will be started. This method should be called in a separate goroutine. More than one worker can be started by calling this method multiple times in separate goroutines.
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop signals to the dispatcher to stop emitting events.
All workers started with Loop will stop processing without draining the pending events.
func (*Dispatcher) Unbind ¶
func (d *Dispatcher) Unbind(name string, handler Handler)
Unbind removes the given handler from the list of handlersIndex for the event.