logstore

package
v0.0.18 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRowData       = errors.New("invalid log row data")
	ErrUncertain     = errors.New("log commit outcome is uncertain")
	ErrClientDeleted = errors.New("log client was deleted during commit")
	ErrSystemic      = errors.New("systemic log commit failure")
)

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	OccurredAt time.Time
	Sequence   int64
	ID         int64
}

type Event

type Event struct {
	Key        [32]byte
	Scope      Scope
	Instance   string
	OccurredAt time.Time
	Sequence   int64
	Message    string
}

type Outcome

type Outcome uint8
const (
	Inserted Outcome = iota + 1
	Duplicate
	RejectedClient
)

type Page

type Page struct {
	Rows           []Row // Newest first.
	Older          *Cursor
	Newer          *Cursor
	AnchorInstance *string // Set when an authorized context anchor was found.
}

type PageQuery

type PageQuery struct {
	Scope     Scope
	Instances []string // Nil selects all instances. A non-nil empty slice selects none.
	Range     *TimeRange
	// Use at most one cursor. No cursor requests the newest page.
	Older  *Cursor
	Newer  *Cursor
	Search *logsearch.Query
	Limit  int

	// AnchorID resolves the instance of a context continuation if the URL still
	// supplies its anchor. The existing selection applies if the anchor is gone.
	AnchorID int64
}

type Result

type Result struct {
	Outcome Outcome
	Row     Row // Set only for Inserted.
}

type Row

type Row struct {
	ID         int64
	Scope      Scope
	Instance   string
	OccurredAt time.Time
	Sequence   int64
	Message    string
}

type Scope

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

type Store

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

func New

func New(pool *pgxpool.Pool) *Store

func (*Store) Around

func (s *Store) Around(ctx context.Context, scope Scope, id int64, limit int, bounds *TimeRange) (Page, bool, error)

Around returns the authorized anchor with up to limit neighbors on each side.

func (*Store) Commit

func (s *Store) Commit(ctx context.Context, events []Event) ([]Result, error)

Commit checks client ownership and activity in the insert statement. A successful call returns one outcome per event in input order. Event keys are retained only as long as their logs are retained. Known transient failures are returned with their original cause for ordinary retries.

func (*Store) Instances

func (s *Store) Instances(ctx context.Context, scope Scope) ([]string, error)

func (*Store) Page

func (s *Store) Page(ctx context.Context, query PageQuery) (Page, error)

type TimeRange

type TimeRange struct {
	From time.Time
	To   time.Time
}

TimeRange includes From and excludes To.

Jump to

Keyboard shortcuts

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