postgres

package
v1.153.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 5 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

func Shared added in v1.152.6

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

Shared returns the store a workflow gate keeps its records in: this PostgreSQL store when there is a database, so a record written on one replica is read on another (#789), and the in-memory store otherwise, which is correct for a single replica.

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