Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyEnvVars(dsn string) (string, error)
- func CheckDBExists(ctx context.Context, db *db.Pool, name string, dsType types.DataSourceType) error
- func EnsurePgDatabase(ctx context.Context, host, port, user, password, dbName string) error
- func EscapeSQLString(s string) string
- type DataSourceResolver
- type EmbeddingResult
- type EmbeddingSource
- type EmbeddingsResult
- type ExtensionSource
- type HeartbeatConfig
- type Heartbeater
- type LLMMessage
- type LLMOptions
- type LLMResult
- type LLMSource
- type LLMStreamEvent
- type LLMStreamingSource
- type LLMTool
- type LLMToolCall
- type ModelInfo
- type ModelSource
- type ParsedDSN
- type Provisioner
- type PubSubStoreSource
- type Querier
- type RuntimeSource
- type RuntimeSourceDataSourceUser
- type RuntimeSourceQuerier
- type SelfDescriber
- type Source
- type SourceDataSourceUser
- type StoreSource
- type SubscriptionResult
- type SubscriptionSource
Constants ¶
const ( Postgres types.DataSourceType = "postgres" DuckDB types.DataSourceType = "duckdb" MySQL types.DataSourceType = "mysql" MSSQL types.DataSourceType = "mssql" Http types.DataSourceType = "http" Runtime types.DataSourceType = "runtime" Extension types.DataSourceType = "extension" Embedding types.DataSourceType = "embedding" Airport types.DataSourceType = "airport" DuckLake types.DataSourceType = "ducklake" Iceberg types.DataSourceType = "iceberg" HugrApp types.DataSourceType = "hugr-app" LLMOpenAI types.DataSourceType = "llm-openai" LLMAnthropic types.DataSourceType = "llm-anthropic" LLMGemini types.DataSourceType = "llm-gemini" Redis types.DataSourceType = "redis" )
Variables ¶
var ( ErrDataSourceNotFound = errors.New("data source not found") ErrDataSourceExists = errors.New("data source already exists") ErrDataSourceAttached = errors.New("data source is attached") ErrDataSourceNotAttached = errors.New("data source is not attached") ErrUnknownDataSourceType = errors.New("unknown data source type") ErrDataSourceAttachedWithDifferentType = errors.New("data source already attached with different type exists") ErrEmptyQuery = errors.New("empty query") ErrQueryParsingFailed = errors.New("query parsing failed") ErrInvalidDataSourcePath = errors.New("invalid data source path") )
Functions ¶
func ApplyEnvVars ¶ added in v0.1.9
func CheckDBExists ¶
func EnsurePgDatabase ¶ added in v0.3.3
EnsurePgDatabase connects to the PostgreSQL "postgres" maintenance database and creates the target database if it doesn't exist. This is idempotent — it does nothing if the database already exists.
NOTE: The connection to the maintenance database uses sslmode=disable because it targets the same PostgreSQL instance as the main DuckLake connection. In production, the DuckLake PostgreSQL backend should be co-located (same network) with the Hugr query engine, so TLS is not required for the maintenance connection. If your PostgreSQL instance requires TLS, do not use ensure_db — create the database manually instead.
func EscapeSQLString ¶ added in v0.3.3
EscapeSQLString escapes single quotes in SQL string literals by doubling them.
Types ¶
type DataSourceResolver ¶ added in v0.3.16
DataSourceResolver resolves registered data sources by name.
type EmbeddingResult ¶ added in v0.3.16
type EmbeddingResult = types.EmbeddingResult
Type aliases for convenience — re-export from types sub-module.
type EmbeddingSource ¶ added in v0.1.28
type EmbeddingSource interface {
ModelSource
CreateEmbedding(ctx context.Context, input string) (*types.EmbeddingResult, error)
CreateEmbeddings(ctx context.Context, input []string) (*types.EmbeddingsResult, error)
}
type EmbeddingsResult ¶ added in v0.3.16
type EmbeddingsResult = types.EmbeddingsResult
Type aliases for convenience — re-export from types sub-module.
type ExtensionSource ¶ added in v0.1.12
type ExtensionSource interface {
IsExtension() bool
}
The data source is a catalog extension.
type HeartbeatConfig ¶ added in v0.3.11
HeartbeatConfig holds heartbeat monitoring settings.
type Heartbeater ¶ added in v0.3.11
type Heartbeater interface {
StartHeartbeat(
config HeartbeatConfig,
onSuspend func(ctx context.Context, name string) error,
onRecover func(ctx context.Context, name string) error,
)
StopHeartbeat()
}
Heartbeater is implemented by sources that need periodic health monitoring. The service calls StartHeartbeat after successful Attach and StopHeartbeat before Detach.
type LLMMessage ¶ added in v0.3.16
type LLMMessage = types.LLMMessage
Type aliases for convenience — re-export from types sub-module.
type LLMOptions ¶ added in v0.3.16
type LLMOptions = types.LLMOptions
Type aliases for convenience — re-export from types sub-module.
type LLMSource ¶ added in v0.3.16
type LLMSource interface {
ModelSource
CreateCompletion(ctx context.Context, prompt string, opts types.LLMOptions) (*types.LLMResult, error)
CreateChatCompletion(ctx context.Context, messages []types.LLMMessage, opts types.LLMOptions) (*types.LLMResult, error)
}
LLMSource provides text generation capabilities.
type LLMStreamEvent ¶ added in v0.3.20
type LLMStreamEvent = types.LLMStreamEvent
Type alias for LLMStreamEvent convenience.
type LLMStreamingSource ¶ added in v0.3.20
type LLMStreamingSource interface {
LLMSource
CreateChatCompletionStream(ctx context.Context, messages []types.LLMMessage, opts types.LLMOptions,
onEvent func(event *types.LLMStreamEvent) error) error
}
LLMStreamingSource extends LLMSource with streaming completion support.
type LLMToolCall ¶ added in v0.3.16
type LLMToolCall = types.LLMToolCall
Type aliases for convenience — re-export from types sub-module.
type ModelSource ¶ added in v0.3.16
ModelSource identifies a data source as an AI model.
type ParsedDSN ¶
type Provisioner ¶ added in v0.3.11
Provisioner is implemented by sources that need to provision external resources (databases, schemas) after attachment. Called by the data source service after Attach() succeeds. Querier provides access to hugr's GraphQL API for registering/loading data sources and querying system configuration.
type PubSubStoreSource ¶ added in v0.3.20
type PubSubStoreSource interface {
StoreSource
Subscribe(ctx context.Context, channel string) (*SubscriptionResult, error)
PSubscribe(ctx context.Context, pattern string) (*SubscriptionResult, error)
Publish(ctx context.Context, channel string, message string) error
ConfigGet(ctx context.Context, key string) (string, error)
ConfigSet(ctx context.Context, key string, value string) error
}
PubSubStoreSource extends StoreSource with Pub/Sub capabilities.
type RuntimeSource ¶
type RuntimeSource interface {
Name() string
Engine() engines.Engine
IsReadonly() bool
AsModule() bool
Attach(ctx context.Context, db *db.Pool) error
Catalog(ctx context.Context) (cs.Catalog, error)
}
RuntimeSource is a data source that is attached on start and provides a catalog source.
type RuntimeSourceDataSourceUser ¶ added in v0.3.16
type RuntimeSourceDataSourceUser interface {
DataSourceServiceSetup(resolver DataSourceResolver)
}
RuntimeSourceDataSourceUser is implemented by runtime sources that need access to registered data sources. Follows RuntimeSourceQuerier pattern.
type RuntimeSourceQuerier ¶
type SelfDescriber ¶
type SourceDataSourceUser ¶ added in v0.3.16
type SourceDataSourceUser interface {
SetDataSourceResolver(resolver DataSourceResolver)
}
SourceDataSourceUser is implemented by regular (non-runtime) data sources that need access to other data sources (e.g., LLM sources needing Redis for rate limiting).
type StoreSource ¶ added in v0.3.16
type StoreSource interface {
Get(ctx context.Context, key string) (string, bool, error)
Set(ctx context.Context, key string, value string, ttlSeconds int) error
Del(ctx context.Context, key string) error
Incr(ctx context.Context, key string) (int64, error)
IncrBy(ctx context.Context, key string, value int64) (int64, error)
Expire(ctx context.Context, key string, ttlSeconds int) error
Keys(ctx context.Context, pattern string) ([]string, error)
}
StoreSource provides key-value store operations. Named StoreSource (not RedisSource) to allow future non-Redis implementations.
type SubscriptionResult ¶ added in v0.3.20
type SubscriptionResult struct {
Reader array.RecordReader // Yields records incrementally; schema included.
Cancel func() // Stops the subscription.
}
SubscriptionResult is returned by SubscriptionSource.Subscribe.
type SubscriptionSource ¶ added in v0.3.20
type SubscriptionSource interface {
Subscribe(ctx context.Context, field *ast.Field, vars map[string]any) (*SubscriptionResult, error)
}
SubscriptionSource is implemented by data sources that handle native subscriptions.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package llm implements LLM data source types for AI model providers.
|
Package llm implements LLM data source types for AI model providers. |
|
Package ratelimit provides request and token rate limiting for LLM sources.
|
Package ratelimit provides request and token rate limiting for LLM sources. |