server

package
v0.0.0-edge.10.a154347 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MetricsJobID = "__metrics__"

MetricsJobID is the sentinel job ID used for the merged metrics query.

Variables

This section is empty.

Functions

func FanoutMetricResults

func FanoutMetricResults(results map[string]*WidgetQueryResult, merged *WidgetQueryResult, j WidgetJob, d *dashboard.Dashboard)

FanoutMetricResults splits a merged metrics query result into individual widget results and adds them to the results map.

func WidgetID

func WidgetID(rowIdx, widgetIdx int) string

WidgetID returns the canonical widget identifier for a given row and widget index.

Types

type Config

type Config struct {
	Host          string
	Port          int
	DashboardDir  string
	TemplateName  string
	ConfigFile    string
	Environment   string
	AdminPassword string
	AgentEffort   string // reasoning effort for agent turns: "low", "medium", "high"
	Frontend      fs.FS  // embedded frontend files, nil for dev mode
}

Config holds server configuration.

type DashboardSummary

type DashboardSummary struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Connection  string `json:"connection,omitempty"`
	WidgetCount int    `json:"widget_count"`
	FilterCount int    `json:"filter_count"`
	RowCount    int    `json:"row_count"`
}

DashboardSummary is a lightweight representation of a dashboard for listing.

func MakeDashboardSummary

func MakeDashboardSummary(d *dashboard.Dashboard) DashboardSummary

MakeDashboardSummary creates a DashboardSummary from a Dashboard.

type DraftInfo

type DraftInfo struct {
	DraftID       string // short random ID (e.g. "a1b2c3d4")
	DashboardName string // original dashboard name
	DraftPath     string // path to the draft file (dot-prefixed in dashboard dir)
	OriginalPath  string // path to the original live file
}

DraftInfo tracks a draft copy of a dashboard.

type Invalidator

type Invalidator interface {
	Invalidate()
}

Invalidator is called when dashboard files change to clear stale data.

type Server

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

Server is the dac HTTP server.

func New

func New(cfg Config) (*Server, error)

New creates a new server instance.

func (*Server) Start

func (s *Server) Start() error

Start begins listening and serving. It tries the configured port first, then increments until it finds an available one.

type Watcher

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

Watcher monitors dashboard files for changes and broadcasts SSE events.

func NewWatcher

func NewWatcher(dirs ...string) (*Watcher, error)

NewWatcher creates file watchers for the given directories.

func (*Watcher) Run

func (w *Watcher) Run()

Run starts processing file system events. Call in a goroutine.

type WidgetJob

type WidgetJob struct {
	ID         string
	SQL        string
	Connection string
	// MetricFanout is set on the merged metrics job: maps widget ID -> metric name.
	// When set, the single query result is fanned out to multiple widget results.
	MetricFanout map[string]string
}

WidgetJob represents a single SQL query to execute for a dashboard widget.

func ResolveWidgetJobs

func ResolveWidgetJobs(d *dashboard.Dashboard, filters map[string]any) ([]WidgetJob, error)

ResolveWidgetJobs builds the list of SQL jobs for all data-bearing widgets in a dashboard, including declarative metric and dimensional widgets.

Metric-ref widgets are merged into a single query to avoid redundant table scans. The merged result is then split into per-widget results via metricsJobGroup.

type WidgetQueryResult

type WidgetQueryResult struct {
	Columns []struct {
		Name string `json:"name"`
		Type string `json:"type,omitempty"`
	} `json:"columns"`
	Rows  [][]any `json:"rows"`
	Query string  `json:"query,omitempty"`
	Error string  `json:"error,omitempty"`
}

WidgetQueryResult holds the result of executing a widget's SQL query.

func ExecuteWidgetQuery

func ExecuteWidgetQuery(ctx context.Context, backend query.Backend, j WidgetJob) *WidgetQueryResult

ExecuteWidgetQuery runs a single widget SQL query against the given backend.

func FanoutSingleMetric

func FanoutSingleMetric(merged *WidgetQueryResult, metricRef string, sql string, d *dashboard.Dashboard) *WidgetQueryResult

FanoutSingleMetric extracts a single metric's value from a merged query result. For aggregate metrics, it picks the column by name. For expression metrics, it evaluates the expression client-side from the aggregate values.

Jump to

Keyboard shortcuts

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