event

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(pattern, name string) (matched bool)

Match - finds whether the text matches/satisfies the pattern string. supports '*' and '?' wildcards in the pattern string. unlike path.Match(), considers a path as a flat name space while matching the pattern. The difference is illustrated in the example here https://play.golang.org/p/Ega9qgD4Qz .

func MatchSimple

func MatchSimple(pattern, name string) bool

MatchSimple - finds whether the text matches/satisfies the pattern string. supports only '*' wildcard in the pattern. considers a file system path as a flat name space.

Types

type DefaultEventBus

type DefaultEventBus struct {
	// contains filtered or unexported fields
}

DefaultEventBus - box for handlers and callbacks.

func (*DefaultEventBus) HasCallback

func (eb *DefaultEventBus) HasCallback(topic string) bool

HasCallback returns true if exists any callback subscribed to the topic.

func (*DefaultEventBus) Publish

func (eb *DefaultEventBus) Publish(topic string, args ...interface{})

Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.

func (*DefaultEventBus) Subscribe

func (eb *DefaultEventBus) Subscribe(topic string, fn interface{}) error

Subscribe subscribes to a topic. Returns error if `fn` is not a function.

func (*DefaultEventBus) SubscribeAsync

func (eb *DefaultEventBus) SubscribeAsync(topic string, fn interface{}, transactional bool) error

SubscribeAsync subscribes to a topic with an asynchronous callback Transactional determines whether subsequent callbacks for a topic are run serially (true) or concurrently (false) Returns error if `fn` is not a function.

func (*DefaultEventBus) SubscribeOnce

func (eb *DefaultEventBus) SubscribeOnce(topic string, fn interface{}) error

SubscribeOnce subscribes to a topic once. Handler will be removed after executing. Returns error if `fn` is not a function.

func (*DefaultEventBus) SubscribeOnceAsync

func (eb *DefaultEventBus) SubscribeOnceAsync(topic string, fn interface{}) error

SubscribeOnceAsync subscribes to a topic once with an asynchronous callback Handler will be removed after executing. Returns error if `fn` is not a function.

func (*DefaultEventBus) Unsubscribe

func (eb *DefaultEventBus) Unsubscribe(topic string, handler interface{}) error

Unsubscribe removes callback defined for a topic. Returns error if there are no callbacks subscribed to the topic.

func (*DefaultEventBus) WaitAsync

func (eb *DefaultEventBus) WaitAsync()

WaitAsync waits for all async callbacks to complete

type EventBus

type EventBus interface {
	// contains filtered or unexported methods
}

func GetEventBus

func GetEventBus(id string) EventBus

func New

func New() EventBus

New returns new DefaultEventBus with empty handlers.

func SimpleEventBus

func SimpleEventBus() EventBus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL