events

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package events defines the structured observability events of Auth-All. Auth-All does not dictate the logging or tracing backend of the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

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

Emitter fans one event out to every registered handler.

func NewEmitter

func NewEmitter(now func() time.Time) *Emitter

NewEmitter returns an emitter.

func (*Emitter) Add

func (e *Emitter) Add(h Handler)

Add registers a handler.

func (*Emitter) Emit

func (e *Emitter) Emit(ctx context.Context, name Name, userID string, fields map[string]any)

Emit sends one event to every handler.

type Event

type Event struct {
	Name   Name
	Time   time.Time
	UserID string
	Fields map[string]any
}

Event is one structured observability event.

An event must never carry a password, a password hash, a session token, a one-time token, or a provider secret.

type Handler

type Handler interface {
	HandleEvent(ctx context.Context, event Event)
}

Handler receives events.

type HandlerFunc

type HandlerFunc func(ctx context.Context, event Event)

HandlerFunc adapts a function to the Handler interface.

func (HandlerFunc) HandleEvent

func (f HandlerFunc) HandleEvent(ctx context.Context, e Event)

HandleEvent implements Handler.

type Name

type Name string

Name identifies an event type.

const (
	SignUp                 Name = "auth.sign_up"
	SignIn                 Name = "auth.sign_in"
	SignInFailed           Name = "auth.sign_in_failed"
	SignOut                Name = "auth.sign_out"
	PasswordResetRequested Name = "auth.password_reset_requested"
	PasswordChanged        Name = "auth.password_changed"
	EmailVerified          Name = "auth.email_verified"
	EmailChangeRequested   Name = "auth.email_change_requested"
	EmailChanged           Name = "auth.email_changed"
	// UserDeleted arrives before Auth-All removes the rows, so a handler can
	// still read the owned data.
	UserDeleted        Name = "auth.user_deleted"
	MagicLinkRequested Name = "auth.magic_link_requested"
	MagicLinkUsed      Name = "auth.magic_link_used"
	OAuthCompleted     Name = "auth.oauth_completed"
	AccountLinked      Name = "auth.account_linked"
	AccountUnlinked    Name = "auth.account_unlinked"
)

Expected v1 events.

Jump to

Keyboard shortcuts

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