Documentation
¶
Overview ¶
Package notify defines notices and actionable inbox items shared by host applications. Authentication, rendering, delivery channels and the action that remedies a problem belong to the application. Reading never resolves an item. Existing domain records can be projected as Items without copying their authoritative state into another queue.
Index ¶
Constants ¶
const MaxMutations = 100
MaxMutations bounds one atomic publication/withdrawal batch.
Variables ¶
var ( ErrInvalid = errors.New("notify: invalid input") ErrNotFound = errors.New("notify: item not found") ErrConflict = errors.New("notify: item changed") ErrRecipientErased = errors.New("notify: recipient erased") )
Errors are stable outcomes of validation, scoped lookup and concurrent edits.
Functions ¶
func ValidateRecipient ¶
ValidateRecipient checks the scope-local identity; it grants no authority.
Types ¶
type Adoption ¶ added in v1.17.0
Adoption maps exact legacy origins for Current's recipient to one current producer identity during an explicit, stopped-writer migration. The host authorizes the mapping; it never means a prefix, range or inbox search.
type AppView ¶ added in v1.13.0
type AppView struct {
AppID string
LegacyOrigins []OriginScope
}
AppView presents tenant-wide receipts and one exact application's receipts. LegacyOrigins is an explicit compatibility allowance for unclassified rows. A nil or empty allowance admits no legacy origins.
type Audience ¶
type Audience string
Audience selects an authorization boundary, not a delivery channel.
type Input ¶
type Input struct {
Recipient Recipient `json:"recipient"`
Origin Origin `json:"origin"`
Kind string `json:"kind"`
Data json.RawMessage `json:"data"`
CreatedAt time.Time `json:"created_at"`
Visibility Visibility `json:"visibility,omitempty"`
AppID string `json:"app_id,omitempty"`
Status Status `json:"status,omitempty"`
// ActionRequested records the item's category at creation. With empty Status
// it is historical information, not a claim that the issue is still open.
ActionRequested bool `json:"action_requested,omitempty"`
Severity string `json:"severity,omitempty"`
}
Input is trusted application-authored content. Kind is extensible. Data must contain only fields the recipient may see. CreatedAt is the source time. Publish accepts StatusNotice or StatusOpen; workflow transitions are separate.
type Item ¶
type Item struct {
ID string `json:"id"`
Input
ReadAt *time.Time `json:"read_at"`
// DismissedAt archives this recipient's receipt without resolving work.
DismissedAt *time.Time `json:"dismissed_at"`
ResolvedAt *time.Time `json:"resolved_at"`
UpdatedAt time.Time `json:"updated_at"`
Revision int64 `json:"revision"`
// ProducerRevision orders source mutations independently of receipt changes.
ProducerRevision int64 `json:"producer_revision,omitempty"`
// Withdrawn items are retained only to reject delayed producer mutations.
Withdrawn bool `json:"withdrawn,omitempty"`
}
Item is an inbox record or a projection of an existing domain record. ReadAt and ResolvedAt describe different operations; neither implies the other. Revision is positive in the durable store and zero for unversioned projections.
type ListOptions ¶
type ListOptions struct {
Limit int
Cursor string
UnreadOnly bool
Status *Status
// Dismissed selects archived receipts instead of the active inbox.
Dismissed bool
}
ListOptions selects a bounded, newest-first page. Status nil includes notices and work items; a pointer to StatusNotice selects only general notices.
type Mutation ¶ added in v1.17.0
type Mutation struct {
Input
Revision int64 `json:"revision"`
Withdrawn bool `json:"withdrawn,omitempty"`
}
Mutation is the current state of one exact producer identity. The producer durably assigns Revision before delivery; transport retries reuse it. A newer publication replaces the payload, while Withdrawn hides the item even if it has not arrived yet. Neither IDs nor withdrawals interpret wildcards.
func ValidateMutation ¶ added in v1.17.0
ValidateMutation validates and normalizes one producer mutation. Withdrawal needs only recipient, origin and visibility; payload fields are ignored.
type Origin ¶
type Origin struct {
System string `json:"system"`
Scope string `json:"scope"`
ID string `json:"id"`
// Subject is the source recipient, when the destination maps it to a
// different local identity. It grants no authority by itself.
Subject string `json:"subject,omitempty"`
}
Origin preserves a producer's deployment, namespace and stable item ID. Scope can identify a merchant, project or account issuer. Each recipient receives at most one item for the same System, Scope and ID in one local store scope; Subject is optional provenance, not part of that identity.
type OriginScope ¶ added in v1.13.0
type OriginScope struct {
System string `json:"system" yaml:"system"`
Scope string `json:"scope" yaml:"scope"`
}
OriginScope selects all items from one exact producer namespace. It is separate from recipient authorization and never grants access to an account.
type Publisher ¶
Publisher is implemented by durable stores and application adapters. A retry with the same recipient and origin preserves the original content/read state.
type Recipient ¶
Recipient names a user or an operator queue within the store's scope. Hosts authorize this pair; an email address is never an identity join.
type Sink ¶ added in v1.17.0
Sink durably accepts an atomic batch. Older revisions and identical retries are successful no-ops; conflicting mutations at one revision return ErrConflict. A nil error may mean durable queued delivery rather than a visible inbox item. Producers never need to list the destination inbox.
type Status ¶
type Status string
Status is independent of read state. A general notice has no workflow; actionable items begin open and are explicitly resolved or dismissed.
type Visibility ¶ added in v1.13.0
type Visibility string
Visibility identifies where a receipt may be presented; Origin remains provenance and replay identity. Empty visibility means an unclassified legacy item, never an implicit tenant-wide grant in an AppView.
const ( VisibilityTenant Visibility = "tenant" VisibilityApp Visibility = "app" )