module

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package module defines the base lifecycle contract for built-in integrations plus optional capability interfaces for docs, resources, sandbox env, and datasource metadata.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoValidConfig = errors.New("no valid configuration entries")

ErrNoValidConfig indicates that a module was configured but has no valid entries (e.g., all clusters/instances have empty required fields). This is not an error - the module should be skipped gracefully.

Functions

This section is empty.

Types

type CartographoorAware

type CartographoorAware interface {
	SetCartographoorClient(client cartographoor.CartographoorClient)
}

CartographoorAware is an optional interface for modules that need network discovery data.

type DatasourceInfoProvider

type DatasourceInfoProvider interface {
	DatasourceInfo() []types.DatasourceInfo
}

DatasourceInfoProvider contributes datasource metadata for datasources:// resources.

type DefaultEnabled

type DefaultEnabled interface {
	// DefaultEnabled returns true if the module should be initialized
	// without explicit config in the config file.
	DefaultEnabled() bool
}

DefaultEnabled is an optional interface that modules can implement to indicate they should be initialized even without explicit config. This is useful for modules like dora that work with discovered data and require no user configuration.

type EnabledAware

type EnabledAware interface {
	Enabled() bool
}

EnabledAware is an optional interface for modules that can be initialized but still disabled via config.

type ExamplesProvider

type ExamplesProvider interface {
	Examples() map[string]types.ExampleCategory
}

ExamplesProvider contributes search examples and examples:// resources.

type GettingStartedSnippetProvider

type GettingStartedSnippetProvider interface {
	GettingStartedSnippet() string
}

GettingStartedSnippetProvider contributes snippets to the getting-started resource.

type Module

type Module interface {
	// Name returns the module identifier (e.g. "clickhouse").
	Name() string

	// Init parses the raw YAML config section for this module.
	Init(rawConfig []byte) error

	// ApplyDefaults sets default values before validation.
	ApplyDefaults()

	// Validate checks that the parsed config is valid.
	Validate() error

	// Start performs async initialization (e.g. schema discovery).
	Start(ctx context.Context) error

	// Stop cleans up resources.
	Stop(ctx context.Context) error
}

Module is the minimal lifecycle/config contract for built-in integrations. Optional capabilities are expressed through the provider interfaces above.

type ProxyAware

type ProxyAware interface {
	SetProxyClient(client proxy.Service)
}

ProxyAware is an optional interface for modules that need raw proxy access.

type ProxyDiscoverable

type ProxyDiscoverable interface {
	// InitFromDiscovery initializes the module from discovered datasources.
	// Returns ErrNoValidConfig if no relevant datasources exist.
	InitFromDiscovery(datasources []types.DatasourceInfo) error
}

ProxyDiscoverable modules initialize from datasources discovered via the proxy.

type PythonAPIDocsProvider

type PythonAPIDocsProvider interface {
	PythonAPIDocs() map[string]types.ModuleDoc
}

PythonAPIDocsProvider contributes Python module docs.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry tracks all compiled-in modules and which ones are initialized (have config and passed Init/Validate).

func NewRegistry

func NewRegistry(log logrus.FieldLogger) *Registry

NewRegistry creates a new module registry.

func (*Registry) Add

func (r *Registry) Add(ext Module)

Add registers a compiled-in module by name. This does not initialize the module; call InitModule for that.

func (*Registry) All

func (r *Registry) All() []string

All returns the names of all compiled-in modules.

func (*Registry) DatasourceInfo

func (r *Registry) DatasourceInfo() []types.DatasourceInfo

DatasourceInfo aggregates datasource info from all initialized modules.

func (*Registry) Examples

func (r *Registry) Examples() map[string]types.ExampleCategory

Examples aggregates query examples from all initialized modules.

func (*Registry) Get

func (r *Registry) Get(name string) Module

Get returns a module by name, or nil if not found.

func (*Registry) GettingStartedSnippets

func (r *Registry) GettingStartedSnippets() string

GettingStartedSnippets aggregates getting-started snippets from all initialized modules.

func (*Registry) InitModule

func (r *Registry) InitModule(name string, rawConfig []byte) error

InitModule initializes a module with the given raw YAML config. It calls Init, ApplyDefaults, and Validate in sequence. Returns ErrNoValidConfig if the module has no valid configuration entries, which should be handled by the caller as a graceful skip.

func (*Registry) InitModuleFromDiscovery

func (r *Registry) InitModuleFromDiscovery(name string, datasources []types.DatasourceInfo) error

InitModuleFromDiscovery initializes a module from discovered datasources. The module must implement ProxyDiscoverable.

func (*Registry) Initialized

func (r *Registry) Initialized() []Module

Initialized returns all modules that passed Init/Validate.

func (*Registry) IsInitialized

func (r *Registry) IsInitialized(name string) bool

IsInitialized reports whether the named module was initialized successfully.

func (*Registry) PythonAPIDocs

func (r *Registry) PythonAPIDocs() map[string]types.ModuleDoc

PythonAPIDocs aggregates Python API docs from all initialized modules.

func (*Registry) SandboxEnv

func (r *Registry) SandboxEnv() (map[string]string, error)

SandboxEnv aggregates sandbox environment variables from all initialized modules.

func (*Registry) StartAll

func (r *Registry) StartAll(ctx context.Context) error

StartAll starts all initialized modules.

func (*Registry) StopAll

func (r *Registry) StopAll(ctx context.Context)

StopAll stops all initialized modules.

type ResourceProvider

type ResourceProvider interface {
	RegisterResources(log logrus.FieldLogger, reg ResourceRegistry) error
}

ResourceProvider contributes custom MCP resources.

type ResourceRegistry

type ResourceRegistry interface {
	RegisterStatic(res types.StaticResource)
	RegisterTemplate(res types.TemplateResource)
}

ResourceRegistry is the interface modules use to register MCP resources. This avoids a circular dependency between module and resource packages. pkg/resource.Registry satisfies this interface.

type SandboxEnvProvider

type SandboxEnvProvider interface {
	SandboxEnv() (map[string]string, error)
}

SandboxEnvProvider contributes sandbox environment variables.

Jump to

Keyboard shortcuts

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