Documentation
¶
Overview ¶
Package diagnostics defines read-only runtime inspection contracts for Atlas.
Index ¶
- func ValidateReadOnlySQL(sql string) error
- type BrowserLogEntry
- type BrowserLogRequest
- type Column
- type DatabaseConnection
- type DatabaseSchema
- type Index
- type LogEntry
- type LogRequest
- type MetricsMetadata
- type MetricsMetadataRequest
- type Provider
- type QueryRequest
- type QueryResult
- type StaticProvider
- func (p StaticProvider) AbsoluteURL(_ context.Context, req URLRequest) (string, error)
- func (p StaticProvider) BrowserLogs(_ context.Context, req BrowserLogRequest) ([]BrowserLogEntry, error)
- func (p StaticProvider) DatabaseConnections(context.Context) ([]DatabaseConnection, error)
- func (p StaticProvider) DatabaseQuery(_ context.Context, req QueryRequest) (QueryResult, error)
- func (p StaticProvider) DatabaseSchema(_ context.Context, connection string) (DatabaseSchema, error)
- func (p StaticProvider) LastError(context.Context) (LogEntry, bool, error)
- func (p StaticProvider) LogEntries(_ context.Context, req LogRequest) ([]LogEntry, error)
- func (p StaticProvider) MetricsMetadata(_ context.Context, req MetricsMetadataRequest) (MetricsMetadata, error)
- type Table
- type URLRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateReadOnlySQL ¶
ValidateReadOnlySQL rejects SQL that is not obviously read-only.
Types ¶
type BrowserLogEntry ¶
type BrowserLogEntry struct {
Time string `json:"time,omitempty"`
App string `json:"app,omitempty"`
Level string `json:"level,omitempty"`
Message string `json:"message"`
URL string `json:"url,omitempty"`
}
BrowserLogEntry describes one browser console log entry.
type BrowserLogRequest ¶
type BrowserLogRequest struct {
App string `json:"app,omitempty"`
Limit int `json:"limit,omitempty"`
}
BrowserLogRequest describes a bounded browser log read.
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
Nullable bool `json:"nullable"`
Primary bool `json:"primary,omitempty"`
}
Column describes one database column.
type DatabaseConnection ¶
type DatabaseConnection struct {
Name string `json:"name"`
Driver string `json:"driver"`
Database string `json:"database,omitempty"`
App string `json:"app,omitempty"`
}
DatabaseConnection describes safe database connection metadata.
type DatabaseSchema ¶
type DatabaseSchema struct {
Connection string `json:"connection"`
Tables []Table `json:"tables,omitempty"`
}
DatabaseSchema describes safe schema metadata.
type Index ¶
type Index struct {
Name string `json:"name"`
Columns []string `json:"columns"`
Unique bool `json:"unique,omitempty"`
}
Index describes one database index.
type LogEntry ¶
type LogEntry struct {
Time string `json:"time,omitempty"`
App string `json:"app,omitempty"`
Runtime string `json:"runtime,omitempty"`
Level string `json:"level,omitempty"`
Message string `json:"message"`
Fields map[string]any `json:"fields,omitempty"`
}
LogEntry describes one runtime log entry.
type LogRequest ¶
LogRequest describes a bounded log read.
type MetricsMetadata ¶
type MetricsMetadata struct {
App string `json:"app,omitempty"`
Runtime string `json:"runtime,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Targets []string `json:"targets,omitempty"`
Counters []string `json:"counters,omitempty"`
}
MetricsMetadata describes known app/runtime metric labels and targets.
type MetricsMetadataRequest ¶
type MetricsMetadataRequest struct {
App string `json:"app,omitempty"`
Runtime string `json:"runtime,omitempty"`
}
MetricsMetadataRequest describes app/runtime metrics metadata lookup.
type Provider ¶
type Provider interface {
// DatabaseConnections returns safe connection metadata without secrets.
DatabaseConnections(context.Context) ([]DatabaseConnection, error)
// DatabaseSchema returns table, column, and index metadata for a connection.
DatabaseSchema(context.Context, string) (DatabaseSchema, error)
// DatabaseQuery runs a bounded read-only query.
DatabaseQuery(context.Context, QueryRequest) (QueryResult, error)
// LogEntries returns recent framework log entries.
LogEntries(context.Context, LogRequest) ([]LogEntry, error)
// LastError returns the latest error-level log entry when one is available.
LastError(context.Context) (LogEntry, bool, error)
// AbsoluteURL resolves an app-relative path to a local absolute URL.
AbsoluteURL(context.Context, URLRequest) (string, error)
// BrowserLogs returns recent browser console entries captured during local development.
BrowserLogs(context.Context, BrowserLogRequest) ([]BrowserLogEntry, error)
// MetricsMetadata returns app/runtime-aware metrics labels and targets.
MetricsMetadata(context.Context, MetricsMetadataRequest) (MetricsMetadata, error)
}
Provider supplies read-only runtime diagnostics to Atlas.
type QueryRequest ¶
type QueryRequest struct {
Connection string `json:"connection"`
SQL string `json:"sql"`
Limit int `json:"limit,omitempty"`
}
QueryRequest describes a bounded read-only database query.
type QueryResult ¶
type QueryResult struct {
Connection string `json:"connection"`
Columns []string `json:"columns,omitempty"`
Rows []map[string]any `json:"rows,omitempty"`
Limit int `json:"limit,omitempty"`
}
QueryResult describes read-only query output.
type StaticProvider ¶
type StaticProvider struct {
Connections []DatabaseConnection
Schemas map[string]DatabaseSchema
Queries map[string]QueryResult
Logs []LogEntry
BaseURLs map[string]string
Browser []BrowserLogEntry
Metrics map[string]MetricsMetadata
}
StaticProvider is an in-memory diagnostics provider for tests and adapters.
func (StaticProvider) AbsoluteURL ¶
func (p StaticProvider) AbsoluteURL(_ context.Context, req URLRequest) (string, error)
AbsoluteURL resolves a local app URL.
func (StaticProvider) BrowserLogs ¶
func (p StaticProvider) BrowserLogs(_ context.Context, req BrowserLogRequest) ([]BrowserLogEntry, error)
BrowserLogs returns bounded static browser log entries.
func (StaticProvider) DatabaseConnections ¶
func (p StaticProvider) DatabaseConnections(context.Context) ([]DatabaseConnection, error)
DatabaseConnections returns static connection metadata.
func (StaticProvider) DatabaseQuery ¶
func (p StaticProvider) DatabaseQuery(_ context.Context, req QueryRequest) (QueryResult, error)
DatabaseQuery returns a static query result after enforcing read-only SQL.
func (StaticProvider) DatabaseSchema ¶
func (p StaticProvider) DatabaseSchema(_ context.Context, connection string) (DatabaseSchema, error)
DatabaseSchema returns static schema metadata.
func (StaticProvider) LogEntries ¶
func (p StaticProvider) LogEntries(_ context.Context, req LogRequest) ([]LogEntry, error)
LogEntries returns bounded static log entries.
func (StaticProvider) MetricsMetadata ¶
func (p StaticProvider) MetricsMetadata(_ context.Context, req MetricsMetadataRequest) (MetricsMetadata, error)
MetricsMetadata returns static metrics metadata.
type Table ¶
type Table struct {
Name string `json:"name"`
Columns []Column `json:"columns,omitempty"`
Indexes []Index `json:"indexes,omitempty"`
}
Table describes one database table.
type URLRequest ¶
URLRequest describes a local app URL lookup.