server

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 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

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.

Directories

Path Synopsis
api
v1
mcp
md
Package uploadurl issues short-lived URLs that accept a file for one file form field in a single PUT request.
Package uploadurl issues short-lived URLs that accept a file for one file form field in a single PUT request.
cel

Jump to

Keyboard shortcuts

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