event

package
v1.4.3-beta1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultActorBus = NewActorEventBus()
	DefaultFeedBus  = NewFeedEventBus()
)
View Source
var (
	DefaultPublisher = actor.EmptyRootContext.Spawn(actor.PropsFromFunc(func(c actor.Context) {

	}).WithReceiverMiddleware(middleware.Logger))
)

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.

func Spawn added in v1.4.0

func Spawn(fn func(c actor.Context)) *actor.PID

func SpawnWithPool added in v1.4.0

func SpawnWithPool(fn func(c actor.Context)) *actor.PID

SpawnWithPool spawn a process with pool support

Types

type ActorEventBus added in v1.4.0

type ActorEventBus struct {
	Context *actor.RootContext
	// contains filtered or unexported fields
}

func (*ActorEventBus) Close added in v1.4.0

func (eb *ActorEventBus) Close() error

func (*ActorEventBus) CloseTopic added in v1.4.0

func (eb *ActorEventBus) CloseTopic(topic ct.TopicType) error

func (*ActorEventBus) HasCallback added in v1.4.0

func (eb *ActorEventBus) HasCallback(topic ct.TopicType) bool

func (*ActorEventBus) Publish added in v1.4.0

func (eb *ActorEventBus) Publish(topic ct.TopicType, msg interface{})

func (*ActorEventBus) PublishFrom added in v1.4.0

func (eb *ActorEventBus) PublishFrom(topic ct.TopicType, msg interface{}, publisher interface{}) error

func (*ActorEventBus) Subscribe added in v1.4.0

func (eb *ActorEventBus) Subscribe(topic ct.TopicType, fn interface{}) error

func (*ActorEventBus) Subscribers added in v1.4.0

func (eb *ActorEventBus) Subscribers(topic ct.TopicType, callback func(subscriber *actor.PID))

func (*ActorEventBus) Unsubscribe added in v1.4.0

func (eb *ActorEventBus) Unsubscribe(topic ct.TopicType, subscriber interface{}) error

type ActorPublisher added in v1.4.0

type ActorPublisher struct {
	Bus EventBus
	// contains filtered or unexported fields
}

func NewActorPublisher added in v1.4.0

func NewActorPublisher(publisher *actor.PID, bus ...EventBus) *ActorPublisher

NewActorPublisher with publisher and eventbus

func (*ActorPublisher) Publish added in v1.4.0

func (p *ActorPublisher) Publish(topic ct.TopicType, msg interface{}) error

Publish msg to topic

func (*ActorPublisher) PublishFuture added in v1.4.0

func (p *ActorPublisher) PublishFuture(topic ct.TopicType, msg interface{}, callback func(msg interface{}, err error))

func (*ActorPublisher) WithTimeout added in v1.4.0

func (p *ActorPublisher) WithTimeout(timeout time.Duration) *ActorPublisher

WithTimeout change default timeout

type ActorSubscriber added in v1.4.0

type ActorSubscriber struct {
	Bus EventBus
	// contains filtered or unexported fields
}

func NewActorSubscriber added in v1.4.0

func NewActorSubscriber(subscriber *actor.PID, bus ...EventBus) *ActorSubscriber

func (*ActorSubscriber) Subscribe added in v1.4.0

func (s *ActorSubscriber) Subscribe(topic ...ct.TopicType) error

Subscribe multiple topics by default handler

func (*ActorSubscriber) SubscribeOne added in v1.4.0

func (s *ActorSubscriber) SubscribeOne(topic ct.TopicType, subscriber *actor.PID) error

SubscribeOne subscribe topic->handler

func (*ActorSubscriber) Unsubscribe added in v1.4.0

func (s *ActorSubscriber) Unsubscribe(topic ct.TopicType) error

Unsubscribe by topic

func (*ActorSubscriber) UnsubscribeAll added in v1.4.0

func (s *ActorSubscriber) UnsubscribeAll() error

UnsubscribeAll topic

func (*ActorSubscriber) WithSubscribe added in v1.4.0

func (s *ActorSubscriber) WithSubscribe(subscriber *actor.PID) *ActorSubscriber

WithSubscribe set default handler

type EventBus

type EventBus interface {
	io.Closer
	// contains filtered or unexported methods
}

func GetEventBus

func GetEventBus(id string) EventBus

func NewActorEventBus added in v1.4.0

func NewActorEventBus() EventBus

type Feed added in v1.4.0

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

Feed implements one-to-many subscriptions where the carrier of events is a channel. Values sent to a Feed are delivered to all subscribed channels simultaneously.

Feeds can only be used with a single type. The type is determined by the first Send or Subscribe operation. Subsequent calls to these methods panic if the type does not match.

The zero value is ready to use.

func (*Feed) Send added in v1.4.0

func (f *Feed) Send(value interface{}) (nsent int)

Send delivers to all subscribed channels simultaneously. It returns the number of subscribers that the value was sent to.

func (*Feed) Subscribe added in v1.4.0

func (f *Feed) Subscribe(channel interface{}) FeedSubscription

Subscribe adds a channel to the feed. Future sends will be delivered on the channel until the subscription is canceled. All channels added must have the same element type.

The channel should have ample buffer space to avoid blocking other subscribers. Slow subscribers are not dropped.

type FeedEventBus added in v1.4.0

type FeedEventBus struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetFeedEventBus added in v1.4.0

func GetFeedEventBus(id string) *FeedEventBus

func NewFeedEventBus added in v1.4.0

func NewFeedEventBus() *FeedEventBus

func (*FeedEventBus) LookupFeed added in v1.4.0

func (eb *FeedEventBus) LookupFeed(topic ct.TopicType) *Feed

func (*FeedEventBus) Publish added in v1.4.0

func (eb *FeedEventBus) Publish(topic ct.TopicType, msg interface{})

func (*FeedEventBus) RpcSyncCall added in v1.4.0

func (eb *FeedEventBus) RpcSyncCall(msg *ct.EventRPCSyncCallMsg) interface{}

func (*FeedEventBus) RpcSyncCallWithTime added in v1.4.0

func (eb *FeedEventBus) RpcSyncCallWithTime(msg *ct.EventRPCSyncCallMsg, waitTime time.Duration) interface{}

func (*FeedEventBus) Subscribe added in v1.4.0

func (eb *FeedEventBus) Subscribe(topic ct.TopicType, ch interface{}) FeedSubscription

func (*FeedEventBus) Unsubscribe added in v1.4.0

func (eb *FeedEventBus) Unsubscribe(sub FeedSubscription)

type FeedSubscription added in v1.4.0

type FeedSubscription interface {
	Unsubscribe() // cancels sending of events, closing the error channel
}

FeedSubscription represents a stream of events. The carrier of the events is typically a channel, but isn't part of the interface.

Subscriptions can fail while established. Failures are reported through an error channel. It receives a value if there is an issue with the subscription (e.g. the network connection delivering the events has been closed). Only one value will ever be sent.

The Unsubscribe method cancels the sending of events. You must call Unsubscribe in all cases to ensure that resources related to the subscription are released. It can be called any number of times.

Jump to

Keyboard shortcuts

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