Documentation
¶
Index ¶
- Variables
- func NewIndexingBootstrapCoreStore(delegate bootstrap.BootstrapCoreStore, indexer DocumentIndexer) bootstrap.BootstrapCoreStore
- func NewIndexingCoreObjectStore(delegate bootstrap.CoreObjectStore, indexer DocumentIndexer) bootstrap.CoreObjectStore
- func OpenSearchDocumentID(doc Document) string
- func OpenSearchDocumentIDForRef(ref DocumentRef) string
- func RebuildOpenSearchIndex(ctx context.Context, client *OpenSearchClient, state *bootstrap.Service) error
- func ValidateOpenSearchEndpoint(raw string) error
- type ConsistencyCounts
- type ConsistencyObjectCount
- type ConsistencyPlan
- type ConsistencyResult
- type ConsistencyService
- type ConsistencyTarget
- type Document
- type DocumentBuilder
- func (b DocumentBuilder) Client(org string, client bootstrap.Client) Document
- func (b DocumentBuilder) DataBagItem(org, bagName string, item bootstrap.DataBagItem) Document
- func (b DocumentBuilder) Environment(org string, env bootstrap.Environment) Document
- func (b DocumentBuilder) Node(org string, node bootstrap.Node) Document
- func (b DocumentBuilder) Role(org string, role bootstrap.Role) Document
- type DocumentIndexer
- type DocumentRef
- type Index
- type MemoryIndex
- type NoopIndex
- type OpenSearchCapabilities
- type OpenSearchClient
- func (c *OpenSearchClient) BulkUpsert(ctx context.Context, docs []Document) error
- func (c *OpenSearchClient) DeleteByQuery(ctx context.Context, org, index string) error
- func (c *OpenSearchClient) DeleteDocument(ctx context.Context, id string) error
- func (c *OpenSearchClient) DeleteDocuments(ctx context.Context, refs []DocumentRef) error
- func (c *OpenSearchClient) DiscoverProvider(ctx context.Context) (OpenSearchProviderInfo, error)
- func (c *OpenSearchClient) EnsureChefIndex(ctx context.Context) error
- func (c *OpenSearchClient) Ping(ctx context.Context) error
- func (c *OpenSearchClient) ProviderInfo() (OpenSearchProviderInfo, bool)
- func (c *OpenSearchClient) Refresh(ctx context.Context) error
- func (c *OpenSearchClient) SearchIDs(ctx context.Context, query Query) ([]string, error)
- func (c *OpenSearchClient) Status() Status
- func (c *OpenSearchClient) UpsertDocuments(ctx context.Context, docs []Document) error
- type OpenSearchIndex
- type OpenSearchOption
- type OpenSearchProviderInfo
- type OpenSearchTransport
- type Query
- type QueryPlan
- type ReindexCounts
- type ReindexMode
- type ReindexPlan
- type ReindexResult
- type ReindexService
- type ReindexTarget
- type Result
- type Status
Constants ¶
This section is empty.
Variables ¶
var ( ErrOrganizationNotFound = errors.New("search organization not found") ErrIndexNotFound = errors.New("search index not found") ErrNotFound = ErrOrganizationNotFound ErrInvalidConfiguration = errors.New("search backend invalid configuration") // ErrInvalidQuery marks Chef search query syntax that OpenCook can parse as invalid. ErrInvalidQuery = errors.New("search query invalid") ErrRejected = errors.New("search backend rejected request") )
Functions ¶
func NewIndexingBootstrapCoreStore ¶
func NewIndexingBootstrapCoreStore(delegate bootstrap.BootstrapCoreStore, indexer DocumentIndexer) bootstrap.BootstrapCoreStore
func NewIndexingCoreObjectStore ¶
func NewIndexingCoreObjectStore(delegate bootstrap.CoreObjectStore, indexer DocumentIndexer) bootstrap.CoreObjectStore
func OpenSearchDocumentID ¶
func OpenSearchDocumentIDForRef ¶
func OpenSearchDocumentIDForRef(ref DocumentRef) string
func RebuildOpenSearchIndex ¶
Types ¶
type ConsistencyCounts ¶
type ConsistencyCounts struct {
Expected int `json:"expected"`
Observed int `json:"observed"`
Missing int `json:"missing"`
Stale int `json:"stale"`
Unsupported int `json:"unsupported"`
Upserted int `json:"upserted"`
Deleted int `json:"deleted"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
Clean int `json:"clean"`
}
type ConsistencyObjectCount ¶
type ConsistencyPlan ¶
type ConsistencyResult ¶
type ConsistencyResult struct {
AllOrganizations bool `json:"all_organizations"`
Organization string `json:"organization,omitempty"`
Index string `json:"index,omitempty"`
Repair bool `json:"repair,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
Counts ConsistencyCounts `json:"counts"`
ObjectCounts []ConsistencyObjectCount `json:"object_counts,omitempty"`
MissingDocuments []string `json:"missing_documents,omitempty"`
StaleDocuments []string `json:"stale_documents,omitempty"`
UnsupportedScopes []string `json:"unsupported_scopes,omitempty"`
Failures []string `json:"failures,omitempty"`
Duration time.Duration `json:"duration"`
}
type ConsistencyService ¶
type ConsistencyService struct {
// contains filtered or unexported fields
}
func NewConsistencyService ¶
func NewConsistencyService(state *bootstrap.Service, target ConsistencyTarget) *ConsistencyService
func (*ConsistencyService) Run ¶
func (s *ConsistencyService) Run(ctx context.Context, plan ConsistencyPlan) (result ConsistencyResult, err error)
func (*ConsistencyService) WithNow ¶
func (s *ConsistencyService) WithNow(now func() time.Time) *ConsistencyService
type ConsistencyTarget ¶
type Document ¶
type Document struct {
Index string
Name string
Object map[string]any
Partial map[string]any
Fields map[string][]string
Resource authz.Resource
}
func DocumentsFromBootstrapStateForPlan ¶
func DocumentsFromBootstrapStateForPlan(state *bootstrap.Service, plan ReindexPlan) ([]Document, error)
type DocumentBuilder ¶
type DocumentBuilder struct{}
DocumentBuilder centralizes Chef-style search document expansion so the memory and OpenSearch-backed indexes cannot drift in field semantics.
func NewDocumentBuilder ¶
func NewDocumentBuilder() DocumentBuilder
func (DocumentBuilder) Client ¶
func (b DocumentBuilder) Client(org string, client bootstrap.Client) Document
func (DocumentBuilder) DataBagItem ¶
func (b DocumentBuilder) DataBagItem(org, bagName string, item bootstrap.DataBagItem) Document
func (DocumentBuilder) Environment ¶
func (b DocumentBuilder) Environment(org string, env bootstrap.Environment) Document
type DocumentIndexer ¶
type DocumentRef ¶
type MemoryIndex ¶
type MemoryIndex struct {
// contains filtered or unexported fields
}
func NewMemoryIndex ¶
func NewMemoryIndex(state *bootstrap.Service, target string) MemoryIndex
func (MemoryIndex) Name ¶
func (i MemoryIndex) Name() string
func (MemoryIndex) Search ¶
Search evaluates the shared compiled query plan against documents derived from the in-memory bootstrap state.
func (MemoryIndex) Status ¶
func (i MemoryIndex) Status() Status
type NoopIndex ¶
type NoopIndex struct {
// contains filtered or unexported fields
}
func NewNoopIndex ¶
type OpenSearchCapabilities ¶
type OpenSearchCapabilities struct {
IndexExistsChecks bool
CreateIndex bool
PutMapping bool
BulkIndexing bool
SearchIDs bool
SearchAfterPagination bool
Refresh bool
DeleteDocument bool
DeleteByQuery bool
DeleteByQueryFallbackRequired bool
TotalHitsObjectResponses bool
}
OpenSearchCapabilities describes provider operations OpenCook relies on. Later hardening tasks can replace inferred flags with more exact probes.
type OpenSearchClient ¶
type OpenSearchClient struct {
// contains filtered or unexported fields
}
func NewOpenSearchClient ¶
func NewOpenSearchClient(raw string, opts ...OpenSearchOption) (*OpenSearchClient, error)
func (*OpenSearchClient) BulkUpsert ¶
func (c *OpenSearchClient) BulkUpsert(ctx context.Context, docs []Document) error
func (*OpenSearchClient) DeleteByQuery ¶
func (c *OpenSearchClient) DeleteByQuery(ctx context.Context, org, index string) error
func (*OpenSearchClient) DeleteDocument ¶
func (c *OpenSearchClient) DeleteDocument(ctx context.Context, id string) error
func (*OpenSearchClient) DeleteDocuments ¶
func (c *OpenSearchClient) DeleteDocuments(ctx context.Context, refs []DocumentRef) error
func (*OpenSearchClient) DiscoverProvider ¶
func (c *OpenSearchClient) DiscoverProvider(ctx context.Context) (OpenSearchProviderInfo, error)
DiscoverProvider performs the non-mutating discovery sequence used to model the configured provider before activation, status, or admin workflows rely on version-specific behavior.
func (*OpenSearchClient) EnsureChefIndex ¶
func (c *OpenSearchClient) EnsureChefIndex(ctx context.Context) error
func (*OpenSearchClient) ProviderInfo ¶
func (c *OpenSearchClient) ProviderInfo() (OpenSearchProviderInfo, bool)
ProviderInfo returns the last successful provider discovery snapshot. Callers get a copy so later discovery refreshes cannot mutate their view.
func (*OpenSearchClient) Status ¶
func (c *OpenSearchClient) Status() Status
func (*OpenSearchClient) UpsertDocuments ¶
func (c *OpenSearchClient) UpsertDocuments(ctx context.Context, docs []Document) error
type OpenSearchIndex ¶
type OpenSearchIndex struct {
// contains filtered or unexported fields
}
func NewOpenSearchIndex ¶
func NewOpenSearchIndex(state *bootstrap.Service, client *OpenSearchClient, target string) *OpenSearchIndex
func (*OpenSearchIndex) Name ¶
func (i *OpenSearchIndex) Name() string
func (*OpenSearchIndex) Status ¶
func (i *OpenSearchIndex) Status() Status
type OpenSearchOption ¶
type OpenSearchOption func(*openSearchOptions)
func WithOpenSearchTransport ¶
func WithOpenSearchTransport(transport OpenSearchTransport) OpenSearchOption
type OpenSearchProviderInfo ¶
type OpenSearchProviderInfo struct {
Distribution string
Version string
VersionParsed bool
Major int
Minor int
Patch int
Tagline string
NodeName string
ClusterName string
BuildFlavor string
BuildType string
BuildHash string
Capabilities OpenSearchCapabilities
}
OpenSearchProviderInfo records the provider identity and inferred feature set discovered from the configured OpenSearch-compatible endpoint.
type OpenSearchTransport ¶
type QueryPlan ¶
type QueryPlan struct {
// contains filtered or unexported fields
}
func CompileQuery ¶
CompileQuery parses the Chef search query string into the shared internal AST used by both memory search and OpenSearch request planning.
func (QueryPlan) Err ¶
Err returns a stable parser error that callers can map to Chef-facing search error shapes without exposing parser/provider internals.
func (QueryPlan) Matches ¶
Matches evaluates the compiled query against an expanded search document.
func (QueryPlan) MatchesFields ¶
MatchesFields is a test/helper shortcut for evaluating already-expanded document fields without constructing a complete search document.
func (QueryPlan) OpenSearchQueryBody ¶
OpenSearchQueryBody returns the query-only request fragment for tests and request builders that need to inspect the generated provider clause.
func (QueryPlan) OpenSearchQueryClause ¶
OpenSearchQueryClause compiles the AST into the current compat_terms-based OpenSearch clause, keeping provider behavior aligned with memory search.
type ReindexCounts ¶
type ReindexMode ¶
type ReindexMode string
const ( ReindexModeDrop ReindexMode = "drop" ReindexModeReindex ReindexMode = "reindex" ReindexModeComplete ReindexMode = "complete" )
type ReindexPlan ¶
type ReindexResult ¶
type ReindexResult struct {
Mode ReindexMode `json:"mode"`
AllOrganizations bool `json:"all_organizations"`
Organization string `json:"organization,omitempty"`
Index string `json:"index,omitempty"`
Names []string `json:"names,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
Counts ReindexCounts `json:"counts"`
Failures []string `json:"failures,omitempty"`
Duration time.Duration `json:"duration"`
}
type ReindexService ¶
type ReindexService struct {
// contains filtered or unexported fields
}
func NewReindexService ¶
func NewReindexService(state *bootstrap.Service, target ReindexTarget) *ReindexService
func (*ReindexService) Run ¶
func (s *ReindexService) Run(ctx context.Context, plan ReindexPlan) (result ReindexResult, err error)
func (*ReindexService) WithNow ¶
func (s *ReindexService) WithNow(now func() time.Time) *ReindexService
type ReindexTarget ¶
type Status ¶
type Status struct {
Backend string `json:"backend"`
Configured bool `json:"configured"`
Message string `json:"message"`
}
func OpenSearchActiveStatus ¶
func OpenSearchActiveStatus() Status
func OpenSearchProviderStatus ¶
func OpenSearchProviderStatus(info OpenSearchProviderInfo, known bool) Status
OpenSearchProviderStatus preserves the stable status payload shape while making discovered provider identity and capability mode visible in the existing human-readable message.
func OpenSearchUnavailableStatus ¶
func OpenSearchUnavailableStatus() Status