feed

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package feed is authama's event feed: one ordered stream of what happened, for the API, webhooks and MCP, each event a CloudEvents 1.0 event in structured JSON (https://github.com/cloudevents/spec). An operation that finished (any change, made from the CLI or the web) is a com.simtabi.authama.operation.finished event; a change to a watched file is com.simtabi.authama.file.added, .changed, .removed or .mode-changed.

The envelope is sange's (its design, webhooks-and-events.md section 3.1), so one receiver reads both: the type is reverse-DNS from authama's own prefix, as its desktop notifier's app id is; the source is a URL naming this install by a random id, never the host or the user; a path in a home is written from ~, so neither a subject nor the data names the account.

It is read from the history database and the file events log, so it holds changes made by every authama process, not only the one serving the feed. Events are ordered by time, then id; a cursor names a place in that order.

Index

Constants

View Source
const (
	TypeOperation     = TypePrefix + "operation.finished"
	TypeFileAdded     = TypePrefix + "file.added"
	TypeFileChanged   = TypePrefix + "file.changed"
	TypeFileRemoved   = TypePrefix + "file.removed"
	TypeFileMode      = TypePrefix + "file.mode-changed"
	TypeWatchStarted  = TypePrefix + "file.watch.started"
	TypeWebhookTested = TypePrefix + "webhook.tested"
)

The event types.

View Source
const MaxLimit = 500

MaxLimit is the most events one List returns.

View Source
const TypePrefix = "com.simtabi.authama."

TypePrefix starts every event type: reverse-DNS, as authama's desktop notifier's app id is (com.simtabi.authama).

Variables

View Source
var ErrBadCursor = errors.New("not a cursor this feed gave: pass the cursor of the last event you read, or none")

ErrBadCursor is a cursor this feed did not give.

Functions

func Matches

func Matches(e Event, prefixes []string) bool

Matches reports whether e's type starts with one of prefixes, each given whole (com.simtabi.authama.file.) or without the common prefix (file.); no prefixes match every event.

func Now

func Now(now time.Time) string

Now is a cursor at now: List after it returns only what happens from now on. A new webhook starts here, so it is not sent the whole history.

func Source

func Source(p paths.Paths) string

Source is this install's CloudEvents source: a URL naming it by a random id, made the first time it is asked for and kept in the state home. It names neither the host nor the user.

Types

type Event

type Event struct {
	SpecVersion     string    `json:"specversion"`
	ID              string    `json:"id"`
	Source          string    `json:"source"`
	Type            string    `json:"type"`
	Subject         string    `json:"subject,omitempty"`
	Time            time.Time `json:"time"`
	DataContentType string    `json:"datacontenttype"`
	Data            any       `json:"data"`
	// Sub is the authamasub extension: set per webhook delivery to the
	// endpoint's name, inside the signed body, so a delivery captured from
	// one endpoint cannot be replayed to another that checks it.
	Sub string `json:"authamasub,omitempty"`
}

Event is one thing that happened: a CloudEvents 1.0 event.

func List

func List(p paths.Paths, cursor string, limit int) ([]Event, string, error)

List returns up to limit events after cursor, oldest first, and the cursor to pass next (the last event's, or cursor itself when there are none). An empty cursor lists the newest limit events.

func New

func New(p paths.Paths, id, typ, subject string, t time.Time, data any) Event

New is an event of typ at t, from this install, with its data.

func (Event) Cursor

func (e Event) Cursor() string

Cursor is the event's place in the feed: the next List after it starts after this event.

type File

type File struct {
	Kind      string    `json:"kind"`
	ChangedAt time.Time `json:"changed_at"`
	Area      string    `json:"area"`
	Path      string    `json:"path"`
	Size      int64     `json:"size,omitempty"`
	Mode      string    `json:"mode,omitempty"`
	Detail    string    `json:"detail,omitempty"`
}

File is a file event's data. The event's time is when authama noticed the change; ChangedAt is when the file says it changed, which can be much earlier (a change made while nothing was watching).

type Operation

type Operation struct {
	OpID    string   `json:"op_id"`
	Command string   `json:"command"`
	Args    []string `json:"args"`
	// MadeFrom is where the change was made: cli or web (the history's
	// source; named apart from the event's own source).
	MadeFrom string   `json:"made_from"`
	Result   string   `json:"result"`
	Error    string   `json:"error,omitempty"`
	Subjects []string `json:"subjects,omitempty"`
	Snapshot string   `json:"snapshot,omitempty"`
}

Operation is an operation.finished event's data.

Jump to

Keyboard shortcuts

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