Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartWithFallback ¶
StartWithFallback starts the listener with polling fallback. This is useful when the database doesn't support LISTEN (e.g., connection poolers). If DATABASE_DIRECT_URL is set, tests the connection first and uses it for real-time LISTEN/NOTIFY. Falls back to polling if the direct connection fails or is unavailable.
Types ¶
type DeliveryChannel ¶
type DeliveryChannel interface {
Name() string
Deliver(ctx context.Context, n *db.Notification) error
}
DeliveryChannel defines the interface for notification delivery
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener listens for PostgreSQL notifications and triggers delivery
func NewListener ¶
NewListener creates a new notification listener. Returns nil if service is nil to prevent nil pointer dereferences.
type NotificationDB ¶
type NotificationDB interface {
GetPendingSlackNotifications(ctx context.Context, limit int) ([]*db.Notification, error)
MarkNotificationDelivered(ctx context.Context, notificationID, channel string) error
GetSlackConnectionsForOrg(ctx context.Context, organisationID string) ([]*db.SlackConnection, error)
GetEnabledUserLinksForConnection(ctx context.Context, connectionID string) ([]*db.SlackUserLink, error)
}
NotificationDB defines the database operations needed by the service
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles notification delivery to various channels. Note: Notifications are created by PostgreSQL triggers, not Go code.
func NewService ¶
func NewService(database NotificationDB) *Service
NewService creates a notification service
func (*Service) AddChannel ¶
func (s *Service) AddChannel(ch DeliveryChannel)
AddChannel adds a delivery channel to the service
type SlackChannel ¶
type SlackChannel struct {
// contains filtered or unexported fields
}
SlackChannel implements the DeliveryChannel interface for Slack
func NewSlackChannel ¶
func NewSlackChannel(database SlackDB) (*SlackChannel, error)
NewSlackChannel creates a new Slack delivery channel
func (*SlackChannel) Deliver ¶
func (c *SlackChannel) Deliver(ctx context.Context, n *db.Notification) error
Deliver sends a notification to Slack
type SlackDB ¶
type SlackDB interface {
GetSlackConnectionsForOrg(ctx context.Context, organisationID string) ([]*db.SlackConnection, error)
GetEnabledUserLinksForConnection(ctx context.Context, connectionID string) ([]*db.SlackUserLink, error)
GetSlackToken(ctx context.Context, connectionID string) (string, error)
}
SlackDB defines Slack-specific database operations