external

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package external provides external model configuration and validation

Index

Constants

View Source
const ExternalTypeSQL = "sql"

ExternalTypeSQL identifies SQL external models

Variables

View Source
var (
	// ErrIntervalRequired is returned when interval configuration is missing
	ErrIntervalRequired = errors.New("interval configuration is required")
	// ErrDatabaseRequired is returned when database is not specified
	ErrDatabaseRequired = errors.New("database is required")
	// ErrTableRequired is returned when table is not specified
	ErrTableRequired = errors.New("table is required")
	// ErrCacheConfigRequired is returned when cache configuration is not specified
	ErrCacheConfigRequired = errors.New("cache configuration is required")
	// ErrInvalidIncrementalInterval is returned when incremental scan interval is invalid
	ErrInvalidIncrementalInterval = errors.New("incremental_scan_interval must be positive")
	// ErrInvalidFullInterval is returned when full scan interval is invalid
	ErrInvalidFullInterval = errors.New("full_scan_interval must be positive")
	// ErrInvalidIntervalOrder is returned when incremental interval is not less than full interval
	ErrInvalidIntervalOrder = errors.New("incremental_scan_interval must be less than full_scan_interval")
	// ErrIntervalTypeRequired is returned when interval.type is not specified
	ErrIntervalTypeRequired = errors.New("interval.type is required")
)
View Source
var (
	// ErrInvalidFrontmatter is returned when frontmatter is invalid
	ErrInvalidFrontmatter = errors.New("invalid frontmatter")
	// ErrSQLContentRequired is returned when SQL content is not specified
	ErrSQLContentRequired = errors.New("sql content is required")
)

Functions

This section is empty.

Types

type CacheConfig added in v0.0.2

type CacheConfig struct {
	IncrementalScanInterval time.Duration `yaml:"incremental_scan_interval"`
	FullScanInterval        time.Duration `yaml:"full_scan_interval"`
}

CacheConfig defines caching configuration for external models

type Config

type Config struct {
	Cluster  string          `yaml:"cluster"`  // Optional, can fall back to default
	Database string          `yaml:"database"` // Optional, can fall back to default
	Table    string          `yaml:"table" validate:"required"`
	Cache    *CacheConfig    `yaml:"cache"`
	Lag      uint64          `yaml:"lag"`
	Interval *IntervalConfig `yaml:"interval" json:"interval"`
}

Config defines configuration for external models

func (*Config) GetID

func (c *Config) GetID() string

GetID returns the unique identifier for the external model

func (*Config) SetDefaults added in v0.0.8

func (c *Config) SetDefaults(defaultCluster, defaultDatabase string)

SetDefaults applies default values to the configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the external configuration is valid

type IntervalConfig added in v0.0.25

type IntervalConfig struct {
	Type string `yaml:"type" json:"type"` // Required: examples: "second", "slot", "epoch", "block"
}

IntervalConfig defines interval configuration for external models

func (IntervalConfig) Validate added in v0.0.25

func (c IntervalConfig) Validate() error

Validate checks if the interval configuration is valid

type SQL

type SQL struct {
	Config  `yaml:",inline"`
	Content string `yaml:"-"`
}

SQL represents an external SQL model with YAML frontmatter

func NewExternalSQL

func NewExternalSQL(content []byte) (*SQL, error)

NewExternalSQL creates a new external SQL model from content

func (*SQL) GetConfig

func (c *SQL) GetConfig() Config

GetConfig returns the external model configuration

func (*SQL) GetConfigMutable added in v0.0.24

func (c *SQL) GetConfigMutable() *Config

GetConfigMutable returns a mutable pointer to the external model configuration

func (*SQL) GetIntervalType added in v0.0.25

func (c *SQL) GetIntervalType() string

GetIntervalType returns the interval type for this external model

func (*SQL) GetType

func (c *SQL) GetType() string

GetType returns the external model type

func (*SQL) GetValue

func (c *SQL) GetValue() string

GetValue returns the SQL content

func (*SQL) SetDefaults added in v0.0.40

func (c *SQL) SetDefaults(defaultCluster, defaultDB string)

SetDefaults applies the default cluster and database if not already set

func (*SQL) Validate

func (c *SQL) Validate() error

Validate checks if the external SQL model is valid

Jump to

Keyboard shortcuts

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