func DebugHTTPForm(r *http.Request)
DebugHTTPForm helper to print the form url parameters
func HTTPReply(w http.ResponseWriter, r *HTTPResult, j *JSONOutput) (int, error)
HTTPReply helper function that takes care of sending the message out
ErrorCmd command with error
type ErrorCmd struct { Error string `json:"error"` }
func (e *ErrorCmd) String() string
HTTPResult Diagnostic Server HTTP result operation
type HTTPResult struct { Message string `json:"message"` Details StringInterface `json:"details"` }
func CommandSucceed(result StringInterface) *HTTPResult
CommandSucceed creates a success message
func FailCommand(err error) *HTTPResult
FailCommand creates a failure message with error
func WrongCommand(message, usage string) *HTTPResult
WrongCommand creates a wrong command response
func (h *HTTPResult) String() string
JSONOutput contains details on JSON output printing
type JSONOutput struct {
// contains filtered or unexported fields
}
func ParseHTTPFormOptions(r *http.Request) (bool, *JSONOutput)
ParseHTTPFormOptions easily parse the JSON printing options
NetworkStatsResult network db stats related to entries and queue len for a network
type NetworkStatsResult struct { Entries int `json:"entries"` QueueLen int `jsoin:"qlen"` }
func (n *NetworkStatsResult) String() string
PeerEntryObj entry in the networkdb peer table
type PeerEntryObj struct { Index int `json:"-"` Name string `json:"-=name"` IP string `json:"ip"` }
func (p *PeerEntryObj) String() string
Server when the debug is enabled exposes a This data structure is protected by the Agent mutex so does not require and additional mutex here
type Server struct {
// contains filtered or unexported fields
}
func New() *Server
New creates a new diagnostic server
func (s *Server) DisableDiagnostic()
DisableDiagnostic stop the dubug and closes the tcp socket
func (s *Server) EnableDiagnostic(ip string, port int)
EnableDiagnostic opens a TCP socket to debug the passed network DB
func (s *Server) Handle(pattern string, handler http.Handler)
Handle registers the handler for the given pattern, replacing any existing handler.
func (s *Server) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
Handle registers the handler function for the given pattern, replacing any existing handler.
func (s *Server) IsDiagnosticEnabled() bool
IsDiagnosticEnabled returns true when the debug is enabled
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP this is the method called bu the ListenAndServe, and is needed to allow us to use our custom mux
StringCmd command with info string
type StringCmd struct { Info string `json:"info"` }
func (s *StringCmd) String() string
StringInterface interface that has to be implemented by messages
type StringInterface interface { String() string }
TableEndpointsResult fully typed message for proper unmarshaling on the client side
type TableEndpointsResult struct { TableObj Elements []TableEntryObj `json:"entries"` }
TableEntryObj network db table entry object
type TableEntryObj struct { Index int `json:"-"` Key string `json:"key"` Value string `json:"value"` Owner string `json:"owner"` }
func (t *TableEntryObj) String() string
TableObj network db table object
type TableObj struct { Length int `json:"size"` Elements []StringInterface `json:"entries"` }
func (t *TableObj) String() string
TablePeersResult fully typed message for proper unmarshaling on the client side
type TablePeersResult struct { TableObj Elements []PeerEntryObj `json:"entries"` }
UsageCmd command with usage field
type UsageCmd struct { Usage string `json:"usage"` }
func (u *UsageCmd) String() string