server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 32 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultEnvPrefix = "DASHBOARD_"
)

Variables

This section is empty.

Functions

func InitDatabase

func InitDatabase(cfg *DatabaseConfig) (*sql.DB, error)

InitDatabase initializes a database within a bounded startup window.

func OpenDatabase

func OpenDatabase(cfg *DatabaseConfig) (*sql.DB, error)

OpenDatabase creates a stable pool; it can reconnect without replacing its pointer.

Types

type Analytics

type Analytics struct {
	TotalRuns       int          `json:"total_runs"`
	SuccessRate     float64      `json:"success_rate"`
	SkippedRuns     int          `json:"skipped_runs"`
	CancelledRuns   int          `json:"cancelled_runs"`
	AverageDuration float64      `json:"average_duration_seconds"`
	FlakyTests      []FlakyTest  `json:"flaky_tests,omitempty"`
	TrendData       []TrendPoint `json:"trend_data,omitempty"`
}

Analytics provides statistical analysis of workflow data

func GetAnalytics

func GetAnalytics(ctx context.Context, db *sql.DB, repositoryID int64, days int) (*Analytics, error)

GetAnalytics returns overall analytics for a repository or all repositories

type CacheConfig

type CacheConfig struct {
	// Cache duration for workflow runs
	WorkflowTTL time.Duration `yaml:"workflow_ttl"`

	// Maximum cache entries
	MaxEntries int `yaml:"max_entries"`

	// How long repository, analytics and flaky-check results are served from
	// memory before being refreshed in the background (default: 1m)
	StatsTTL time.Duration `yaml:"stats_ttl"`
}

type Config

type Config struct {
	Server   baseapp.HTTPConfig `yaml:"server"`
	Logging  LoggingConfig      `yaml:"logging"`
	Github   githubapp.Config   `yaml:"github"`
	Database DatabaseConfig     `yaml:"database"`
	Cache    CacheConfig        `yaml:"cache"`
	Options  DashboardOptions   `yaml:"options"`
	Sessions SessionsConfig     `yaml:"sessions"`
	Access   auth.AccessPolicy  `yaml:"access"`
	DemoMode bool               `yaml:"demo_mode"`
}

func ParseConfig

func ParseConfig(bytes []byte) (*Config, error)

type DashboardOptions

type DashboardOptions struct {
	// Default time window for workflow display (e.g., "12h", "24h")
	DefaultTimeWindow string `yaml:"default_time_window"`

	// Maximum repositories to display per page
	MaxReposPerPage int `yaml:"max_repos_per_page"`

	// Enable real-time updates via WebSocket
	EnableRealtime bool `yaml:"enable_realtime"`
}

type DatabaseConfig

type DatabaseConfig struct {
	// Database driver: "postgres" (default: postgres)
	Driver string `yaml:"driver"`

	// Database connection string
	// For PostgreSQL: "postgres://user:pass@localhost:5432/dbname?sslmode=disable"
	// For Cloud SQL: auto-generated from CloudSQLInstance
	URL string `yaml:"url"`

	// Cloud SQL Instance connection name (format: project:region:instance)
	// When set, automatically configures Unix socket connection for Cloud Run
	CloudSQLInstance string `yaml:"cloud_sql_instance"`

	// Database name (PostgreSQL only)
	DBName string `yaml:"db_name"`

	// Database user (PostgreSQL only)
	User string `yaml:"user"`

	// Database password (prefer using Secret Manager in production)
	Password string `yaml:"password"`

	// Maximum number of open connections
	MaxOpenConns int `yaml:"max_open_conns"`

	// Maximum number of idle connections
	MaxIdleConns int `yaml:"max_idle_conns"`
}

type FlakyTest

type FlakyTest struct {
	Name         string    `json:"name"`
	Repository   string    `json:"repository"`
	TotalRuns    int       `json:"total_runs"`
	FailureCount int       `json:"failure_count"`
	FlakeRate    float64   `json:"flake_rate"`
	LastFailure  time.Time `json:"last_failure"`
}

FlakyTest represents a test that intermittently fails

func GetFlakyTests

func GetFlakyTests(ctx context.Context, db *sql.DB, repositoryID int64, minRuns int, days int) ([]FlakyTest, error)

GetFlakyTests identifies tests that fail intermittently

type LoggingConfig

type LoggingConfig struct {
	Level string `yaml:"level" json:"level"`
	Text  bool   `yaml:"text" json:"text"`
}

type Repository

type Repository struct {
	ID            int64     `json:"id"`
	Owner         string    `json:"owner"`
	Name          string    `json:"name"`
	FullName      string    `json:"full_name"`
	DefaultBranch string    `json:"default_branch"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`

	// Aggregate data
	TotalRuns      int     `json:"total_runs,omitempty"`
	SuccessfulRuns int     `json:"successful_runs,omitempty"`
	FailedRuns     int     `json:"failed_runs,omitempty"`
	SkippedRuns    int     `json:"skipped_runs,omitempty"`
	CancelledRuns  int     `json:"cancelled_runs,omitempty"`
	SuccessRate    float64 `json:"success_rate,omitempty"`
}

Repository represents a GitHub repository

func GetRepositories

func GetRepositories(ctx context.Context, db *sql.DB, withStats bool) ([]Repository, error)

GetRepositories returns all tracked repositories with optional statistics

type Server

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

Server represents the dashboard application server

func New

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

New creates a new Server instance

func (*Server) Close

func (s *Server) Close() error

Close cancels background work and shuts down the server exactly once.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the application routes for serving or integration testing.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server

type SessionsConfig

type SessionsConfig struct {
	// Lifetime in seconds (default: 86400 = 24 hours)
	Lifetime int   `yaml:"lifetime"`
	Secure   *bool `yaml:"secure"`
}

type TrendPoint

type TrendPoint struct {
	Date        string  `json:"date"`
	SuccessRate float64 `json:"success_rate"`
	TotalRuns   int     `json:"total_runs"`
}

TrendPoint represents success rate at a point in time

func GetTrendData

func GetTrendData(ctx context.Context, db *sql.DB, repositoryID int64, days int) ([]TrendPoint, error)

GetTrendData returns success rate trends over time

type WorkflowGridRow

type WorkflowGridRow struct {
	Name  string
	Cells []*WorkflowRun
}

type WorkflowRun

type WorkflowRun struct {
	ID           int64      `json:"id"`
	RepositoryID int64      `json:"repository_id"`
	WorkflowID   int64      `json:"workflow_id"`
	WorkflowName string     `json:"workflow_name"`
	WorkflowPath string     `json:"workflow_path,omitempty"`
	HeadBranch   string     `json:"head_branch"`
	HeadSHA      string     `json:"head_sha"`
	RunNumber    int        `json:"run_number"`
	Event        string     `json:"event"`
	Status       string     `json:"status"`
	Conclusion   string     `json:"conclusion"`
	HTMLURL      string     `json:"html_url"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
	RunStartedAt *time.Time `json:"run_started_at,omitempty"`

	// Joined data
	RepositoryFullName string `json:"repository_full_name,omitempty"`
}

WorkflowRun represents a workflow run

func GetWorkflowRuns

func GetWorkflowRuns(ctx context.Context, db *sql.DB, opts WorkflowRunOptions) ([]WorkflowRun, error)

GetWorkflowRuns returns workflow runs with optional filtering

type WorkflowRunOptions

type WorkflowRunOptions struct {
	Offset       int
	RepositoryID int64
	Status       string
	Conclusion   string
	HeadBranch   string
	WorkflowName string
	Event        string
	Since        time.Time
	Limit        int
}

WorkflowRunOptions defines filtering options for workflow runs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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