Documentation ¶
Index ¶
- Variables
- func ApisHandler(c *gin.Context)
- func CaptchaHandler() gin.HandlerFunc
- func CounterMiddleware() gin.HandlerFunc
- func ErrorPage(fsys fs.FS, msg string, err error) string
- func ErrorTmpl(fsys fs.FS, msg string, err error) string
- func Etag(str string, weak bool) string
- func FAQPage(fsys fs.FS) string
- func FooterPage(fsys fs.FS) string
- func GinHandlerFunc(hdlr http.HandlerFunc) gin.HandlerFunc
- func HeaderMiddleware(webServer srvConfig.WebServer) gin.HandlerFunc
- func HeaderPage(fsys fs.FS) string
- func InitServer(webServer srvConfig.WebServer)
- func MDToHTML(fsys fs.FS, fname string) (string, error)
- func MetricsHandler(c *gin.Context)
- func ParseTmpl(tdir, tmpl string, data interface{}) (string, error)
- func Router(routes []Route, fsys fs.FS, static string, webServer srvConfig.WebServer) *gin.Engine
- func StartServer(r *gin.Engine, webServer srvConfig.WebServer)
- func SuccessTmpl(fsys fs.FS, msg string) string
- func TmplPage(fsys fs.FS, tmpl string, tmplData TmplRecord) string
- type GinRoute
- type Mem
- type Memory
- type Metrics
- type ProcFS
- type RequestStats
- type Route
- type Templates
- type TmplRecord
Constants ¶
This section is empty.
Variables ¶
var AvgGetRequestTime float64
AvgGetRequestTime represents average GET request time
var AvgPostRequestTime float64
AvgPostRequestTime represents average POST request time
var AvgPutRequestTime float64
AvgPutRequestTime represents average PUT request time
var LimiterMiddleware gin.HandlerFunc
LimiterMiddleware provides limiter middleware pointer
var MetricsLastUpdateTime time.Time
MetricsLastUpdateTime keeps track of last update time of the metrics
var NumLogicalCores int
NumLogicalCores represents number of cores in our node
var NumPhysicalCores int
NumPhysicalCores represents number of cores in our node
var RPS float64
RPS represents requests per second for a given server
var RPSLogical float64
RPSLogical represents requests per second for a given server times number of logical CPU cores
var RPSPhysical float64
RPSPhysical represents requests per second for a given server times number of physical CPU cores
var StartTime time.Time
StartTime represents initial time when we started the server
var Time0 time.Time
Time0 represents initial time when we started the server
var TotalDeleteRequests uint64
TotalDeleteRequests counts total number of DELETE requests received by the server
var TotalGetRequests uint64
TotalGetRequests counts total number of GET requests received by the server
var TotalPostRequests uint64
TotalPostRequests counts total number of POST requests received by the server
var TotalPutRequests uint64
TotalPutRequests counts total number of PUT requests received by the server
Functions ¶
func ApisHandler ¶ added in v0.0.1
ApisHandler provides JSON output for server routes
func CaptchaHandler ¶
func CaptchaHandler() gin.HandlerFunc
CaptchaHandler provides access to captcha server
func CounterMiddleware ¶
func CounterMiddleware() gin.HandlerFunc
CounterMiddleware counts GET/POST/PUT/DELETE requests
func Etag ¶ added in v0.0.5
Generates an Etag for given string, provided by https://github.com/amalfra/etag
func GinHandlerFunc ¶ added in v0.0.3
func GinHandlerFunc(hdlr http.HandlerFunc) gin.HandlerFunc
GinHandlerFunc converts given http.Handler to gin.HandlerFunc
func HeaderMiddleware ¶ added in v0.0.5
func HeaderMiddleware(webServer srvConfig.WebServer) gin.HandlerFunc
HeaderMiddleware represents header middleware
func InitServer ¶ added in v0.0.2
InitServer provides server initialization
func MetricsHandler ¶ added in v0.0.8
MetricsHandler provides metrics JSON for monitoring purposes (Prometheus)
func Router ¶ added in v0.0.1
Router provids server router, it takes two maps: one for non-authorized routes and anotehr for authorized ones
func StartServer ¶ added in v0.0.7
StartServer starts HTTP(s) server
func SuccessTmpl ¶
SuccessTmpl provides success template message
Types ¶
type Mem ¶
type Mem struct { Virtual Memory `json:"virtual"` // virtual memory metrics from gopsutils Swap Memory `json:"swap"` // swap memory metrics from gopsutils }
Mem structure keeps track of virtual/swap memory of the server
type Memory ¶
type Memory struct { Total uint64 `json:"total"` Free uint64 `json:"free"` Used uint64 `json:"used"` UsedPercent float64 `json:"usedPercent"` }
Memory structure keeps track of server memory
type Metrics ¶ added in v0.0.8
type Metrics struct { CPU []float64 `json:"cpu"` // cpu metrics from gopsutils CpuPercent float64 `json:"cpu_pct"` // cpu percent Connections []net.ConnectionStat `json:"connections"` // connections metrics from gopsutils Load load.AvgStat `json:"load"` // load metrics from gopsutils Memory Mem `json:"memory"` // memory metrics from gopsutils OpenFiles []process.OpenFilesStat `json:"openFiles"` // open files metrics from gopsutils GoRoutines uint64 `json:"goroutines"` // total number of go routines at run-time Uptime float64 `json:"uptime"` // uptime of the server GetRequests uint64 `json:"getRequests"` // total number of get requests across all services PostRequests uint64 `json:"postRequests"` // total number of post requests across all services PutRequests uint64 `json:"putRequests"` // total number of post requests across all services AvgGetTime float64 `json:"avgGetTime"` // avg GET request time AvgPostTime float64 `json:"avgPostTime"` // avg POST request time AvgPutTime float64 `json:"avgPutTime"` // avg PUT request time RPS float64 `json:"rps"` // throughput req/sec RPSPhysical float64 `json:"rpsPhysical"` // throughput req/sec using physical cpu RPSLogical float64 `json:"rpsLogical"` // throughput req/sec using logical cpu ProcFS ProcFS `json:"procfs"` // metrics from prometheus procfs MaxDBConnections uint64 `json:"maxDBConnections"` // max number of DB connections MaxIdleConnections uint64 `json:"maxIdleConnections"` // max number of idle DB connections // Migration server metrics MigrationRequests uint64 `json:"migrationRequests"` // total number of migration requests across all services MigrationPending uint64 `json:"migrationPending"` // total number of pending migration requests across all services MigrationInProgress uint64 `json:"migrationInProgress"` // total number of in progress migration requests across all services MigrationFailed uint64 `json:"migrationFailed"` // total number of failed migration requests across all services MigrationTermFailed uint64 `json:"migrationTermFailed"` // total number of term failed migration requests across all services MigrationCompleted uint64 `json:"migrationCompleted"` // total number of completed migration requests across all services MigrationQueued uint64 `json:"migrationQueued"` // total number of queued migration requests across all services MigrationExistInDB uint64 `json:"migrationExistInDB"` // total number of exist in db migration requests across all services }
Metrics provide various metrics about our server
type ProcFS ¶ added in v0.0.8
type ProcFS struct { CpuTotal float64 Vsize float64 Rss float64 OpenFDs float64 MaxFDs float64 MaxVsize float64 UserCPUs []float64 SystemCPUs []float64 SumUserCPUs float64 SumSystemCPUs float64 }
ProcFS represents prometheus profcs metrics
func ProcFSMetrics ¶ added in v0.0.8
func ProcFSMetrics() ProcFS
ProcFSMetrics returns procfs (prometheus) metrics
type RequestStats ¶ added in v0.0.8
type RequestStats struct { TotalGetRequests uint64 TotalPostRequests uint64 TotalPutRequests uint64 Time time.Time NumPhysicalCores int NumLogicalCores int }
RequestStats holds metrics related to number of requests on a server
func (*RequestStats) Update ¶ added in v0.0.8
func (r *RequestStats) Update()
Update RequestStatus metrics
type Route ¶ added in v0.0.1
type Route struct { Method string Path string Scope string Authorized bool Handler gin.HandlerFunc }
Route represents routes structure
type Templates ¶ added in v0.0.1
type Templates struct {
// contains filtered or unexported fields
}
Templates structure
type TmplRecord ¶ added in v0.0.1
type TmplRecord map[string]interface{}
TmplRecord represent template record
func MakeTmpl ¶
func MakeTmpl(fsys fs.FS, title string) TmplRecord
helper function to make initial template struct
func (TmplRecord) GetBytes ¶ added in v0.0.1
func (t TmplRecord) GetBytes(key string) []byte
GetBytes returns bytes object for given key
func (TmplRecord) GetElapsedTime ¶ added in v0.0.1
func (t TmplRecord) GetElapsedTime() string
GetElapsedTime returns elapsed time
func (TmplRecord) GetError ¶ added in v0.0.1
func (t TmplRecord) GetError() string
GetError returns error string
func (TmplRecord) GetInt ¶ added in v0.0.1
func (t TmplRecord) GetInt(key string) int
GetInt converts given value for provided key to int data-type
func (TmplRecord) GetString ¶ added in v0.0.1
func (t TmplRecord) GetString(key string) string
GetString converts given value for provided key to string data-type