event

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package event provides event system definition and data event types.

Package event provides Watermill-based publish/subscribe infrastructure backed by Redis Streams.

Index

Constants

This section is empty.

Variables

View Source
var Publisher message.Publisher

Publisher is the global Watermill publisher, provided by NewPublisher via fx.

Functions

func BotEventFire added in v0.23.1

func BotEventFire(ctx types.Context, eventName string, param types.KV, pub message.Publisher) error

BotEventFire publishes a bot-run event to the event bus, triggering any subscribed pipeline handlers.

func NewMessage

func NewMessage(payload any) (*message.Message, error)

NewMessage creates a Watermill message from the given payload, marshaled as JSON.

func NewPublisher

func NewPublisher(lc fx.Lifecycle, client *redis.Client) (message.Publisher, error)

NewPublisher creates a Watermill Redis Stream publisher using the shared Redis client.

func NewRouter

func NewRouter(_ *sdktrace.TracerProvider) (*message.Router, error)

NewRouter creates a Watermill message router with standard middleware.

func NewSubscriber

func NewSubscriber(lc fx.Lifecycle, client *redis.Client) (message.Subscriber, error)

NewSubscriber creates a Watermill Redis Stream subscriber using the shared Redis client.

func PublishMessage

func PublishMessage(ctx context.Context, topic string, payload any) error

PublishMessage publishes a message to the given topic using the global Publisher, with OpenTelemetry tracing.

func SendMessage

func SendMessage(ctx types.Context, msg types.MsgPayload, pub message.Publisher) error

SendMessage delivers a message payload to the user's channels, scoped to a specific topic when ctx.Topic is set, or broadcast to all channels the user is a member of.

func SetMessageDestinations added in v0.99.0

func SetMessageDestinations(s MessageDestinations)

SetMessageDestinations wires the persistence backend used by SendMessage.

func TraceConsumerMiddleware added in v0.92.0

func TraceConsumerMiddleware() message.HandlerMiddleware

TraceConsumerMiddleware returns a Watermill middleware that extracts OTel trace context from message metadata and creates a consumer span for each incoming message.

Types

type DestinationChannelUser added in v0.99.0

type DestinationChannelUser struct {
	UserFlag    string
	ChannelFlag string
}

DestinationChannelUser maps a platform user flag to a channel flag.

type DestinationPlatform added in v0.99.0

type DestinationPlatform struct {
	ID   int64
	Name string
}

DestinationPlatform is a messaging platform used for delivery.

type DestinationPlatformChannel added in v0.99.0

type DestinationPlatformChannel struct {
	PlatformID int64
}

DestinationPlatformChannel identifies a platform channel by routing metadata.

type DestinationPlatformUser added in v0.99.0

type DestinationPlatformUser struct {
	PlatformID int64
	Flag       string
}

DestinationPlatformUser links a user to a platform for delivery.

type DestinationUser added in v0.99.0

type DestinationUser struct {
	ID int64
}

DestinationUser is the user identity subset needed to resolve message destinations.

type MessageDestinations added in v0.99.0

type MessageDestinations interface {
	GetUserByFlag(ctx context.Context, flag string) (*DestinationUser, error)
	GetPlatformUsersByUserId(ctx context.Context, userID int64) ([]*DestinationPlatformUser, error)
	GetPlatformChannelByFlag(ctx context.Context, flag string) (*DestinationPlatformChannel, error)
	GetPlatform(ctx context.Context, id int64) (*DestinationPlatform, error)
	GetPlatforms(ctx context.Context) ([]*DestinationPlatform, error)
	GetPlatformChannelUsersByUserFlags(ctx context.Context, userFlags []string) ([]*DestinationChannelUser, error)
}

MessageDestinations resolves users, platforms, and channels for message delivery.

func GetMessageDestinations added in v0.99.0

func GetMessageDestinations() MessageDestinations

GetMessageDestinations returns the injected message destinations store.

Jump to

Keyboard shortcuts

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