notifications

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 9 Imported by: 0

README

notifications

Laravel-style notifications for togo. Channels: mail (via togo mail), broadcast (via togo realtime), database. Push providers (FCM, OneSignal, Pusher) ship as channel plugins.

togo install togo-framework/notifications

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

func RegisterChannel

func RegisterChannel(name string, f func(*togo.Kernel) Channel)

RegisterChannel registers a delivery channel (call from a plugin's init()).

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

type PushMessage struct {
	Title string
	Body  string
	Data  map[string]string
}

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

func FromKernel(k *togo.Kernel) (*Service, bool)

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).

Jump to

Keyboard shortcuts

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