Documentation ¶
Overview ¶
Package redis implements an events.PubSub implementation that uses Redis PubSub.
Example ¶
package main import ( "context" "go.thethings.network/lorawan-stack/v3/pkg/component" "go.thethings.network/lorawan-stack/v3/pkg/events" "go.thethings.network/lorawan-stack/v3/pkg/events/redis" ttnredis "go.thethings.network/lorawan-stack/v3/pkg/redis" ) func main() { // The task starter is used for automatic re-subscription on failure. taskStarter := component.StartTaskFunc(component.DefaultStartTask) // This sends all events received from Redis to the default pubsub. redisPubSub := redis.WrapPubSub(context.TODO(), events.DefaultPubSub(), taskStarter, ttnredis.Config{ // Config here... }) // Replace the default pubsub so that we will now publish to Redis. events.SetDefaultPubSub(redisPubSub) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PubSub ¶
PubSub with Redis backend.
func NewPubSub ¶
func NewPubSub(ctx context.Context, taskStarter component.TaskStarter, conf ttnredis.Config) *PubSub
NewPubSub creates a new PubSub that publishes and subscribes to Redis.
func WrapPubSub ¶
func WrapPubSub(ctx context.Context, wrapped events.PubSub, taskStarter component.TaskStarter, conf ttnredis.Config) *PubSub
WrapPubSub wraps an existing PubSub and publishes all events received from Redis to that PubSub.
Click to show internal directories.
Click to hide internal directories.