sqlentry

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sqlentry holds the shared PostgreSQL/SQLite bounded entry-listing logic. Stores should go through RunBoundedQuery and ApplyEpochFilter instead of copying the cursor, upToEntryId, fromSeq, and ordering predicates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyCreatedAtFilter added in v0.2.2

func ApplyCreatedAtFilter(base *gorm.DB, filter *registrystore.CreatedAtFilter, alias string, sqlite bool) *gorm.DB

ApplyCreatedAtFilter appends timestamp predicates to base. When sqlite is true the integer companion column created_at_unix_ms is used (milliseconds since Unix epoch) so that timezone-offset-bearing DATETIME text values compare as instants rather than strings.

func ApplyEpochFilter

func ApplyEpochFilter(base *gorm.DB, epochFilter *registrystore.MemoryEpochFilter, latestWhenNil bool, latestErr string) (*gorm.DB, error)

func BoundedEntriesFromBase

func BoundedEntriesFromBase(ctx context.Context, base *gorm.DB, fromSeq *uint32, afterEntryID, beforeEntryID *string, tail bool, limit int, lookup LookupFunc, cursorEntryError CursorErrorFunc, entryIDValue EntryIDValueFunc, scanErr string) ([]model.Entry, *string, *string, error)

func FilterEntriesByCreatedAt added in v0.2.2

func FilterEntriesByCreatedAt(entries []model.Entry, filter *registrystore.CreatedAtFilter) []model.Entry

FilterEntriesByCreatedAt filters in-memory entries based on CreatedAtFilter.

func RunBoundedQuery

func RunBoundedQuery(ctx context.Context, query BoundedQuery) ([]model.Entry, *string, *string, error)

func UUIDStringValue

func UUIDStringValue(id uuid.UUID) any

func UUIDValue

func UUIDValue(id uuid.UUID) any

func WhereEntryOrderAtOrBeforeAlias

func WhereEntryOrderAtOrBeforeAlias(tx *gorm.DB, alias string, bound model.Entry, entryIDValue EntryIDValueFunc) *gorm.DB

func WhereEntryOrderBeforeAlias

func WhereEntryOrderBeforeAlias(tx *gorm.DB, alias string, bound model.Entry, entryIDValue EntryIDValueFunc) *gorm.DB

func WhereEntryOrderStrictlyAfterAlias

func WhereEntryOrderStrictlyAfterAlias(tx *gorm.DB, alias string, bound model.Entry, entryIDValue EntryIDValueFunc) *gorm.DB

func WhereSeqOrderBeforeAlias

func WhereSeqOrderBeforeAlias(tx *gorm.DB, alias string, bound model.Entry, entryIDValue EntryIDValueFunc) *gorm.DB

func WhereSeqOrderStrictlyAfterAlias

func WhereSeqOrderStrictlyAfterAlias(tx *gorm.DB, alias string, bound model.Entry, entryIDValue EntryIDValueFunc) *gorm.DB

Types

type BoundedQuery

type BoundedQuery struct {
	Base             *gorm.DB
	FromSeq          *uint32
	UpToEntryID      *string
	AfterEntryID     *string
	BeforeEntryID    *string
	Tail             bool
	Limit            int
	MaxLimit         int
	UpToLookup       LookupFunc
	BaseTransform    func(*gorm.DB) (*gorm.DB, error)
	CursorEntryError CursorErrorFunc
	LimitError       func(int) error
	EntryNotFound    func(string) error
	EntryIDValue     EntryIDValueFunc
	ScanErr          string
	CreatedAtFilter  *registrystore.CreatedAtFilter
	// SQLite signals that ApplyCreatedAtFilter should use the integer
	// created_at_unix_ms column instead of the DATETIME text column.
	SQLite bool
}

type CursorErrorFunc

type CursorErrorFunc func(context.Context, string, string) error

type EntryIDValueFunc

type EntryIDValueFunc func(uuid.UUID) any

EntryIDValueFunc converts a UUID entry id into the value shape expected by a datastore/dialect. PostgreSQL compares UUID values directly, while SQLite stores entry ids as text.

type LookupFunc

type LookupFunc func(string) (model.Entry, bool, error)

Jump to

Keyboard shortcuts

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