postgres

package
v1.101.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package postgres provides a PostgreSQL-backed searchgate.Store so the search-first gate's discovery signal is shared across replicas.

The backing table's key column is named session_id for historical reasons (migration 000077), but it holds an opaque discovery scope key, not necessarily a session ID: the middleware keys discovery on the authenticated user when known (see middleware.PlatformContext.DiscoveryScopeKey). Do not add session-specific logic (a foreign key to sessions, a per-session join) on the strength of the column name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements searchgate.Store using PostgreSQL.

func New

func New(db *sql.DB, ttl time.Duration) *Store

New creates a PostgreSQL discovery store. Discovery records expire ttl after the most recent MarkDiscovered.

func (*Store) Cleanup

func (s *Store) Cleanup(ctx context.Context) error

Cleanup deletes expired discovery records.

func (*Store) Close

func (*Store) Close() error

Close is a no-op; the underlying *sql.DB is owned by the platform.

func (*Store) HasDiscovered

func (s *Store) HasDiscovered(ctx context.Context, scopeKey string) (bool, error)

HasDiscovered reports whether the scope has a non-expired discovery record.

func (*Store) MarkDiscovered

func (s *Store) MarkDiscovered(ctx context.Context, scopeKey string) error

MarkDiscovered records discovery for the scope, upserting its expiry. The scopeKey is stored in the session_id column (see the package doc).

Jump to

Keyboard shortcuts

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