Documentation
¶
Index ¶
- Constants
- type DeliveryAttempt
- type InboxItem
- type JSONMap
- type NotificationDefinition
- type NotificationEvent
- type NotificationMessage
- type NotificationPreference
- type NotificationPublication
- type NotificationRetryOperation
- type NotificationTemplate
- type RecordMeta
- type StringList
- type SubscriptionGroup
- type TemplateSchema
- type TemplateSource
Constants ¶
const ( EventStatusPending = "pending" EventStatusScheduled = "scheduled" EventStatusDispatching = "dispatching" EventStatusRetrying = "retrying" EventStatusPartial = "partial" EventStatusProcessed = "processed" EventStatusFailed = "failed" MessageStatusPending = "pending" MessageStatusDelivered = "delivered" MessageStatusFailed = "failed" MessageStatusSkipped = "skipped" AttemptStatusPending = "pending" AttemptStatusSucceeded = "succeeded" AttemptStatusFailed = "failed" PublicationStatusPending = "pending" PublicationStatusPublished = "published" PublicationStatusProcessing = "processing" PublicationStatusCompleted = "completed" PublicationStatusFailed = "failed" RetryStatusPending = "pending" RetryStatusProcessing = "processing" RetryStatusCompleted = "completed" RetryStatusFailed = "failed" )
Domain constants for statuses.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeliveryAttempt ¶
type DeliveryAttempt struct {
bun.BaseModel `bun:"table:notification_delivery_attempts"`
RecordMeta
MessageID uuid.UUID `bun:",nullzero,notnull"`
RetryOperationID uuid.UUID `bun:",nullzero"`
Adapter string `bun:",nullzero,notnull"`
Status string `bun:",nullzero"`
Error string `bun:",nullzero"`
ErrorCode string `bun:",nullzero"`
Payload JSONMap `bun:"type:jsonb,nullzero"`
}
DeliveryAttempt tracks adapter executions.
type InboxItem ¶
type InboxItem struct {
bun.BaseModel `bun:"table:notification_inbox_items"`
RecordMeta
UserID string `bun:",nullzero,notnull" json:"user_id"`
MessageID uuid.UUID `bun:",nullzero" json:"message_id"`
Title string `bun:",nullzero" json:"title"`
Body string `bun:",nullzero" json:"body"`
Locale string `bun:",nullzero" json:"locale"`
Unread bool `bun:",nullzero" json:"unread"`
Pinned bool `bun:",nullzero" json:"pinned"`
ActionURL string `bun:",nullzero" json:"action_url"`
Metadata JSONMap `bun:"type:jsonb,nullzero" json:"metadata,omitempty"`
ReadAt time.Time `bun:",nullzero" json:"read_at"`
DismissedAt time.Time `bun:",nullzero" json:"dismissed_at"`
SnoozedUntil time.Time `bun:",nullzero" json:"snoozed_until"`
}
InboxItem stores in-app notifications.
type NotificationDefinition ¶
type NotificationDefinition struct {
bun.BaseModel `bun:"table:notification_definitions"`
RecordMeta
Code string `bun:",unique,nullzero,notnull"`
Name string `bun:",nullzero,notnull"`
Description string `bun:",nullzero"`
Severity string `bun:",nullzero"`
Category string `bun:",nullzero"`
Channels StringList `bun:"type:jsonb,nullzero"`
Metadata JSONMap `bun:"type:jsonb,nullzero"`
// Template references are logical names, resolved by services.
TemplateKeys StringList `bun:"type:jsonb,nullzero"`
// Policy stores throttling/digest requirements.
Policy JSONMap `bun:"type:jsonb,nullzero"`
}
NotificationDefinition describes a notification type.
type NotificationEvent ¶
type NotificationEvent struct {
bun.BaseModel `bun:"table:notification_events"`
RecordMeta
DefinitionCode string `bun:",nullzero,notnull"`
TenantID string `bun:",nullzero"`
ActorID string `bun:",nullzero"`
Recipients StringList `bun:"type:jsonb,nullzero"`
Channels StringList `bun:"type:jsonb,nullzero"`
Locale string `bun:",nullzero"`
Context JSONMap `bun:"type:jsonb,nullzero"`
CorrelationID string `bun:",nullzero"`
RequestID string `bun:",nullzero"`
IdempotencyScope string `bun:",nullzero"`
IdempotencyKey string `bun:",nullzero"`
RequestFingerprint string `bun:",nullzero"`
TransientDependent bool `bun:",notnull,default:false"`
PublicationID uuid.UUID `bun:",nullzero"`
DigestKey string `bun:",nullzero"`
RetryClaimUntil time.Time `bun:",nullzero"`
ScheduledAt time.Time `bun:",nullzero"`
Status string `bun:",nullzero"`
}
NotificationEvent captures input events before fan-out.
type NotificationMessage ¶
type NotificationMessage struct {
bun.BaseModel `bun:"table:notification_messages"`
RecordMeta
EventID uuid.UUID `bun:",nullzero,notnull"`
RetryOperationID uuid.UUID `bun:",nullzero"`
Channel string `bun:",nullzero,notnull"`
TemplateCode string `bun:",nullzero"`
ProviderPlan StringList `bun:"type:jsonb,nullzero"`
Locale string `bun:",nullzero"`
Subject string `bun:",nullzero"`
Body string `bun:",nullzero"`
ActionURL string `bun:",nullzero" json:"action_url"`
ManifestURL string `bun:",nullzero" json:"manifest_url"`
URL string `bun:",nullzero" json:"url"`
Receiver string `bun:",nullzero,notnull"`
Status string `bun:",nullzero"`
Metadata JSONMap `bun:"type:jsonb,nullzero"`
}
NotificationMessage represents a concrete rendered message.
type NotificationPreference ¶
type NotificationPreference struct {
bun.BaseModel `bun:"table:notification_preferences"`
RecordMeta
SubjectID string `bun:",nullzero,notnull" json:"subject_id"`
SubjectType string `bun:",nullzero,notnull" json:"subject_type"` // user, tenant, group, etc.
DefinitionCode string `bun:",nullzero" json:"definition_code"`
Channel string `bun:",nullzero" json:"channel"`
Locale string `bun:",nullzero" json:"locale"`
Enabled bool `bun:",nullzero" json:"enabled"`
QuietHours JSONMap `bun:"type:jsonb,nullzero" json:"quiet_hours,omitempty"`
AdditionalRules JSONMap `bun:"type:jsonb,nullzero" json:"additional_rules,omitempty"`
}
NotificationPreference captures opt-in/out settings.
type NotificationPublication ¶ added in v0.15.0
type NotificationPublication struct {
bun.BaseModel `bun:"table:notification_publications"`
RecordMeta
Kind string `bun:",nullzero,notnull"`
DigestKey string `bun:",nullzero"`
QueueKey string `bun:",nullzero,notnull"`
RunAt time.Time `bun:",nullzero"`
Status string `bun:",nullzero,notnull"`
ClaimUntil time.Time `bun:",nullzero"`
Attempts int `bun:",nullzero"`
ErrorCode string `bun:",nullzero"`
}
NotificationPublication is the durable authority for asynchronous scheduling and digest windows.
type NotificationRetryOperation ¶ added in v0.15.0
type NotificationRetryOperation struct {
bun.BaseModel `bun:"table:notification_retry_operations"`
RecordMeta
EventID uuid.UUID `bun:",nullzero,notnull"`
RetryScope string `bun:",nullzero,notnull"`
IdempotencyKey string `bun:",nullzero,notnull"`
CorrelationID string `bun:",nullzero"`
RequestID string `bun:",nullzero"`
Status string `bun:",nullzero,notnull"`
ClaimUntil time.Time `bun:",nullzero"`
ErrorCode string `bun:",nullzero"`
}
NotificationRetryOperation provides a durable idempotency and audit record for explicit same-event retries.
type NotificationTemplate ¶
type NotificationTemplate struct {
bun.BaseModel `bun:"table:notification_templates"`
RecordMeta
Code string `bun:",nullzero,notnull,unique:template_variant"`
Channel string `bun:",nullzero,notnull,unique:template_variant"`
Description string `bun:",nullzero"`
Body string `bun:",nullzero"`
Subject string `bun:",nullzero"`
Locale string `bun:",nullzero,unique:template_variant"`
Format string `bun:",nullzero"`
Revision int `bun:",nullzero"`
Source TemplateSource `bun:"type:jsonb,nullzero"`
Schema TemplateSchema `bun:"type:jsonb,nullzero"`
Metadata JSONMap `bun:"type:jsonb,nullzero"`
}
NotificationTemplate stores channel-specific template configuration.
type RecordMeta ¶
type RecordMeta struct {
ID uuid.UUID `bun:",pk,type:uuid" json:"id"`
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"created_at"`
UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"updated_at"`
DeletedAt time.Time `bun:",soft_delete,nullzero" json:"deleted_at"`
}
RecordMeta captures identifiers and audit fields shared across entities.
func (*RecordMeta) EnsureID ¶
func (m *RecordMeta) EnsureID()
EnsureID assigns a UUID when the struct is about to be persisted.
type StringList ¶
type StringList []string
StringList stores []string as JSON.
func (*StringList) Scan ¶
func (s *StringList) Scan(value any) error
type SubscriptionGroup ¶
type SubscriptionGroup struct {
bun.BaseModel `bun:"table:notification_subscription_groups"`
RecordMeta
Code string `bun:",unique,nullzero,notnull"`
Name string `bun:",nullzero,notnull"`
Description string `bun:",nullzero"`
Metadata JSONMap `bun:"type:jsonb,nullzero"`
}
SubscriptionGroup represents named cohorts.
type TemplateSchema ¶
type TemplateSchema struct {
Required []string `json:"required"`
Optional []string `json:"optional"`
}
TemplateSchema tracks required and optional placeholders.
func (TemplateSchema) IsZero ¶
func (s TemplateSchema) IsZero() bool
IsZero reports whether any constraints are defined.
func (*TemplateSchema) Scan ¶
func (s *TemplateSchema) Scan(value any) error
type TemplateSource ¶
type TemplateSource struct {
Type string `json:"type"`
Reference string `json:"reference"`
Payload JSONMap `json:"payload"`
}
TemplateSource describes where a template body originated.
func (*TemplateSource) Scan ¶
func (s *TemplateSource) Scan(value any) error