live

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package live distributes committed logs and renders them only on gateways with interested viewers. Core NATS delivery is best effort, not a replay log.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLiveResync      = errors.New("live log view requires a fresh snapshot")
	ErrInvalidSelector = errors.New("invalid live log instance selection")
	ErrClosed          = errors.New("live logs are closed")
)

Functions

This section is empty.

Types

type Logs

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

Logs owns live subscriptions, lazy rendering and publication budgets. It borrows a dedicated NATS connection; the composition root closes that last.

func New

func New(conn *nats.Conn) *Logs

func (*Logs) AfterCommit

func (l *Logs) AfterCommit(ctx context.Context, rows []types.StoredLog)

AfterCommit accepts a bounded copy, regardless of this replica's viewers. Failure is a live-view failure, never a reason to retry a committed insert.

func (*Logs) AfterUncertainCommit

func (l *Logs) AfterUncertainCommit(rows []types.StoredLog)

AfterUncertainCommit is for a write whose outcome is unknown. The rows may be committed without publication, and a retry will not publish existing rows, so matching views must stop visibly instead of silently missing them.

func (*Logs) Close

func (l *Logs) Close()

func (*Logs) Open

func (l *Logs) Open(ctx context.Context, scope Scope, selector Selector) (*Session, error)

Open waits for broker readiness. ctx bounds opening, not the lifetime of the returned Session; its owner must Close it. Scope must already be authorized.

type Scope

type Scope struct {
	ProjectID uuid.UUID
	ClientID  uuid.UUID
}

type Selector

type Selector struct {
	Instances []string
}

An empty selection watches all instances; []string{""} watches the unnamed instance. Open copies the selection, so callers retain ownership of it.

func NewSelector

func NewSelector(instances []string) (Selector, error)

NewSelector bounds subscription fanout and URL/subject size without treating punctuation, whitespace or an empty instance name as NATS syntax.

type Session

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

Session owns a bounded viewer queue. Only done is closed; a concurrent renderer can never send to a closed data channel. HTML is immutable/shared.

func (*Session) Close

func (s *Session) Close()

Close immediately stops Next. Shared broker interest is released asynchronously, and disappears after the last local viewer leaves.

func (*Session) Next

func (s *Session) Next(ctx context.Context) ([]byte, error)

Jump to

Keyboard shortcuts

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