events

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package events publishes durable domain events and accesses the platformd notification service (ADR-0035).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Causation

func Causation(ctx context.Context) string

func WithCausation

func WithCausation(ctx context.Context, eventID string) context.Context

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(app string) *Client

func (*Client) List

func (c *Client) List(ctx context.Context, login, after string, limit int) (Page, error)

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, login, id, action string) (int, error)

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, user auth.User, event Event) error

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, login string, fn func(Notification) error) error

Stream opens the plane SSE feed and calls fn for every notification record.

func (*Client) Unread

func (c *Client) Unread(ctx context.Context, login string) (int, error)

type Event

type Event struct {
	ID           string         `json:"id"`
	Type         string         `json:"type"`
	SubjectID    string         `json:"subject_id,omitempty"`
	OccurredAt   time.Time      `json:"occurred_at"`
	Data         map[string]any `json:"data"`
	Notification *Notification  `json:"notification,omitempty"`
}

type Notification

type Notification struct {
	ID          string  `json:"id,omitempty"`
	EventID     string  `json:"event_id,omitempty"`
	Source      string  `json:"source,omitempty"`
	Title       string  `json:"title"`
	Body        string  `json:"body,omitempty"`
	AppSlug     string  `json:"app_slug,omitempty"`
	Path        string  `json:"path,omitempty"`
	URL         string  `json:"url,omitempty"`
	GroupKey    string  `json:"group_key,omitempty"`
	DedupKey    string  `json:"dedup_key,omitempty"`
	CreatedAt   string  `json:"created_at,omitempty"`
	ReadAt      *string `json:"read_at"`
	DismissedAt *string `json:"dismissed_at"`
	Retired     bool    `json:"source_retired,omitempty"`
}

type Page

type Page struct {
	Notifications []Notification `json:"notifications"`
	Next          string         `json:"next"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL