graphqlindex

package
v1.131.1 Latest Latest
Warning

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

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

Documentation

Overview

Package graphqlindex is the graphql connection kind's consumer of the shared index-jobs framework. It registers a Source/Sink pair under source_kind "graphql_operations" so a connection's operations are embedded off the request path, and so ranking a schema with hundreds of operations does not depend on the caller's words matching the schema author's.

The indexing unit is one connection: its source id is the connection name, and one pass embeds every operation the connection's current schema exposes. Vectors are keyed on the schema hash as well as the connection, so a schema that changes does not invalidate a connection that was reverted to a previous one, and a pass that has not run yet leaves ranking lexical rather than wrong.

Index

Constants

View Source
const SourceKind = "graphql_operations"

SourceKind is the indexjobs source_kind this package serves.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sink

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

Sink stores the vectors for the graphql operations kind.

func NewSink

func NewSink(store *Store, source *Source) *Sink

NewSink builds the sink over a store and the source it shares a kind with. The source is held because gap detection has to compare the live operation set against the persisted vectors: a schema refresh changes what should be indexed without changing any count in the database.

func (*Sink) FindGaps

func (s *Sink) FindGaps(ctx context.Context) ([]string, error)

FindGaps reports the connections whose live operation set has drifted from their persisted vectors: a schema read for the first time, a schema that changed, or an operation whose indexable text changed without the count changing.

func (*Sink) Kind

func (*Sink) Kind() string

Kind reports the graphql operations source kind.

func (*Sink) ListExisting

func (s *Sink) ListExisting(ctx context.Context, key indexjobs.Key) (map[string]indexjobs.Vector, error)

ListExisting returns the persisted vectors for the connection's current schema version, for the worker's dedup pass.

func (*Sink) StampExpected

func (*Sink) StampExpected(context.Context, indexjobs.Key, int) error

StampExpected is a no-op. A successful pass writes the connection's complete operation set atomically, so the indexed vector count is also the expected count and there is nothing separate to record.

func (*Sink) Upsert

func (s *Sink) Upsert(ctx context.Context, key indexjobs.Key, rows []indexjobs.Vector) error

Upsert replaces the connection's whole vector set for its current schema, so an operation the schema no longer exposes loses its vector. Vectors written for an earlier schema hash are left alone: they are what a connection reverted to that schema would rank on.

func (*Sink) UpsertBatch

func (s *Sink) UpsertBatch(ctx context.Context, key indexjobs.Key, rows []indexjobs.Vector) error

UpsertBatch writes one chunk in place, so a pass that fails midway leaves its earlier chunks visible to the next attempt's dedup.

type Source

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

Source enumerates the operations of one connection as embeddable items.

func NewSource

func NewSource(lister ToolkitLister) *Source

NewSource builds the source over the live toolkits.

func (*Source) Kind

func (*Source) Kind() string

Kind reports the graphql operations source kind.

func (*Source) LoadItems

func (s *Source) LoadItems(_ context.Context, sourceID string) ([]indexjobs.Item, error)

LoadItems returns one item per operation of the named connection. A connection that is gone, or that holds no schema yet, yields ErrSourceGone so the worker clears its vectors and completes rather than retrying a unit that cannot resolve.

func (*Source) OnSucceeded

func (s *Source) OnSucceeded(sourceID string)

OnSucceeded re-reads the connection's vectors so a schema that was ranking lexically starts ranking semantically without a restart.

type Store

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

Store persists the per-operation embedding vectors in graphql_operation_embeddings. It is the write half of what internal/platform/graphqlstore reads at connection load time; the two address the same rows, keyed on (connection, schema_hash, operation_id).

func NewStore

func NewStore(db *sql.DB) *Store

NewStore returns a store over the platform's database.

func (*Store) ListVectors

func (s *Store) ListVectors(ctx context.Context, connection, schemaHash string) (map[string]indexjobs.Vector, error)

ListVectors returns the persisted vectors for one connection's schema version, keyed by operation id.

func (*Store) Replace

func (s *Store) Replace(ctx context.Context, connection, schemaHash string, rows []indexjobs.Vector) error

Replace swaps the whole vector set for one connection's schema version in a single transaction, so an operation the schema no longer exposes loses its row.

func (*Store) UpsertBatch

func (s *Store) UpsertBatch(ctx context.Context, connection, schemaHash string, rows []indexjobs.Vector) error

UpsertBatch writes one chunk in place without disturbing rows outside it.

type ToolkitLister

type ToolkitLister func() []*graphqlkit.Toolkit

ToolkitLister returns the live graphql toolkits. It is a function rather than a snapshot so a connection added through the admin API after startup is indexed without a restart.

Jump to

Keyboard shortcuts

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