core

package
v1.7.21 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHtml added in v1.7.9

func CreateHtml(tableBody string) string

CreateHtml create a complete page html by replacing {{tableBody}}

func CreateTableHtml added in v1.7.7

func CreateTableHtml(col, title, header, body string) string

CreateTableHtml create a complete page html by replacing {{tableBody}} and table part html

func CreateTablePart added in v1.7.9

func CreateTablePart(col, title, header, body string) string

CreateTablePart create a table part html by replacing flags

Types

type ConcurrenceMap

type ConcurrenceMap interface {
	Get(key string) (value interface{}, exists bool)
	GetString(key string) string
	GetTimeDuration(key string) time.Duration
	GetInt(key string) int
	GetUInt64(key string) uint64
	Exists(key string) bool
	GetCurrentMap() map[string]interface{}
	Len() int
	Set(key string, value interface{})
	Remove(key string)
	Once(key string) (value interface{}, exists bool)
}

ReadonlyMap support concurrence for map

func NewConcurrenceMap

func NewConcurrenceMap() ConcurrenceMap

NewConcurrenceMap create new ConcurrenceMap

type ErrorInfo

type ErrorInfo struct {
	URL    string
	ErrMsg string
	Num    uint64
}

error count info

type HideReaddirFS

type HideReaddirFS struct {
	FileSystem http.FileSystem
}

FileSystem with hide Readdir

func (HideReaddirFS) Open

func (fs HideReaddirFS) Open(name string) (http.File, error)

Conforms to http.Filesystem

type ItemMap

type ItemMap struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

ItemMap concurrence map

func NewItemMap

func NewItemMap() *ItemMap

NewItemMap create new ItemMap

func (*ItemMap) Exists

func (ctx *ItemMap) Exists(key string) bool

Exists check exists key

func (*ItemMap) Get

func (ctx *ItemMap) Get(key string) (value interface{}, exists bool)

Get returns value of specified key

func (*ItemMap) GetCurrentMap

func (ctx *ItemMap) GetCurrentMap() map[string]interface{}

GetCurrentMap get current map, returns map[string]interface{}

func (*ItemMap) GetInt

func (ctx *ItemMap) GetInt(key string) int

GetInt returns value as int specified by key return 0 if key not exists

func (*ItemMap) GetString

func (ctx *ItemMap) GetString(key string) string

GetString returns value as string specified by key return empty string if key not exists

func (*ItemMap) GetTimeDuration

func (ctx *ItemMap) GetTimeDuration(key string) time.Duration

GetTimeDuration returns value as time.Duration specified by key return 0 if key not exists or value cannot be converted to time.Duration

func (*ItemMap) GetUInt64

func (ctx *ItemMap) GetUInt64(key string) uint64

GetUInt64 returns value as uint64 specified by key return 0 if key not exists or value cannot be converted to int64

func (*ItemMap) Len

func (ctx *ItemMap) Len() int

Len get context length

func (*ItemMap) Once

func (ctx *ItemMap) Once(key string) (value interface{}, exists bool)

Once get item by gived key, and remove it only can be read once, it will be locked

func (*ItemMap) Remove

func (ctx *ItemMap) Remove(key string)

Remove remove item by gived key if not exists key, do nothing...

func (*ItemMap) Set

func (ctx *ItemMap) Set(key string, value interface{})

Set put key, value into ItemMap

type ReadonlyMap

type ReadonlyMap interface {
	Get(key string) (value interface{}, exists bool)
	GetString(key string) string
	GetTimeDuration(key string) time.Duration
	GetInt(key string) int
	GetUInt64(key string) uint64
	Exists(key string) bool
	Len() int
}

ReadonlyMap only support readonly method for map

func NewReadonlyMap

func NewReadonlyMap() ReadonlyMap

NewReadonlyMap create new ReadonlyMap

type RequestInfo

type RequestInfo struct {
	URL  string
	Code int
	Num  uint64
}

http request count info

type ServerStateInfo

type ServerStateInfo struct {
	ServerStartTime time.Time
	// enable detailed request statistics, fixes #63 request statistics, high memory usage when URL number is high
	EnabledDetailRequestData bool
	TotalRequestCount        uint64
	// active request count
	CurrentRequestCount uint64
	// request statistics per minute
	IntervalRequestData *ItemMap
	// detailed request statistics, the key is url without parameters
	DetailRequestURLData *ItemMap
	TotalErrorCount      uint64
	// request error statistics per minute
	IntervalErrorData *ItemMap
	// detailed request error statistics, the key is url without parameters
	DetailErrorPageData *ItemMap
	// detailed error statistics, the key is url without parameters
	DetailErrorData *ItemMap
	// detailed reponse statistics of http code, the key is HttpCode, e.g. 200, 500 etc.
	DetailHTTPCodeData *ItemMap
	// contains filtered or unexported fields
}

Server state

func NewServerStateInfo

func NewServerStateInfo() *ServerStateInfo

NewServerStateInfo return ServerStateInfo which is init

func (*ServerStateInfo) AddCurrentRequest

func (state *ServerStateInfo) AddCurrentRequest(num uint64) uint64

AddCurrentRequest increment current request count

func (*ServerStateInfo) AddErrorCount

func (state *ServerStateInfo) AddErrorCount(page string, err error, num uint64) uint64

AddErrorCount add error count

func (*ServerStateInfo) AddRequestCount

func (state *ServerStateInfo) AddRequestCount(page string, code int, num uint64)

AddRequestCount add request count

func (*ServerStateInfo) QueryIntervalErrorData

func (state *ServerStateInfo) QueryIntervalErrorData(queryKey string) uint64

QueryIntervalErrorData query error count by query time

func (*ServerStateInfo) QueryIntervalRequestData

func (state *ServerStateInfo) QueryIntervalRequestData(queryKey string) uint64

QueryIntervalRequestData query request count by query time

func (*ServerStateInfo) ShowHtmlDataRaw added in v1.7.7

func (state *ServerStateInfo) ShowHtmlDataRaw(version, globalUniqueId string) string

ShowHtmlDataRaw show server state data html-string format

func (*ServerStateInfo) ShowHtmlTableData added in v1.7.7

func (state *ServerStateInfo) ShowHtmlTableData(version, globalUniqueId string) string

ShowHtmlData show server state data html-table format

func (*ServerStateInfo) SubCurrentRequest

func (state *ServerStateInfo) SubCurrentRequest(num uint64) uint64

SubCurrentRequest subtract current request count

Jump to

Keyboard shortcuts

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