Documentation
¶
Index ¶
- Constants
- func RegisterSchemaResources(log logrus.FieldLogger, reg module.ResourceRegistry, ...)
- type ClickHouseSchemaClient
- type ClickHouseSchemaConfig
- type ClusterTables
- type ClusterTablesSummary
- type Config
- type Module
- func (p *Module) ApplyDefaults()
- func (p *Module) DatasourceInfo() []types.DatasourceInfo
- func (p *Module) Examples() map[string]types.ExampleCategory
- func (p *Module) GettingStartedSnippet() string
- func (p *Module) Init(rawConfig []byte) error
- func (p *Module) InitFromDiscovery(datasources []types.DatasourceInfo) error
- func (p *Module) Name() string
- func (p *Module) PythonAPIDocs() map[string]types.ModuleDoc
- func (p *Module) RegisterResources(log logrus.FieldLogger, reg module.ResourceRegistry) error
- func (p *Module) SandboxEnv() (map[string]string, error)
- func (p *Module) SchemaClient() ClickHouseSchemaClient
- func (p *Module) SetProxyClient(client proxy.Service)
- func (p *Module) Start(ctx context.Context) error
- func (p *Module) Stop(_ context.Context) error
- func (p *Module) Validate() error
- type SchemaDiscoveryConfig
- type SchemaDiscoveryDatasource
- type TableColumn
- type TableDetailResponse
- type TableSchema
- type TableSummary
- type TablesListResponse
Constants ¶
const ( // DefaultSchemaRefreshInterval is the refresh interval for schema discovery. DefaultSchemaRefreshInterval = 15 * time.Minute // DefaultSchemaQueryTimeout is the timeout for individual schema queries. DefaultSchemaQueryTimeout = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func RegisterSchemaResources ¶
func RegisterSchemaResources( log logrus.FieldLogger, reg module.ResourceRegistry, client ClickHouseSchemaClient, )
RegisterSchemaResources registers ClickHouse schema resources with the registry.
Types ¶
type ClickHouseSchemaClient ¶
type ClickHouseSchemaClient interface {
// Start initializes the client and fetches initial schema data.
Start(ctx context.Context) error
// Stop stops background refresh.
Stop() error
// WaitForReady blocks until the initial schema fetch completes or ctx is cancelled.
WaitForReady(ctx context.Context) error
// GetAllTables returns all tables across all clusters.
GetAllTables() map[string]*ClusterTables
// GetTable returns schema for a specific table (searches all clusters).
GetTable(tableName string) (*TableSchema, string, bool)
}
ClickHouseSchemaClient fetches and caches ClickHouse schema information.
func NewClickHouseSchemaClient ¶
func NewClickHouseSchemaClient( log logrus.FieldLogger, cfg ClickHouseSchemaConfig, proxySvc proxy.Service, ) ClickHouseSchemaClient
NewClickHouseSchemaClient creates a new schema discovery client.
type ClickHouseSchemaConfig ¶
type ClickHouseSchemaConfig struct {
RefreshInterval time.Duration
QueryTimeout time.Duration
Datasources []SchemaDiscoveryDatasource
}
ClickHouseSchemaConfig holds configuration for schema discovery.
type ClusterTables ¶
type ClusterTables struct {
ClusterName string `json:"cluster_name"`
Tables map[string]*TableSchema `json:"tables"`
LastUpdated time.Time `json:"last_updated"`
}
ClusterTables represents tables available in a ClickHouse cluster.
type ClusterTablesSummary ¶
type ClusterTablesSummary struct {
Tables []*TableSummary `json:"tables"`
TableCount int `json:"table_count"`
LastUpdated string `json:"last_updated"`
}
ClusterTablesSummary is a compact summary of tables in a cluster.
type Config ¶
type Config struct {
SchemaDiscovery SchemaDiscoveryConfig `yaml:"schema_discovery"`
}
Config holds the ClickHouse module configuration.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the module.Module interface for ClickHouse.
func (*Module) ApplyDefaults ¶
func (p *Module) ApplyDefaults()
ApplyDefaults sets default values before validation.
func (*Module) DatasourceInfo ¶
func (p *Module) DatasourceInfo() []types.DatasourceInfo
DatasourceInfo returns datasource metadata for datasources:// resources.
func (*Module) Examples ¶
func (p *Module) Examples() map[string]types.ExampleCategory
Examples returns query examples for the ClickHouse module.
func (*Module) GettingStartedSnippet ¶
GettingStartedSnippet returns ClickHouse-specific getting-started content.
func (*Module) InitFromDiscovery ¶
func (p *Module) InitFromDiscovery(datasources []types.DatasourceInfo) error
InitFromDiscovery initializes the module from discovered datasources.
func (*Module) PythonAPIDocs ¶
PythonAPIDocs returns the ClickHouse module documentation.
func (*Module) RegisterResources ¶
func (p *Module) RegisterResources(log logrus.FieldLogger, reg module.ResourceRegistry) error
RegisterResources registers ClickHouse schema resources.
func (*Module) SandboxEnv ¶
SandboxEnv returns environment variables for the sandbox.
func (*Module) SchemaClient ¶
func (p *Module) SchemaClient() ClickHouseSchemaClient
SchemaClient returns the schema discovery client, or nil if not initialized.
func (*Module) SetProxyClient ¶
SetProxyClient injects the proxy service for schema discovery.
type SchemaDiscoveryConfig ¶
type SchemaDiscoveryConfig struct {
// Enabled controls whether schema discovery is active. Defaults to true if datasources are configured.
Enabled *bool `yaml:"enabled,omitempty"`
// RefreshInterval is the duration between schema refresh cycles. Defaults to 15 minutes.
RefreshInterval time.Duration `yaml:"refresh_interval,omitempty"`
// Datasources lists the ClickHouse datasources to discover schemas from.
// Each entry references a proxy-exposed datasource by name.
// If empty, all proxy datasources are used.
Datasources []SchemaDiscoveryDatasource `yaml:"datasources"`
}
SchemaDiscoveryConfig holds configuration for ClickHouse schema discovery.
func (*SchemaDiscoveryConfig) IsEnabled ¶
func (c *SchemaDiscoveryConfig) IsEnabled() bool
IsEnabled returns whether schema discovery is enabled. Defaults to true; set enabled=false to disable explicitly.
type SchemaDiscoveryDatasource ¶
type SchemaDiscoveryDatasource struct {
// Name references a ClickHouse datasource by its proxy name.
Name string `yaml:"name"`
// Cluster is the logical cluster name used in schema resources (e.g., "xatu", "xatu-cbt").
// Defaults to Name when empty.
Cluster string `yaml:"cluster"`
}
SchemaDiscoveryDatasource maps a proxy datasource name to a logical cluster name for schema discovery.
type TableColumn ¶
type TableColumn struct {
Name string `json:"name"`
Type string `json:"type"`
Comment string `json:"comment,omitempty"`
DefaultType string `json:"default_type,omitempty"`
DefaultValue string `json:"default_value,omitempty"`
}
TableColumn represents a column in a ClickHouse table.
type TableDetailResponse ¶
type TableDetailResponse struct {
Table *TableSchema `json:"table"`
Cluster string `json:"cluster"`
}
TableDetailResponse is the response for clickhouse://tables/{table_name}.
type TableSchema ¶
type TableSchema struct {
Name string `json:"name"`
Engine string `json:"engine,omitempty"`
Columns []TableColumn `json:"columns"`
Networks []string `json:"networks,omitempty"`
HasNetworkCol bool `json:"has_network_column"`
CreateStatement string `json:"create_statement,omitempty"`
Comment string `json:"comment,omitempty"`
}
TableSchema represents the full schema of a ClickHouse table.
type TableSummary ¶
type TableSummary struct {
Name string `json:"name"`
ColumnCount int `json:"column_count"`
HasNetworkCol bool `json:"has_network_column"`
}
TableSummary is a compact overview of a table for the list view. Use clickhouse://tables/{table_name} for detailed schema including networks.
type TablesListResponse ¶
type TablesListResponse struct {
Description string `json:"description"`
Clusters map[string]*ClusterTablesSummary `json:"clusters"`
Usage string `json:"usage"`
}
TablesListResponse is the response for clickhouse://tables.