tableavail

package
v1.125.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tableavail resolves catalog entity URNs to the warehouse table behind them, remembering each answer briefly.

Several surfaces need the same question answered: the insight review path asks what the platform can see for a pending claim's entities (#1219), and the delivery path asks whether a claim it is handing an agent could be settled by one query (#1220). Both are the same lookup against the same query provider, on read paths that repeat it — a polling review queue, a search that returns the same entity across many hits — so the answer is remembered for a few minutes rather than re-derived per read.

Every answer is advisory. A URN that does not resolve, a table that is not available, a provider that is absent or noop, and a provider that is slow all degrade to no answer at all — never to an error and never to a refused read.

Index

Constants

View Source
const (

	// DeliveryTimeout is the budget for a caller resolving on an interactive
	// delivery path rather than an admin read. It sits well under the default
	// per-provider search budget (knowledge.search_provider_timeout, 5s) because
	// what rides on it is an affordance on a payload that delivers with or
	// without it: a slow warehouse must cost the delivery its marker, never the
	// record itself and never the search arm's whole budget.
	DeliveryTimeout = 2 * time.Second
)

Variables

This section is empty.

Functions

func Distinct

func Distinct(urnSets ...[]string) []string

Distinct returns the non-empty URNs of urnSets with duplicates removed, in first-seen order. Callers resolving a page of records share it so one entity claimed by many records is looked up once, and so the whole page costs one pass rather than one per record.

Types

type Cache

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

Cache resolves entity URNs through a query provider, remembering each answer for a TTL so repeated reads of the same entity cost one lookup.

A nil *Cache resolves nothing, so a caller never needs a branch of its own for the no-provider deployment.

func New

func New(p query.Provider) *Cache

New returns a Cache over p, or nil when no query provider is configured. A nil *Cache resolves nothing, so a caller's only branch is whether to wire it.

A provider that answers but reports nothing available (the platform's noop fallback) is deliberately NOT refused here: "can this provider resolve anything" is not a question a provider can be asked, only answered by asking it, and a cache over such a provider costs one remembered "no" per entity.

func NewWithOptions

func NewWithOptions(p query.Provider, opts Options) *Cache

NewWithOptions returns a Cache over p with opts applied, or nil when no query provider is configured.

func (*Cache) Resolve

func (c *Cache) Resolve(ctx context.Context, urns []string) map[string]*query.TableAvailability

Resolve returns the available tables among urns. A URN absent from the result is one the provider does not report as available, could not answer for, or was not reached within the pass's budget — all indistinguishable to the caller by design, since every one of them means "no answer to show".

func (*Cache) Verifiables

func (c *Cache) Verifiables(ctx context.Context, urns []string) map[string]query.Verifiable

Verifiables returns the queryable identity of each URN that resolved, keyed by URN. It is the delivery-side projection of Resolve: a consumer holding a claim needs the table and connection to check it against, not the row estimate the review path compares numbers with.

type Options

type Options struct {
	// Timeout bounds one resolution pass. Zero selects defaultTimeout.
	Timeout time.Duration
	// TTL is how long a positive answer is remembered. Zero selects defaultTTL.
	TTL time.Duration
	// SkipRowEstimate asks the provider only where an entity is queryable, never
	// how many rows it holds, when the provider offers that cheaper path
	// (query.LocationResolver). Set it on any request-path caller that reads only
	// QueryTable/Connection: without it a provider configured for row estimation
	// runs a COUNT(*) per entity whose result the caller discards. Leave it false
	// in a caller that reads EstimatedRows.
	SkipRowEstimate bool
	// Now reads the clock. Nil selects time.Now.
	Now func() time.Time
}

Options overrides a Cache's timing. The zero value selects the defaults; it exists so a caller with a different read shape (or a test with a fake clock) can set them without a second implementation of the cache itself.

Jump to

Keyboard shortcuts

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