Documentation ¶
Index ¶
- Constants
- Variables
- func CreateCounterDiffHandler(getter GetCounterDiffFunc) interface{}
- func CreateDelayOutputHandler(getter GetDelayOutputFunc) interface{}
- func CreateMemStatsHandler(keyPrefix string) interface{}
- func CreateStateDataHandler(getter GetStateDataFunc) interface{}
- func GetFormatParam(params map[string][]string) string
- func InitReloadACL(filename string) error
- func MemStatsKVEncode(stat runtime.MemStats, keyPrefix string) ([]byte, error)
- func RegisterHandlers(wh *WebHandlers, hType int, ht map[string]interface{}) error
- type GetCounterDiffFunc
- type GetDelayOutputFunc
- type GetStateDataFunc
- type MonitorServer
- func (srv *MonitorServer) HandlersSet(handlers *WebHandlers)
- func (srv *MonitorServer) ListenAndServe() error
- func (srv *MonitorServer) RegisterHandler(hType int, command string, f interface{}) error
- func (srv *MonitorServer) RegisterHandlers(hType int, ht map[string]interface{}) error
- func (srv *MonitorServer) Start()
- type WebHandlerMap
- type WebHandlers
Constants ¶
const ( WebHandleMonitor = 0 // handler for monitor WebHandleReload = 1 // handler for reload WebHandlePprof = 2 // handler for pprof )
type of web handler
Variables ¶
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 InitReloadACL ¶
InitReloadACL inits reload-acl from file.
func MemStatsKVEncode ¶
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
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 (*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