Documentation ¶
Overview ¶
Package cloud implements an events.PubSub implementation that uses Go Cloud PubSub.
Example ¶
package main import ( "context" "go.thethings.network/lorawan-stack/v3/pkg/events" "go.thethings.network/lorawan-stack/v3/pkg/events/cloud" "go.thethings.network/lorawan-stack/v3/pkg/task" _ "gocloud.dev/pubsub/mempubsub" ) func main() { // The task starter is used for automatic re-subscription on failure. taskStarter := task.StartTaskFunc(task.DefaultStartTask) // Import the desired cloud pub-sub drivers (see godoc.org/gocloud.dev). // In this example we use "gocloud.dev/pubsub/mempubsub". cloudPubSub, err := cloud.NewPubSub(context.TODO(), taskStarter, "mem://events", "mem://events") if err != nil { panic(err) } // Replace the default pubsub so that we will now publish to a Go Cloud pub sub. events.SetDefaultPubSub(cloudPubSub) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PubSub ¶
PubSub with Go Cloud backend.
func NewPubSub ¶
func NewPubSub(ctx context.Context, taskStarter task.Starter, pubURL, subURL string) (*PubSub, error)
NewPubSub creates a new PubSub that publishes and subscribes to Go Cloud. If the subURL is an empty string, this PubSub will only publish to Go Cloud.
Click to show internal directories.
Click to hide internal directories.