diagnostic

package
v27.4.0-rc.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 270

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugHTTPForm

func DebugHTTPForm(r *http.Request)

DebugHTTPForm helper to print the form url parameters

func HTTPReply

func HTTPReply(w http.ResponseWriter, r *HTTPResult, j *JSONOutput) (int, error)

HTTPReply helper function that takes care of sending the message out

Types

type ErrorCmd

type ErrorCmd struct {
	Error string `json:"error"`
}

ErrorCmd command with error

func (*ErrorCmd) String

func (e *ErrorCmd) String() string

type HTTPResult

type HTTPResult struct {
	Message string          `json:"message"`
	Details StringInterface `json:"details"`
}

HTTPResult Diagnostic Server HTTP result operation

func CommandSucceed

func CommandSucceed(result StringInterface) *HTTPResult

CommandSucceed creates a success message

func FailCommand

func FailCommand(err error) *HTTPResult

FailCommand creates a failure message with error

func WrongCommand

func WrongCommand(message, usage string) *HTTPResult

WrongCommand creates a wrong command response

func (*HTTPResult) String

func (h *HTTPResult) String() string

type JSONOutput

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

JSONOutput contains details on JSON output printing

func ParseHTTPFormOptions

func ParseHTTPFormOptions(r *http.Request) (bool, *JSONOutput)

ParseHTTPFormOptions easily parse the JSON printing options

type NetworkStatsResult

type NetworkStatsResult struct {
	Entries  int `json:"entries"`
	QueueLen int `jsoin:"qlen"`
}

NetworkStatsResult network db stats related to entries and queue len for a network

func (*NetworkStatsResult) String

func (n *NetworkStatsResult) String() string

type PeerEntryObj

type PeerEntryObj struct {
	Index int    `json:"-"`
	Name  string `json:"-=name"`
	IP    string `json:"ip"`
}

PeerEntryObj entry in the networkdb peer table

func (*PeerEntryObj) String

func (p *PeerEntryObj) String() string

type Server

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

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

func New

func New() *Server

New creates a new diagnostic server

func (*Server) DisableDiagnostic

func (s *Server) DisableDiagnostic()

DisableDiagnostic stop the debug and closes the tcp socket

func (*Server) EnableDiagnostic

func (s *Server) EnableDiagnostic(ip string, port int)

EnableDiagnostic opens a TCP socket to debug the passed network DB

func (*Server) Handle

func (s *Server) Handle(pattern string, handler http.Handler)

Handle registers the handler for the given pattern, replacing any existing handler.

func (*Server) HandleFunc

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 (*Server) IsDiagnosticEnabled

func (s *Server) IsDiagnosticEnabled() bool

IsDiagnosticEnabled returns true when the debug is enabled

func (*Server) ServeHTTP

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

type StringCmd

type StringCmd struct {
	Info string `json:"info"`
}

StringCmd command with info string

func (*StringCmd) String

func (s *StringCmd) String() string

type StringInterface

type StringInterface interface {
	String() string
}

StringInterface interface that has to be implemented by messages

type TableEndpointsResult

type TableEndpointsResult struct {
	TableObj
	Elements []TableEntryObj `json:"entries"`
}

TableEndpointsResult fully typed message for proper unmarshaling on the client side

type TableEntryObj

type TableEntryObj struct {
	Index int    `json:"-"`
	Key   string `json:"key"`
	Value string `json:"value"`
	Owner string `json:"owner"`
}

TableEntryObj network db table entry object

func (*TableEntryObj) String

func (t *TableEntryObj) String() string

type TableObj

type TableObj struct {
	Length   int               `json:"size"`
	Elements []StringInterface `json:"entries"`
}

TableObj network db table object

func (*TableObj) String

func (t *TableObj) String() string

type TablePeersResult

type TablePeersResult struct {
	TableObj
	Elements []PeerEntryObj `json:"entries"`
}

TablePeersResult fully typed message for proper unmarshaling on the client side

type UsageCmd

type UsageCmd struct {
	Usage string `json:"usage"`
}

UsageCmd command with usage field

func (*UsageCmd) String

func (u *UsageCmd) String() string

Jump to

Keyboard shortcuts

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