web_monitor

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebHandleMonitor = 0 // handler for monitor
	WebHandleReload  = 1 // handler for reload
	WebHandlePprof   = 2 // handler for pprof
)

type of web handler

Variables

View Source
var RELOAD_SRC_ALLOWED = map[string]bool{
	"127.0.0.1": true,
	"::1":       true,
}

source ip address allowed to do reload

Functions

func CreateCounterDiffHandler

func CreateCounterDiffHandler(getter GetCounterDiffFunc) interface{}

CreateCounterDiffHandler creates monitor handler for CounterDiff

Params:

  • getter: func for getting CounterDiff

Returns:

  • a monitor handler

func CreateDelayOutputHandler

func CreateDelayOutputHandler(getter GetDelayOutputFunc) interface{}

CreateDelayOutputHandler creates monitor handler for DelayRecent

Params:

  • getter: func for getting DelayOutput

Returns:

  • a monitor handler

func CreateMemStatsHandler

func CreateMemStatsHandler(keyPrefix string) interface{}

CreateMemStatsHandler creates monitor handler for getting memory statistics

Params:

  • keyPrefix: prefix of key, eg. <ServerName>_mem_stats

Return:

  • a monitor handler

func CreateStateDataHandler

func CreateStateDataHandler(getter GetStateDataFunc) interface{}

CreateStateDataHandler creates monitor handler for StateData

Params:

  • getter: func for getting StateData

Returns:

  • a monitor handler

func GetFormatParam

func GetFormatParam(params map[string][]string) string

get format parameter

func InitReloadACL

func InitReloadACL(filename string) error

InitReloadACL inits reload-acl from file.

func MemStatsKVEncode

func MemStatsKVEncode(stat runtime.MemStats, keyPrefix string) ([]byte, error)

MemStatsKVEncode gets encode data of MemStats in key-value format

func RegisterHandlers

func RegisterHandlers(wh *WebHandlers, hType int, ht map[string]interface{}) error

RegisterHandlers registers handlers in handler-table to WebHandlers

Params:

  • wh : WebHandlers
  • hType : hanlder type, WebHandleMonitor or WebHandleReload or WebHandlePprof
  • ht : handler table

Types

type GetCounterDiffFunc

type GetCounterDiffFunc func() *module_state2.CounterDiff

function prototype for getting CounterDiff/DelayOutput/StateData

type GetDelayOutputFunc

type GetDelayOutputFunc func() *delay_counter.DelayOutput

type GetStateDataFunc

type GetStateDataFunc func() *module_state2.StateData

type MonitorServer

type MonitorServer struct {
	// contains filtered or unexported fields
}

func NewMonitorServer

func NewMonitorServer(name string, version string, port int) *MonitorServer

NewMonitorServer creates new MonitorServer

func (*MonitorServer) HandlersSet

func (srv *MonitorServer) HandlersSet(handlers *WebHandlers)

HandlersSet sets handlers

func (*MonitorServer) ListenAndServe

func (srv *MonitorServer) ListenAndServe() error

ListenAndServe start embeded web server

func (*MonitorServer) RegisterHandler

func (srv *MonitorServer) RegisterHandler(hType int, command string, f interface{}) error

RegisterHandler registers handler

func (*MonitorServer) RegisterHandlers

func (srv *MonitorServer) RegisterHandlers(hType int, ht map[string]interface{}) error

RegisterHandlers registers handlers in handler-table to WebHandlers

Params:

  • hType : hanlder type, WebHandleMonitor or WebHandleReload or WebHandlePprof
  • ht : handler table

func (*MonitorServer) Start

func (srv *MonitorServer) Start()

Start starts embeded web server

type WebHandlerMap

type WebHandlerMap map[string]interface{}

func NewWebHandlerMap

func NewWebHandlerMap() *WebHandlerMap

NewWebHandlerMap creates new WebHandlerMap

type WebHandlers

type WebHandlers struct {
	Handlers map[int]*WebHandlerMap
}

func NewWebHandlers

func NewWebHandlers() *WebHandlers

NewWebHandlers creates new WebHandlers

func (*WebHandlers) GetHandler

func (wh *WebHandlers) GetHandler(hType int, command string) (interface{}, error)

GetHandler gets handler list for given callback point

func (*WebHandlers) RegisterHandler

func (wh *WebHandlers) RegisterHandler(hType int, command string, f interface{}) error

RegisterHandler adds filter to given callback point

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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