admin control features and admin dashboard
This commit is contained in:
1 parent
c630f13c57
commit
37910e410b
69 files changed
+4959
-400
No files matched your search
@@ -277,6 +277,55 @@ func LoadProber(path string) (*Prober, error) {
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
// ---- admin-dashboard ----
|
||||
|
||||
// AdminDashboard is the config for the 4th binary, cmd/admin-dashboard — a
|
||||
// stateless, server-rendered web UI over control-api's /api/v1/admin/*
|
||||
// HTTP API (see docs/DASHBOARD.md). It never talks to the database.
|
||||
type AdminDashboard struct {
|
||||
Server ServerConfig `yaml:"server"`
|
||||
ControlAPI DashboardControlAPIConfig `yaml:"control_api"`
|
||||
Overview DashboardOverviewConfig `yaml:"overview"`
|
||||
}
|
||||
|
||||
type DashboardControlAPIConfig struct {
|
||||
BaseURL string `yaml:"base_url"`
|
||||
TimeoutSeconds int `yaml:"timeout_seconds"`
|
||||
}
|
||||
|
||||
// DashboardOverviewConfig configures the overview page's "текущая
|
||||
// проверка" / "последние N завершённых" summary — see
|
||||
// docs/DASHBOARD.md#текущая-и-последняя-завершённая-проверка. Both are
|
||||
// computed fresh on every request from control-api's existing
|
||||
// status/queue endpoints; there is no persisted "run"/"batch" concept.
|
||||
type DashboardOverviewConfig struct {
|
||||
LastCompletedCount int `yaml:"last_completed_count"`
|
||||
PollIntervalSeconds int `yaml:"poll_interval_seconds"`
|
||||
}
|
||||
|
||||
func LoadAdminDashboard(path string) (*AdminDashboard, error) {
|
||||
var c AdminDashboard
|
||||
if err := loadYAML(path, &c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.Server.ListenAddr == "" {
|
||||
c.Server.ListenAddr = ":8090"
|
||||
}
|
||||
if c.ControlAPI.BaseURL == "" {
|
||||
return nil, fmt.Errorf("control_api.base_url is required")
|
||||
}
|
||||
if c.ControlAPI.TimeoutSeconds == 0 {
|
||||
c.ControlAPI.TimeoutSeconds = 10
|
||||
}
|
||||
if c.Overview.LastCompletedCount == 0 {
|
||||
c.Overview.LastCompletedCount = 20
|
||||
}
|
||||
if c.Overview.PollIntervalSeconds == 0 {
|
||||
c.Overview.PollIntervalSeconds = 5
|
||||
}
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func loadYAML(path string, out interface{}) error {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user