events

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package events records what happens (mail received, subscriptions, sends, bounces, opens, clicks) and streams it live to `lfr events --follow`.

Index

Constants

View Source
const (
	Received      = "received"     // a message arrived in a mailbox
	Subscribed    = "subscribed"   // a signup is pending confirmation
	Confirmed     = "confirmed"    // a membership was confirmed
	Unsubscribed  = "unsubscribed" // a member left a list
	Sent          = "sent"         // an outbound message was handed over
	Failed        = "failed"       // an outbound message failed for good
	Deferred      = "deferred"     // an outbound attempt failed temporarily
	Bounced       = "bounced"      // a recipient address does not exist
	Complained    = "complained"   // a recipient marked a message as spam
	Opened        = "opened"
	Clicked       = "clicked"
	IssueStarted  = "issue_started"
	IssueFinished = "issue_finished"
	Paused        = "paused" // a list stopped sending, see detail
)

Kinds of events.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	DB  *store.DB
	Now func() time.Time
	// contains filtered or unexported fields
}

Bus stores events and fans them out to subscribers.

func (*Bus) List

func (b *Bus) List(ctx context.Context, q Query) ([]Event, error)

List returns stored events, newest last.

func (*Bus) Publish

func (b *Bus) Publish(e Event)

Publish sends e to every subscriber that keeps up; slow ones miss events rather than stalling the server.

func (*Bus) Record

func (b *Bus) Record(ctx context.Context, e Event) error

Record stores e (stamping its time) and publishes it.

func (*Bus) RecordTx

func (b *Bus) RecordTx(ctx context.Context, tx *sql.Tx, e *Event) error

RecordTx stores e inside tx; it is published once Publish is called after commit.

func (*Bus) Subscribe

func (b *Bus) Subscribe() (<-chan Event, func())

Subscribe returns a channel of new events and a function ending the subscription.

type Event

type Event struct {
	ID         int64     `json:"id"`
	At         time.Time `json:"at"`
	Kind       string    `json:"kind"`
	ListID     int64     `json:"list_id,omitempty"`
	IssueID    int64     `json:"issue_id,omitempty"`
	ContactID  int64     `json:"contact_id,omitempty"`
	OutboundID int64     `json:"outbound_id,omitempty"`
	MessageID  int64     `json:"message_id,omitempty"`
	Detail     string    `json:"detail,omitempty"`
}

Event is one record.

type Query

type Query struct {
	Since   time.Time
	Kinds   []string
	ListID  int64
	IssueID int64
	Limit   int
}

Query selects stored events.

Jump to

Keyboard shortcuts

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