app

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitGinEngine

func InitGinEngine(opt UseEngine) *gin.Engine

InitGinEngine engine

func Run

func Run(ctx context.Context, opts ...Option) error

Run 运行服务, 注意,必须对BuildInjector进行初始化

func RunHTTPServer

func RunHTTPServer(ctx context.Context, handler http.Handler) func()

RunHTTPServer 初始化http服务

func RunServer

func RunServer(ctx context.Context, opts ...Option) (func(), error)

RunServer 启动服务

func RunWebCmd

func RunWebCmd(ctx context.Context, action func(c *cli.Context) error) *cli.Command

RunWebCmd ...

func RunWithShutdown

func RunWithShutdown(ctx context.Context, runServer func() (func(), error)) error

RunWithShutdown 运行服务

Types

type BuildInjector

type BuildInjector func() (engine *gin.Engine, clean func(), err error)

BuildInjector 构建注入器的方法

type Healthz

type Healthz gin.IRoutes

Healthz 路由

func NewHealthz

func NewHealthz(app *gin.Engine) Healthz

NewHealthz 初始化根路由

type Option

type Option func(*Options)

Option 定义配置项

func SetBuildInjector

func SetBuildInjector(b BuildInjector) Option

SetBuildInjector 设定注入助手

func SetConfigFile

func SetConfigFile(s string) Option

SetConfigFile 设定配置文件

func SetVersion

func SetVersion(s string) Option

SetVersion 设定版本号b

type Options

type Options struct {
	ConfigFile    string
	Version       string
	BuildInjector BuildInjector
}

Options options

type Router

type Router gin.IRouter

Router 根路由 Register???

func NewRouter

func NewRouter(app *gin.Engine) Router

NewRouter 初始化根路由

type Status

type Status struct {
	Uptime       string
	NumGoroutine int

	// General statistics.
	MemAllocated string // bytes allocated and still in use
	MemTotal     string // bytes allocated (even if freed)
	MemSys       string // bytes obtained from system (sum of XxxSys below)
	Lookups      uint64 // number of pointer lookups
	MemMallocs   uint64 // number of mallocs
	MemFrees     uint64 // number of frees

	// Main allocation heap statistics.
	HeapAlloc    string // bytes allocated and still in use
	HeapSys      string // bytes obtained from system
	HeapIdle     string // bytes in idle spans
	HeapInuse    string // bytes in non-idle span
	HeapReleased string // bytes released to the OS
	HeapObjects  uint64 // total number of allocated objects

	// Low-level fixed-size structure allocator statistics.
	//	Inuse is bytes used now.
	//	Sys is bytes obtained from system.
	StackInuse  string // bootstrap stacks
	StackSys    string
	MSpanInuse  string // mspan structures
	MSpanSys    string
	MCacheInuse string // mcache structures
	MCacheSys   string
	BuckHashSys string // profiling bucket hash table
	GCSys       string // GC metadata
	OtherSys    string // other system allocations

	// Garbage collector statistics.
	NextGC       string // next run in HeapAlloc time (bytes)
	LastGC       string // last run in absolute time (ns)
	PauseTotalNs string
	PauseNs      string // circular buffer of recent GC pause times, most recent at [(NumGC+255)%256]
	NumGC        uint32
}

Status 应用状态

func GetAppStatus

func GetAppStatus() Status

GetAppStatus 获取应用状态

type SysStatus

type SysStatus struct {
	CPULogicalCorego int
	CPUCore          int
	OSPlatform       string
	OSFamily         string
	OSVersion        string
	Load1            float64
	Load5            float64
	Load15           float64
	MemTotal         string
	MemAvailable     string
	MemUsed          string
}

SysStatus 系统状态

type UseEngine

type UseEngine func(*gin.Engine)

UseEngine 修正Engine内容

Jump to

Keyboard shortcuts

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