diag

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 15 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDiagSet = NewDiagSet()

DefaultDiagSet is the default Set to use.

Functions

This section is empty.

Types

type CommandSource

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

CommandSource executes the specified command and returns the stdout contents as diagnostics info

func NewCommandSource

func NewCommandSource(ext string, cmd []string) *CommandSource

NewCommandSource creates a new CommandSource.

func (*CommandSource) DiagnosticInfo

func (s *CommandSource) DiagnosticInfo() (Result, error)

DiagnosticInfo implements DiagnosticInfo method of the Source interface.

type LogDirSource

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

LogDirSource bundles together log files from the specified directory.

func NewLogDirSource

func NewLogDirSource(logDir string) *LogDirSource

NewLogDirSource creates a new LogDirSource.

func (*LogDirSource) DiagnosticInfo

func (s *LogDirSource) DiagnosticInfo() (Result, error)

DiagnosticInfo implements DiagnosticInfo method of the Source interface.

type Result

type Result struct {
	// Name is the name of the item sans extension.
	Name string `json:"name,omitempty"`
	// Ext is the file extension to use.
	Ext string `json:"ext,omitempty"`
	// Data is the content returned by the Source.
	Data string `json:"data,omitempty"`
	// IsDir specifies whether this diagnostics result
	// needs to be unpacked to a directory.
	IsDir bool `json:"isdir"`
	// Children denotes the child items to be placed into the
	// subdirectory that should be made for this Result during
	// unpacking.
	Children map[string]Result `json:"children,omitempty"`
	// Error contains an error message in case if the Source
	// has failed to provide the information.
	Error string `json:"error,omitempty"`
}

Result denotes the result of a diagnostics run.

func DecodeDiagnostics

func DecodeDiagnostics(data []byte) (Result, error)

DecodeDiagnostics loads the diagnostics info from the JSON data.

func RetrieveDiagnostics

func RetrieveDiagnostics(socketPath string) (Result, error)

RetrieveDiagnostics retrieves the diagnostic info from the specified UNIX domain socket.

func (Result) FileName

func (dr Result) FileName() string

FileName returns the file name for this Result.

func (Result) ToJSON

func (dr Result) ToJSON() []byte

ToJSON encodes Result into JSON.

func (Result) Unpack

func (dr Result) Unpack(parentDir string) error

Unpack unpacks Result under the specified directory.

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server denotes a diagnostics server that listens on a unix domain socket and spews out a piece of JSON content on a socket connection.

func NewServer

func NewServer(diagSet *Set) *Server

NewServer makes a new diagnostics server using the specified Set. If diagSet is nil, DefaultDiagSet is used.

func (*Server) Serve

func (s *Server) Serve(socketPath string, readyCh chan struct{}) error

Serve makes the server listen on the specified socket path. If readyCh is not nil, it'll be closed when the server is ready to accept connections. This function doesn't return till the server stops listening.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server.

type Set

type Set struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Set denotes a set of diagnostics sources.

func NewDiagSet

func NewDiagSet() *Set

NewDiagSet creates a new Set.

func (*Set) RegisterDiagSource

func (ds *Set) RegisterDiagSource(name string, source Source)

RegisterDiagSource registers a diagnostics source.

func (*Set) RunDiagnostics

func (ds *Set) RunDiagnostics() Result

RunDiagnostics collects the diagnostic information from all of the available sources.

type SimpleTextSource

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

SimpleTextSource invokes the specified function that returns a string (and an error, if any) and wraps its result in Result

func NewSimpleTextSource

func NewSimpleTextSource(ext string, toCall SimpleTextSourceFunc) *SimpleTextSource

NewSimpleTextSource creates a new SimpleTextSource.

func (*SimpleTextSource) DiagnosticInfo

func (s *SimpleTextSource) DiagnosticInfo() (Result, error)

DiagnosticInfo implements DiagnosticInfo method of the Source interface.

type SimpleTextSourceFunc

type SimpleTextSourceFunc func() (string, error)

SimpleTextSourceFunc denotes a function that's invoked by SimpleTextSource to gather diagnostics info.

type Source

type Source interface {
	// DiagnosticInfo returns diagnostic information for the
	// source. DiagnosticInfo() may skip setting Name in the
	// Result, in which case it'll be set to the name used to
	// register the source.
	DiagnosticInfo() (Result, error)
}

Source speicifies a diagnostics information source

var StackDumpSource Source = stackDumpSource{}

StackDumpSource dumps Go runtime stack.

Jump to

Keyboard shortcuts

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