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 ¶
- Variables
- func BotEventFire(ctx types.Context, eventName string, param types.KV, pub message.Publisher) error
- func NewMessage(payload any) (*message.Message, error)
- func NewPublisher(lc fx.Lifecycle, client *redis.Client) (message.Publisher, error)
- func NewRouter(_ *sdktrace.TracerProvider) (*message.Router, error)
- func NewSubscriber(lc fx.Lifecycle, client *redis.Client) (message.Subscriber, error)
- func PublishMessage(ctx context.Context, topic string, payload any) error
- func SendMessage(ctx types.Context, msg types.MsgPayload, pub message.Publisher) error
- func SetMessageDestinations(s MessageDestinations)
- func TraceConsumerMiddleware() message.HandlerMiddleware
- type DestinationChannelUser
- type DestinationPlatform
- type DestinationPlatformChannel
- type DestinationPlatformUser
- type DestinationUser
- type MessageDestinations
Constants ¶
This section is empty.
Variables ¶
var Publisher message.Publisher
Publisher is the global Watermill publisher, provided by NewPublisher via fx.
Functions ¶
func BotEventFire ¶ added in v0.23.1
BotEventFire publishes a bot-run event to the event bus, triggering any subscribed pipeline handlers.
func NewMessage ¶
NewMessage creates a Watermill message from the given payload, marshaled as JSON.
func NewPublisher ¶
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 ¶
NewSubscriber creates a Watermill Redis Stream subscriber using the shared Redis client.
func PublishMessage ¶
PublishMessage publishes a message to the given topic using the global Publisher, with OpenTelemetry tracing.
func SendMessage ¶
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
DestinationChannelUser maps a platform user flag to a channel flag.
type DestinationPlatform ¶ added in v0.99.0
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
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.