Documentation ¶
Overview ¶
Package basic provides a basic events PubSub implementation.
Example ¶
package main import ( "go.thethings.network/lorawan-stack/v3/pkg/events" "go.thethings.network/lorawan-stack/v3/pkg/events/basic" ) func main() { basicPubSub := basic.NewPubSub() // Replace the default pubsub so that we will now publish to this pub sub by default. events.SetDefaultPubSub(basicPubSub) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
PubSub is a basic event PubSub implementation.
func (*PubSub) AddSubscription ¶
func (e *PubSub) AddSubscription(s events.Subscription)
AddSubscription adds an event subscription to the PubSub. The exact same subscription must be used in RemoveSubscription.
func (*PubSub) RemoveSubscription ¶
func (e *PubSub) RemoveSubscription(s events.Subscription)
RemoveSubscription removes an event subscription to the PubSub. This method expects the exact same subscription that was previously used in AddSubscription.
func (*PubSub) Subscribe ¶
func (e *PubSub) Subscribe( ctx context.Context, names []string, identifiers []*ttnpb.EntityIdentifiers, hdl events.Handler, ) error
Subscribe starts a subscription for events that match name and identifiers. The subscription lasts until the context is canceled. The handler will be notified of matching events and must not block.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is a basic implementation of a PubSub subscription.
func NewSubscription ¶
func NewSubscription( ctx context.Context, names []string, identifiers []*ttnpb.EntityIdentifiers, hdl events.Handler, ) (*Subscription, error)
NewSubscription creates a new basic PubSub subscription.
func (*Subscription) Match ¶
func (s *Subscription) Match(evt events.Event) bool
Match returns whether the event matches the subscription.
func (*Subscription) Notify ¶
func (s *Subscription) Notify(evt events.Event)
Notify notifies the subscription of a new matching event.