Documentation
¶
Overview ¶
Copyright 2026 Cloudbase Solutions SRL
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Copyright 2026 Cloudbase Solutions SRL
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsEntity ¶
type MetricsEntity struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Endpoint string `json:"endpoint"`
PoolCount int `json:"pool_count"`
ScaleSetCount int `json:"scale_set_count"`
Healthy bool `json:"healthy"`
}
MetricsEntity represents a repository, organization, or enterprise with enough info for the dashboard entity list.
type MetricsHub ¶
type MetricsHub struct {
// contains filtered or unexported fields
}
MetricsHub broadcasts pre-aggregated metrics snapshots to all connected dashboard WebSocket clients at a fixed interval. It reads from the in-memory cache (no database queries) and computes the snapshot once for all clients.
func NewMetricsHub ¶
func NewMetricsHub(ctx context.Context) *MetricsHub
func (*MetricsHub) Register ¶
func (m *MetricsHub) Register(client *websocket.Client) error
Register adds a client to the hub and sends an immediate snapshot so the dashboard doesn't have to wait for the next tick.
func (*MetricsHub) Start ¶
func (m *MetricsHub) Start() error
func (*MetricsHub) Stop ¶
func (m *MetricsHub) Stop() error
func (*MetricsHub) Unregister ¶
func (m *MetricsHub) Unregister(client *websocket.Client) error
type MetricsPool ¶
type MetricsPool struct {
ID string `json:"id"`
ProviderName string `json:"provider_name"`
OSType string `json:"os_type"`
MaxRunners uint `json:"max_runners"`
Enabled bool `json:"enabled"`
RepoName string `json:"repo_name,omitempty"`
OrgName string `json:"org_name,omitempty"`
EnterpriseName string `json:"enterprise_name,omitempty"`
RunnerCounts map[string]int `json:"runner_counts"`
RunnerStatusCounts map[string]int `json:"runner_status_counts"`
}
MetricsPool represents a pool with runner counts grouped by instance status.
type MetricsScaleSet ¶
type MetricsScaleSet struct {
ID uint `json:"id"`
Name string `json:"name"`
ProviderName string `json:"provider_name"`
OSType string `json:"os_type"`
MaxRunners uint `json:"max_runners"`
Enabled bool `json:"enabled"`
RepoName string `json:"repo_name,omitempty"`
OrgName string `json:"org_name,omitempty"`
EnterpriseName string `json:"enterprise_name,omitempty"`
RunnerCounts map[string]int `json:"runner_counts"`
RunnerStatusCounts map[string]int `json:"runner_status_counts"`
}
MetricsScaleSet represents a scale set with runner counts grouped by instance status.
type MetricsSnapshot ¶
type MetricsSnapshot struct {
Entities []MetricsEntity `json:"entities"`
Pools []MetricsPool `json:"pools"`
ScaleSets []MetricsScaleSet `json:"scale_sets"`
}
MetricsSnapshot is the payload sent to dashboard clients every 5 seconds. It contains pre-aggregated data from the in-memory cache, allowing the frontend to derive all dashboard stats without making individual API calls.
func BuildSnapshot ¶
func BuildSnapshot() MetricsSnapshot
BuildSnapshot reads from the in-memory cache and aggregates data into a MetricsSnapshot. This function is safe to call concurrently — the cache handles its own locking.