search

package
v0.0.0-...-0b46401 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoaderContext

func NewLoaderContext(ctx context.Context, dbConn *pgxpool.Pool, searcher Client) context.Context

Types

type Client

type Client interface {
	Search(ctx context.Context, page *pagination.Pagination, filter SearchFilter) (*SearchNodeConnection, error)
	AddClient(kind SearchType, client Searchable)
	ReIndex(ctx context.Context) error
}

func New

func New(ctx context.Context, pool *pgxpool.Pool, log logrus.FieldLogger) (Client, error)

type Document

type Document struct {
	ID     string            `json:"id"`
	Name   string            `json:"name"`
	Team   string            `json:"team,omitempty"`
	Kind   string            `json:"kind"`
	Fields map[string]string `json:"fields,omitempty"`
}

func (Document) Type

func (m Document) Type() string

type Indexer

type Indexer interface {
	Upsert(doc Document)
	Remove(id ident.Ident)
}

type K8sSearch

type K8sSearch[T watcher.Object] struct {
	// contains filtered or unexported fields
}

func NewK8sSearch

func NewK8sSearch[T watcher.Object](
	kind SearchType,
	watcher *watcher.Watcher[T],
	getByIdent func(ctx context.Context, id ident.Ident) (SearchNode, error),
	newIdent func(env string, o T) ident.Ident,
) *K8sSearch[T]

func (K8sSearch[T]) Convert

func (k K8sSearch[T]) Convert(ctx context.Context, ids ...ident.Ident) ([]SearchNode, error)

func (K8sSearch[T]) ReIndex

func (k K8sSearch[T]) ReIndex(ctx context.Context) []Document

func (K8sSearch[T]) Watch

func (k K8sSearch[T]) Watch(ctx context.Context, indexer Indexer) error

type Result

type Result struct {
	Node SearchNode
	Rank int
}

type SearchFilter

type SearchFilter struct {
	Query string      `json:"query"`
	Type  *SearchType `json:"type,omitempty"`
}

type SearchNode

type SearchNode interface {
	ID() ident.Ident
	IsSearchNode()
}

type SearchNodeConnection

type SearchNodeConnection = pagination.Connection[SearchNode]

type SearchNodeEdge

type SearchNodeEdge = pagination.Edge[SearchNode]

type SearchType

type SearchType string

func (SearchType) MarshalGQL

func (e SearchType) MarshalGQL(w io.Writer)

func (SearchType) String

func (e SearchType) String() string

func (*SearchType) UnmarshalGQL

func (e *SearchType) UnmarshalGQL(v interface{}) error

type Searchable

type Searchable interface {
	Convert(ctx context.Context, ids ...ident.Ident) ([]SearchNode, error)
	ReIndex(ctx context.Context) []Document
	Watch(ctx context.Context, indexer Indexer) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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