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
- type Sink
- func (s *Sink) FindGaps(ctx context.Context) ([]string, error)
- func (*Sink) Kind() string
- func (s *Sink) ListExisting(ctx context.Context, key indexjobs.Key) (map[string]indexjobs.Vector, error)
- func (*Sink) StampExpected(context.Context, indexjobs.Key, int) error
- func (s *Sink) Upsert(ctx context.Context, key indexjobs.Key, rows []indexjobs.Vector) error
- func (s *Sink) UpsertBatch(ctx context.Context, key indexjobs.Key, rows []indexjobs.Vector) error
- type Source
- type Store
- func (s *Store) ListVectors(ctx context.Context, connection, schemaHash string) (map[string]indexjobs.Vector, error)
- func (s *Store) Replace(ctx context.Context, connection, schemaHash string, rows []indexjobs.Vector) error
- func (s *Store) UpsertBatch(ctx context.Context, connection, schemaHash string, rows []indexjobs.Vector) error
- type ToolkitLister
Constants ¶
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 ¶
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 ¶
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) 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 ¶
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.
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) LoadItems ¶
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 ¶
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 (*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.
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.