Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IndexReplacePlaceholder = `<!--INJECT GENERATED CODE HERE FROM BACKEND-->`
Functions ¶
func SetupFrontendMiddleware ¶ added in v0.58.2
SetupFrontendMiddleware mounts base redirect and static file serving middlewares onto engine.
func SetupFrontendRoutes ¶ added in v0.58.2
SetupFrontendRoutes mounts the SPA fallback routes onto router.
Types ¶
type ResourceMonitor ¶
type ResourceMonitor interface {
// GetUsedMemory returns the current memory usage of the server process in bytes.
GetUsedMemory() uint64
// GetTotalMemory returns the total physical memory of the server in bytes.
GetTotalMemory() uint64
// GetCPUUsage returns the current CPU usage percentage across all cores (0.0 to 100.0).
GetCPUUsage() float64
}
ResourceMonitor provides methods to monitor server resources.
type ResourceMonitorImpl ¶
type ResourceMonitorImpl struct {
// contains filtered or unexported fields
}
ResourceMonitorImpl is the real implementation of ResourceMonitor.
func NewResourceMonitorImpl ¶ added in v0.58.2
func NewResourceMonitorImpl() *ResourceMonitorImpl
NewResourceMonitorImpl creates and initializes a ResourceMonitorImpl, starting a background CPU sampling loop.
func (*ResourceMonitorImpl) Close ¶ added in v0.58.2
func (r *ResourceMonitorImpl) Close()
Close terminates the background CPU monitoring loop.
func (*ResourceMonitorImpl) GetCPUUsage ¶ added in v0.58.2
func (r *ResourceMonitorImpl) GetCPUUsage() float64
GetCPUUsage returns the latest sampled CPU usage percentage from the background loop.
func (*ResourceMonitorImpl) GetTotalMemory ¶ added in v0.53.0
func (r *ResourceMonitorImpl) GetTotalMemory() uint64
GetTotalMemory returns the total physical memory using gopsutil. The result is cached after the first call.
func (*ResourceMonitorImpl) GetUsedMemory ¶
func (r *ResourceMonitorImpl) GetUsedMemory() uint64
GetUsedMemory returns the current memory usage using runtime.MemStats (Alloc).
type ResourceMonitorMock ¶
ResourceMonitorMock is a mock implementation of ResourceMonitor for testing.
func (*ResourceMonitorMock) GetCPUUsage ¶ added in v0.58.2
func (r *ResourceMonitorMock) GetCPUUsage() float64
GetCPUUsage returns the mocked CPU usage.
func (*ResourceMonitorMock) GetTotalMemory ¶ added in v0.53.0
func (r *ResourceMonitorMock) GetTotalMemory() uint64
GetTotalMemory returns the mocked total memory.
func (*ResourceMonitorMock) GetUsedMemory ¶
func (r *ResourceMonitorMock) GetUsedMemory() uint64
GetUsedMemory returns the mocked used memory.