server

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IndexReplacePlaceholder = `<!--INJECT GENERATED CODE HERE FROM BACKEND-->`

Functions

func SetupFrontendMiddleware added in v0.58.2

func SetupFrontendMiddleware(engine *gin.Engine, basePath string, staticFolderPath string)

SetupFrontendMiddleware mounts base redirect and static file serving middlewares onto engine.

func SetupFrontendRoutes added in v0.58.2

func SetupFrontendRoutes(router gin.IRouter, staticFolderPath string)

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

type ResourceMonitorMock struct {
	UsedMemory  uint64
	TotalMemory uint64
	CPUUsage    float64
}

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.

Jump to

Keyboard shortcuts

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