Documentation
¶
Overview ¶
Package postgres implements notify's durable inbox on a host-owned PostgreSQL pool. Hosts explicitly migrate before use and authorize every recipient. It starts no workers, sends no messages and never owns the host's pool.
Index ¶
- func Migrate(ctx context.Context, pool *pgxpool.Pool, schema string) error
- func MigrateDB(ctx context.Context, db *sql.DB, schema string) error
- type Config
- type Store
- func (s *Store) EraseRecipient(ctx context.Context, r notify.Recipient) error
- func (s *Store) EraseRecipientTx(ctx context.Context, tx pgx.Tx, r notify.Recipient) error
- func (s *Store) Get(ctx context.Context, r notify.Recipient, id string) (notify.Item, error)
- func (s *Store) GetRecipients(ctx context.Context, rs []notify.Recipient, id string) (notify.Item, error)
- func (s *Store) List(ctx context.Context, r notify.Recipient, o notify.ListOptions) (notify.Page, error)
- func (s *Store) ListRecipients(ctx context.Context, recipients []notify.Recipient, o notify.ListOptions) (notify.Page, error)
- func (s *Store) Publish(ctx context.Context, in notify.Input) (notify.Item, error)
- func (s *Store) PublishTx(ctx context.Context, tx pgx.Tx, in notify.Input) (notify.Item, error)
- func (s *Store) SetDismissed(ctx context.Context, r notify.Recipient, id string, dismissed bool) (notify.Item, error)
- func (s *Store) SetDismissedRecipients(ctx context.Context, rs []notify.Recipient, id string, dismissed bool) (notify.Item, error)
- func (s *Store) SetRead(ctx context.Context, r notify.Recipient, id string, read bool) (notify.Item, error)
- func (s *Store) SetReadRecipients(ctx context.Context, rs []notify.Recipient, id string, read bool) (notify.Item, error)
- func (s *Store) Transition(ctx context.Context, r notify.Recipient, id string, revision int64, ...) (notify.Item, error)
- func (s *Store) TransitionTx(ctx context.Context, tx pgx.Tx, r notify.Recipient, id string, revision int64, ...) (notify.Item, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct{ Schema, Scope string }
Config binds a store to one local application/tenant scope in a migrated schema.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store retains notices and actionable items. Scope and recipients are data isolation boundaries; authorization remains with the host.
func (*Store) EraseRecipient ¶
EraseRecipient deletes an inbox and permanently fences delayed publications. This is account erasure, not the operation for dismissing one item.
func (*Store) EraseRecipientTx ¶
EraseRecipientTx joins account erasure in the host's transaction.
func (*Store) GetRecipients ¶
func (s *Store) GetRecipients(ctx context.Context, rs []notify.Recipient, id string) (notify.Item, error)
GetRecipients reads a receipt only when its recipient is in the host's fresh authorized set. An absent or newly unlinked recipient reads as not found.
func (*Store) List ¶
func (s *Store) List(ctx context.Context, r notify.Recipient, o notify.ListOptions) (notify.Page, error)
List reads one authorized recipient's inbox, newest first. Restart scans from an empty cursor to discover late commits; cursors are not delivery watermarks.
func (*Store) ListRecipients ¶
func (s *Store) ListRecipients(ctx context.Context, recipients []notify.Recipient, o notify.ListOptions) (notify.Page, error)
ListRecipients reads only the recipients the host authorized for this request. Filtering happens in SQL before pagination, so an unlinked recipient consumes no page slots. Empty recipients returns an empty page. Cursors bind the normalized recipient set and filters; restart paging after access changes.
func (*Store) Publish ¶
Publish inserts once per origin and recipient. Retries preserve content and every local read/workflow transition, including after a crash before an ack.
func (*Store) PublishTx ¶
PublishTx joins the domain change's transaction. The transaction must reach the same database as the store; the caller commits or rolls it back.
func (*Store) SetDismissed ¶
func (s *Store) SetDismissed(ctx context.Context, r notify.Recipient, id string, dismissed bool) (notify.Item, error)
SetDismissed archives or restores a recipient's receipt, independently of read state and domain/workflow resolution.
func (*Store) SetDismissedRecipients ¶
func (s *Store) SetDismissedRecipients(ctx context.Context, rs []notify.Recipient, id string, dismissed bool) (notify.Item, error)
SetDismissedRecipients changes only a receipt in the host's currently authorized set. Retried dismissal preserves its original timestamp.
func (*Store) SetRead ¶
func (s *Store) SetRead(ctx context.Context, r notify.Recipient, id string, read bool) (notify.Item, error)
SetRead changes only local read state. It never resolves an actionable item.
func (*Store) SetReadRecipients ¶
func (s *Store) SetReadRecipients(ctx context.Context, rs []notify.Recipient, id string, read bool) (notify.Item, error)
SetReadRecipients updates authorized receipt state and returns the canonical item/revision. Reading does not dismiss the receipt or resolve a workflow.
func (*Store) Transition ¶
func (s *Store) Transition(ctx context.Context, r notify.Recipient, id string, revision int64, status notify.Status) (notify.Item, error)
Transition changes workflow state under optimistic concurrency. The caller must perform/authorize any domain action first, or use TransitionTx in the same transaction as that action. General notices cannot become work items.