added the notify module
This commit is contained in:
51
notify/notifications.go
Normal file
51
notify/notifications.go
Normal 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"
|
||||
)
|
||||
Reference in New Issue
Block a user