Documentation
¶
Overview ¶
Package validation provides dependency validation for CBT models
Package validation provides dependency validation for CBT models
Index ¶
- Variables
- type ExternalModelValidator
- type ExternalValidator
- type FlexUint64
- type MockValidator
- func (m *MockValidator) AssertValidateCalledWith(modelID string, position, interval uint64) bool
- func (m *MockValidator) GetEarliestPosition(ctx context.Context, modelID string) (uint64, error)
- func (m *MockValidator) GetInitialPosition(ctx context.Context, modelID string) (uint64, error)
- func (m *MockValidator) GetValidRange(ctx context.Context, modelID string) (minPos, maxPos uint64, err error)
- func (m *MockValidator) GetValidateCallCount() int
- func (m *MockValidator) Reset()
- func (m *MockValidator) ValidateDependencies(ctx context.Context, modelID string, position, interval uint64) (Result, error)
- type Result
- type ValidateCall
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotSQLModel is returned when external model is not a SQL model ErrNotSQLModel = errors.New("external model is not a SQL model") // ErrInvalidUint64 is returned when a value cannot be unmarshaled as uint64 ErrInvalidUint64 = errors.New("failed to unmarshal value as uint64") )
var ( ErrModelNotFound = errors.New("model not found") ErrDependencyNotFound = errors.New("dependency model not found") ErrRangeNotAvailable = errors.New("required range not available") ErrRangeNotCovered = errors.New("range not fully covered") ErrNotTransformationModel = errors.New("model is not a transformation") ErrInvalidDependencyType = errors.New("invalid dependency type") ErrInvalidModelType = errors.New("invalid dependency model type") ErrFailedModelCast = errors.New("failed to cast model to transformation") ErrInsufficientRange = errors.New("insufficient dependency range for interval") )
Validation-specific errors
Functions ¶
This section is empty.
Types ¶
type ExternalModelValidator ¶
type ExternalModelValidator struct {
// contains filtered or unexported fields
}
ExternalModelValidator implements the ExternalModelExecutor interface
func NewExternalModelExecutor ¶
func NewExternalModelExecutor(log logrus.FieldLogger, chClient clickhouse.ClientInterface, adminService admin.Service, modelsService models.Service) *ExternalModelValidator
NewExternalModelExecutor creates a new external model executor The cacheManager can be nil if caching is not desired
type ExternalValidator ¶ added in v0.0.2
type ExternalValidator interface {
GetMinMax(ctx context.Context, model models.External) (uint64, uint64, error)
}
ExternalValidator defines the interface for external model validation
type FlexUint64 ¶ added in v0.0.2
type FlexUint64 uint64
FlexUint64 is a custom type that can unmarshal from both string and number JSON values
func (*FlexUint64) UnmarshalJSON ¶ added in v0.0.2
func (f *FlexUint64) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for FlexUint64
type MockValidator ¶ added in v0.0.2
type MockValidator struct {
// Control behavior
ValidateDependenciesFunc func(ctx context.Context, modelID string, position, interval uint64) (Result, error)
GetInitialPositionFunc func(ctx context.Context, modelID string) (uint64, error)
GetEarliestPositionFunc func(ctx context.Context, modelID string) (uint64, error)
GetValidRangeFunc func(ctx context.Context, modelID string) (uint64, uint64, error)
// Track calls for assertions
ValidateCalls []ValidateCall
InitialCalls []string
EarliestCalls []string
ValidRangeCalls []string
// contains filtered or unexported fields
}
MockValidator is a mock implementation of Validator for testing
func NewMockValidator ¶ added in v0.0.2
func NewMockValidator() *MockValidator
NewMockValidator creates a new mock validator
func (*MockValidator) AssertValidateCalledWith ¶ added in v0.0.2
func (m *MockValidator) AssertValidateCalledWith(modelID string, position, interval uint64) bool
AssertValidateCalledWith checks if ValidateDependencies was called with specific args
func (*MockValidator) GetEarliestPosition ¶ added in v0.0.2
GetEarliestPosition implements Validator
func (*MockValidator) GetInitialPosition ¶ added in v0.0.2
GetInitialPosition implements Validator
func (*MockValidator) GetValidRange ¶ added in v0.0.2
func (m *MockValidator) GetValidRange(ctx context.Context, modelID string) (minPos, maxPos uint64, err error)
GetValidRange implements Validator
func (*MockValidator) GetValidateCallCount ¶ added in v0.0.2
func (m *MockValidator) GetValidateCallCount() int
GetValidateCallCount returns the number of ValidateDependencies calls
func (*MockValidator) Reset ¶ added in v0.0.2
func (m *MockValidator) Reset()
Reset clears all recorded calls
func (*MockValidator) ValidateDependencies ¶ added in v0.0.2
func (m *MockValidator) ValidateDependencies(ctx context.Context, modelID string, position, interval uint64) (Result, error)
ValidateDependencies implements Validator
type ValidateCall ¶ added in v0.0.2
ValidateCall records a ValidateDependencies call
type Validator ¶ added in v0.0.2
type Validator interface {
// ValidateDependencies checks if all dependencies are satisfied for a given position
ValidateDependencies(ctx context.Context, modelID string, position, interval uint64) (Result, error)
// GetInitialPosition calculates the initial position for a model based on its dependencies
GetInitialPosition(ctx context.Context, modelID string) (uint64, error)
// GetEarliestPosition gets the earliest available position for a model
GetEarliestPosition(ctx context.Context, modelID string) (uint64, error)
// GetValidRange returns the valid position range [min, max] for a model based on its dependencies
// min = MAX(MIN(external_mins), MAX(transformation_mins))
// max = MIN(MAX(external_maxs), MIN(transformation_maxs))
GetValidRange(ctx context.Context, modelID string) (minPos, maxPos uint64, err error)
}
Validator defines the interface for dependency validation (ethPandaOps pattern)
func NewDependencyValidator ¶
func NewDependencyValidator( log logrus.FieldLogger, chClient clickhouse.ClientInterface, adminService admin.Service, modelsService models.Service, ) Validator
NewDependencyValidator creates a new dependency validator