added the notify module

This commit is contained in:
2026-01-24 20:35:40 +11:00
parent 0c3d4ef095
commit 65e8bd07e1
14 changed files with 2728 additions and 0 deletions

51
notify/notifications.go Normal file
View File

@@ -0,0 +1,51 @@
package notify
// Notification represents a message that can be sent to subscribers.
// Notifications contain metadata about the message (Level, Title),
// the content (Message, Details), and an optional Action field for
// custom application data.
type Notification struct {
// Target specifies the subscriber ID to receive this notification.
// If empty when passed to NotifyAll(), the notification is broadcast
// to all subscribers. If set, only the targeted subscriber receives it.
Target Target
// Level indicates the notification severity (Success, Info, Warn, Error).
Level Level
// Title is a short summary of the notification.
Title string
// Message is the main notification content.
Message string
// Details contains additional information about the notification.
Details string
// Action is an optional field for custom application data.
// This can be used to attach contextual information, callback functions,
// URLs, or any other data needed by the notification handler.
Action any
}
// Target is a unique identifier for a subscriber.
// Targets are automatically generated when a subscriber is created
// using cryptographic random bytes (16 bytes, base64 URL-encoded).
type Target string
// Level represents the severity or type of a notification.
type Level string
const (
// LevelSuccess indicates a successful operation or positive outcome.
LevelSuccess Level = "success"
// LevelInfo indicates general informational messages.
LevelInfo Level = "info"
// LevelWarn indicates warnings that don't require immediate action.
LevelWarn Level = "warn"
// LevelError indicates errors that require attention.
LevelError Level = "error"
)