Help us shape the future of Go! Take the 2026 Go Developer Survey

hugrapp

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvisionDataSources

func ProvisionDataSources(
	ctx context.Context,
	pool *db.Pool,
	appSource *Source,
	querier Querier,
	tmplParams TemplateParams,
) error

ProvisionDataSources reads data sources from _mount.data_sources, cleans up stale registrations, ensures DB schemas, then registers and loads all DS. Two-pass approach:

  1. ensureDB for PostgreSQL sources (create tables, migrate)
  2. register + load all sources (any type)

Types

type AppInfo

type AppInfo struct {
	Name            string
	Description     string
	Version         string
	URI             string
	IsDBInitializer bool
	IsDBMigrator    bool
}

AppInfo holds metadata returned by _mount.info() from a hugr-app source.

type DataSourceInfo

type DataSourceInfo struct {
	Name        string
	Type        string
	Description string
	ReadOnly    bool
	Path        string
	Version     string
	HugrSchema  string
}

DataSourceInfo holds a data source declared by a hugr-app.

type HeartbeatConfig

type HeartbeatConfig = sources.HeartbeatConfig

HeartbeatConfig is an alias for sources.HeartbeatConfig.

func DefaultHeartbeatConfig

func DefaultHeartbeatConfig() HeartbeatConfig

DefaultHeartbeatConfig returns the default heartbeat configuration.

type Querier

type Querier = sources.Querier

Querier is sources.Querier — provides GraphQL query access.

type Source

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

Source implements the hugr-app data source type. It connects to an external application via DuckDB Airport extension and manages its lifecycle (heartbeat, DB provisioning, schema mounting).

func New

func New(ds types.DataSource, attached bool) (*Source, error)

New creates a new hugr-app source.

func (*Source) Attach

func (s *Source) Attach(ctx context.Context, pool *db.Pool) error

Attach implements sources.Source.

func (*Source) CatalogSource

func (s *Source) CatalogSource(ctx context.Context, pool *db.Pool) (cs.Catalog, error)

CatalogSource implements sources.SelfDescriber by reading _mount.schema_sdl() from the attached hugr-app and parsing the returned GraphQL SDL.

func (*Source) Definition

func (s *Source) Definition() types.DataSource

Definition implements sources.Source.

func (*Source) Detach

func (s *Source) Detach(ctx context.Context, pool *db.Pool) error

Detach implements sources.Source.

func (*Source) Engine

func (s *Source) Engine() engines.Engine

Engine implements sources.Source.

func (*Source) Info

func (s *Source) Info() *AppInfo

Info returns the cached app info read from _mount.info() after attach.

func (*Source) IsAttached

func (s *Source) IsAttached() bool

IsAttached implements sources.Source.

func (*Source) Name

func (s *Source) Name() string

Name implements sources.Source.

func (*Source) Provision

func (s *Source) Provision(ctx context.Context, querier sources.Querier) error

Provision implements sources.Provisioner. Called by the data source service after Attach() succeeds. Reads _mount.data_sources, registers/initializes/migrates app databases. Template params (VectorSize, EmbedderName) are queried from system config via Querier.

func (*Source) ReadOnly

func (s *Source) ReadOnly() bool

ReadOnly implements sources.Source.

func (*Source) StartHeartbeat

func (s *Source) StartHeartbeat(
	config HeartbeatConfig,
	onSuspend func(ctx context.Context, name string) error,
	onRecover func(ctx context.Context, name string) error,
)

StartHeartbeat starts periodic health monitoring. onSuspend is called when the app becomes unreachable. onRecover is called when a suspended app becomes reachable again.

func (*Source) StopHeartbeat

func (s *Source) StopHeartbeat()

StopHeartbeat stops the heartbeat monitor and waits for it to finish.

type TemplateParams

type TemplateParams struct {
	VectorSize   int    // Embedding vector dimension (0 = no embeddings)
	EmbedderName string // Name of the system embedder (empty = not configured)
}

TemplateParams holds system-level parameters available for Go template expansion in app's SQL (init/migrate) and SDL (HugrSchema). Follows the same pattern as CoreDB's SchemaTemplateParams.

Jump to

Keyboard shortcuts

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