Documentation
¶
Overview ¶
Package notifications is togo's Laravel-style notification system. A Notification is delivered over one or more channels — mail (via togo mail), broadcast (via togo realtime), database — and push providers (FCM, OneSignal, Pusher) register additional channels via RegisterChannel.
Install: `togo install togo-framework/notifications`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BroadcastNotification ¶
type BroadcastNotification interface {
ToBroadcast(Notifiable) (event string, data any)
}
BroadcastNotification renders a realtime event + payload.
type Channel ¶
type Channel interface {
Send(ctx context.Context, to Notifiable, n Notification) error
}
Channel delivers a notification to a recipient.
type DatabaseNotification ¶
type DatabaseNotification interface {
ToDatabase(Notifiable) map[string]any
}
DatabaseNotification renders the stored payload.
type MailNotification ¶
type MailNotification interface{ ToMail(Notifiable) mail.Message }
MailNotification renders the email body.
type Notifiable ¶
type Notifiable interface {
RouteID() string // stable id (database channel)
RouteEmail() string // mail channel
RoutePushTokens() []string // push channels
}
Notifiable is the recipient and its per-channel routing.
type Notification ¶
type Notification interface {
Via(Notifiable) []string
}
Notification chooses its channels for a given recipient.
type PushMessage ¶
PushMessage is the common push payload for push-channel plugins.
type PushNotification ¶
type PushNotification interface{ ToPush(Notifiable) PushMessage }
PushNotification renders a push message (used by FCM/OneSignal/Pusher).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service dispatches notifications to channels.
func FromKernel ¶
FromKernel fetches the notifications service from the kernel container.
func (*Service) Send ¶
func (s *Service) Send(ctx context.Context, to Notifiable, n Notification) error
Send delivers n to every channel returned by n.Via(to).