Documentation
¶
Overview ¶
Package reconciler provides catalog synchronization and reconciliation capabilities. It handles merging data from multiple sources, detecting changes, and applying updates while respecting data authorities and merge strategies.
Index ¶
- func ConvertCatalogsMapToSources(srcs map[sources.ID]*catalogs.Builder) []sources.Observation
- func NewMockSource(sourceType sources.ID, catalog *catalogs.Builder) sources.Observation
- type AuthorityStrategy
- func (s *AuthorityStrategy) ApplyStrategy() differ.ApplyStrategy
- func (s *AuthorityStrategy) Description() string
- func (s *AuthorityStrategy) ResolveConflict(field string, values map[sources.ID]any) (any, sources.ID, string)
- func (s *AuthorityStrategy) ResolveResourceConflict(resourceType sources.ResourceType, field string, values map[sources.ID]any) (any, sources.ID, string)
- func (s *AuthorityStrategy) ShouldMerge(resourceType sources.ResourceType) bool
- func (s *AuthorityStrategy) Type() StrategyType
- func (s *AuthorityStrategy) ValidateResult(result *Result) error
- type Option
- type Reconciler
- type Result
- type ResultMetadata
- type ResultStatistics
- type SourceOrderStrategy
- func (s *SourceOrderStrategy) ApplyStrategy() differ.ApplyStrategy
- func (s *SourceOrderStrategy) Description() string
- func (s *SourceOrderStrategy) ResolveConflict(_ string, values map[sources.ID]any) (any, sources.ID, string)
- func (s *SourceOrderStrategy) ResolveResourceConflict(_ sources.ResourceType, _ string, values map[sources.ID]any) (any, sources.ID, string)
- func (s *SourceOrderStrategy) ShouldMerge(resourceType sources.ResourceType) bool
- func (s *SourceOrderStrategy) Type() StrategyType
- func (s *SourceOrderStrategy) ValidateResult(result *Result) error
- type Strategy
- type StrategyType
- type ValidationError
- type ValidationResult
- type ValidationWarning
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertCatalogsMapToSources ¶
ConvertCatalogsMapToSources converts the old map format to sources slice for testing.
func NewMockSource ¶
NewMockSource creates a direct observation for testing.
Types ¶
type AuthorityStrategy ¶
type AuthorityStrategy struct {
// contains filtered or unexported fields
}
AuthorityStrategy uses field authorities to resolve conflicts.
func NewAuthorityStrategy ¶
func NewAuthorityStrategy(authorities authority.Authority) *AuthorityStrategy
NewAuthorityStrategy creates a new authority-based strategy.
func (*AuthorityStrategy) ApplyStrategy ¶
func (s *AuthorityStrategy) ApplyStrategy() differ.ApplyStrategy
ApplyStrategy returns how changes should be applied.
func (*AuthorityStrategy) Description ¶
func (s *AuthorityStrategy) Description() string
Description returns a human-readable description.
func (*AuthorityStrategy) ResolveConflict ¶
func (s *AuthorityStrategy) ResolveConflict(field string, values map[sources.ID]any) (any, sources.ID, string)
ResolveConflict uses authorities to resolve conflicts.
func (*AuthorityStrategy) ResolveResourceConflict ¶ added in v0.1.0
func (s *AuthorityStrategy) ResolveResourceConflict(resourceType sources.ResourceType, field string, values map[sources.ID]any) (any, sources.ID, string)
ResolveResourceConflict uses resource-specific authorities to resolve conflicts.
func (*AuthorityStrategy) ShouldMerge ¶
func (s *AuthorityStrategy) ShouldMerge(resourceType sources.ResourceType) bool
ShouldMerge determines if resources should be merged.
func (*AuthorityStrategy) Type ¶
func (s *AuthorityStrategy) Type() StrategyType
Type returns the strategy type.
func (*AuthorityStrategy) ValidateResult ¶
ValidateResult validates the reconciliation result.
type Option ¶
type Option func(*options) error
Option is a function that configures a Reconciler.
func WithAuthorities ¶
WithAuthorities sets the field authorities.
func WithBaseline ¶
WithBaseline sets an existing catalog to compare against for change detection.
func WithEnhancers ¶
WithEnhancers adds model enhancers to the pipeline.
func WithProvenance ¶
WithProvenance enables field-level tracking.
func WithStrategy ¶
WithStrategy sets the merge strategy.
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
Reconciler combines data from multiple sources into a canonical catalog. It is concrete because this package has one reconciliation engine; extension points are accepted through the narrow Strategy, Authority, Source, and Enhancer interfaces.
type Result ¶
type Result struct {
// Core data
Catalog *catalogs.Builder
Changeset *differ.Changeset
AppliedChanges *differ.Changeset
// Tracking maps
ProviderAPICounts map[catalogs.ProviderID]int
ModelProviderMap map[string]catalogs.ProviderID
// Metadata
Metadata ResultMetadata
// Provenance tracking
Provenance provenance.Map
// Issues
Errors []error
Warnings []string
}
Result represents the outcome of a reconciliation operation.
func (*Result) Finalize ¶
func (r *Result) Finalize()
Finalize calculates duration and marks completion.
func (*Result) HasChanges ¶
HasChanges returns true if any changes were detected.
func (*Result) WasApplied ¶
WasApplied returns true if changes were applied.
type ResultMetadata ¶
type ResultMetadata struct {
// StartTime when reconciliation started
StartTime time.Time
// EndTime when reconciliation completed
EndTime time.Time
// Duration of the reconciliation
Duration time.Duration
// Sources that were reconciled
Sources []sources.ID
// Strategy used for reconciliation
Strategy Strategy
// DryRun indicates if this was a dry-run
DryRun bool
// Statistics about the reconciliation
Stats ResultStatistics
}
ResultMetadata contains metadata about the reconciliation process.
type ResultStatistics ¶
type ResultStatistics struct {
ModelsProcessed int
ProvidersProcessed int
ConflictsResolved int
ResourcesSkipped int
TotalTimeMs int64
}
ResultStatistics contains statistics about the reconciliation.
type SourceOrderStrategy ¶
type SourceOrderStrategy struct {
// contains filtered or unexported fields
}
SourceOrderStrategy resolves conflicts using a fixed source precedence order. Sources earlier in the priority slice have higher precedence than sources later in the slice.
func NewSourceOrderStrategy ¶
func NewSourceOrderStrategy(priorityOrder []sources.ID) *SourceOrderStrategy
NewSourceOrderStrategy creates a new source priority order strategy. The priorityOrder slice determines precedence: earlier elements have higher priority.
func (*SourceOrderStrategy) ApplyStrategy ¶
func (s *SourceOrderStrategy) ApplyStrategy() differ.ApplyStrategy
ApplyStrategy returns how changes should be applied.
func (*SourceOrderStrategy) Description ¶
func (s *SourceOrderStrategy) Description() string
Description returns a human-readable description.
func (*SourceOrderStrategy) ResolveConflict ¶
func (s *SourceOrderStrategy) ResolveConflict(_ string, values map[sources.ID]any) (any, sources.ID, string)
ResolveConflict uses source priority order to resolve conflicts.
func (*SourceOrderStrategy) ResolveResourceConflict ¶ added in v0.1.0
func (s *SourceOrderStrategy) ResolveResourceConflict(_ sources.ResourceType, _ string, values map[sources.ID]any) (any, sources.ID, string)
ResolveResourceConflict resolves conflicts by source order; resource type does not affect this strategy.
func (*SourceOrderStrategy) ShouldMerge ¶
func (s *SourceOrderStrategy) ShouldMerge(resourceType sources.ResourceType) bool
ShouldMerge determines if resources should be merged.
func (*SourceOrderStrategy) Type ¶
func (s *SourceOrderStrategy) Type() StrategyType
Type returns the strategy type.
func (*SourceOrderStrategy) ValidateResult ¶
ValidateResult validates the reconciliation result.
type Strategy ¶
type Strategy interface {
// Type returns the strategy type
Type() StrategyType
// Description returns a human-readable description
Description() string
// ShouldMerge determines if resources should be merged
ShouldMerge(resourceType sources.ResourceType) bool
// ResolveConflict determines how to resolve conflicts
ResolveConflict(field string, values map[sources.ID]any) (any, sources.ID, string)
// ValidateResult validates the reconciliation result
ValidateResult(result *Result) error
// ApplyStrategy returns how changes should be applied
ApplyStrategy() differ.ApplyStrategy
}
Strategy defines how reconciliation should be performed.
type StrategyType ¶
type StrategyType string
StrategyType represents the type of reconciliation strategy.
const ( // StrategyTypeFieldAuthority uses field-specific authority scores to resolve conflicts. StrategyTypeFieldAuthority StrategyType = "field-authority" // StrategyTypeSourceOrder uses source ordering to resolve conflicts. StrategyTypeSourceOrder StrategyType = "source-order" )
func (StrategyType) Name ¶
func (s StrategyType) Name() string
Name returns the name of the strategy type.
func (StrategyType) String ¶
func (s StrategyType) String() string
String returns the string representation of a strategy type.
type ValidationError ¶
type ValidationError struct {
ResourceType sources.ResourceType
ResourceID string
Field string
Message string
}
ValidationError represents a validation error.
type ValidationResult ¶
type ValidationResult struct {
Valid bool
Errors []ValidationError
Warnings []ValidationWarning
}
ValidationResult represents the result of validating a catalog or changeset.
func (*ValidationResult) HasWarnings ¶
func (v *ValidationResult) HasWarnings() bool
HasWarnings returns true if there are warnings.
func (*ValidationResult) IsValid ¶
func (v *ValidationResult) IsValid() bool
IsValid returns true if validation passed.
func (*ValidationResult) String ¶
func (v *ValidationResult) String() string
String returns a string representation of the validation result.
type ValidationWarning ¶
type ValidationWarning struct {
ResourceType sources.ResourceType
ResourceID string
Field string
Message string
}
ValidationWarning represents a validation warning.