bump copyright, added stats page and updated dependencies
This commit is contained in:
parent
b1028b3d8a
commit
0265d820fe
111 changed files with 9556 additions and 3835 deletions
|
|
@ -1,9 +1,12 @@
|
|||
// Copyright (C) 2019 Marius Schellenberger
|
||||
// Copyright (C) 2020 Marius Schellenberger
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
bleve "git.giftfish.de/ston1th/gowiki/pkg/index"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -12,6 +15,8 @@ const (
|
|||
day = time.Hour * 24
|
||||
min = time.Second * 30
|
||||
max = day * 90
|
||||
|
||||
div = 1048576
|
||||
)
|
||||
|
||||
func duration(duration, mode string) (d time.Duration, err error) {
|
||||
|
|
@ -43,3 +48,19 @@ func duration(duration, mode string) (d time.Duration, err error) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func fmtMem(i uint64) string {
|
||||
return strconv.FormatFloat(float64(i)/div, 'f', 2, 64)
|
||||
}
|
||||
|
||||
func getStats(i *bleve.Index) *core.Stats {
|
||||
mem := new(runtime.MemStats)
|
||||
runtime.ReadMemStats(mem)
|
||||
return &core.Stats{
|
||||
Goroutines: runtime.NumGoroutine(),
|
||||
Alloc: fmtMem(mem.Alloc),
|
||||
Sys: fmtMem(mem.Sys),
|
||||
Docs: i.DocCount(),
|
||||
GoVersion: runtime.Version(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue