Documentation ¶
Overview ¶
Package admin : - has a rpc over http server listening on a unix socket - support other packages to expose any admin functionality over the above server
Example for registering admin handler from another package ¶
// Add this while initializing the package in setup or init etc. admin.RegisterAdminHandler("PackageName", &PackageAdmin{}) admin.RegisterStatusHandler("PackageName", &PackageAdmin{})
// Convention is to keep the following code in admin.go in the respective package type PackageAdmin struct { }
// Status function is used for debug purposes by the admin interface
func (p *PackageAdmin) Status() map[string]interface{} { return map[string]interface{}{ "parameter-1" : value, "parameter-2" : value, } }
// The following function can be called from rudder-cli using getUDSClient().Call("PackageName.SomeAdminFunction", &arg, &reply)
func (p *PackageAdmin) SomeAdminFunction(arg *string, reply *string) error { *reply = "admin function output" return nil }
Index ¶
- func Init()
- func RegisterAdminHandler(name string, handler interface{})
- func RegisterStatusHandler(name string, handler PackageStatusHandler)
- func StartServer(ctx context.Context) error
- type Admin
- func (a *Admin) GetFormattedEnv(env string, reply *string) (err error)
- func (a *Admin) GetLoggingConfig(_ struct{}, reply *string) (err error)
- func (a *Admin) HeapDump(path, reply *string) (err error)
- func (a *Admin) PrintStack(_ struct{}, reply *string) (err error)
- func (a *Admin) ServerConfig(_ struct{}, reply *string) (err error)
- func (a *Admin) SetLogLevel(l LogLevel, reply *string) (err error)
- func (a *Admin) StartCpuProfile(path, reply *string) (err error)
- func (a *Admin) Status(_ struct{}, reply *string) (err error)
- func (a *Admin) StopCpuProfile(_ struct{}, reply *string) (err error)
- type LogLevel
- type PackageStatusHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAdminHandler ¶
func RegisterAdminHandler(name string, handler interface{})
RegisterAdminHandler is used by other packages to expose admin functions over the unix socket based rpc interface
func RegisterStatusHandler ¶
func RegisterStatusHandler(name string, handler PackageStatusHandler)
RegisterStatusHandler expects object implementing PackageStatusHandler interface
func StartServer ¶
StartServer starts an HTTP server listening on unix socket and serving rpc communication
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
func (*Admin) GetFormattedEnv ¶
GetFormattedEnv return the formatted env
func (*Admin) GetLoggingConfig ¶
GetLoggingConfig returns the logging configuration
func (*Admin) PrintStack ¶
PrintStack fetches stack traces of all running goroutines
func (*Admin) ServerConfig ¶
ServerConfig fetches current configuration as set in viper
func (*Admin) StartCpuProfile ¶
StartCpuProfile starts writing cpu profile at given path using pprof
func (*Admin) Status ¶
Status reports overall server status by fetching status of all registered admin handlers
func (*Admin) StopCpuProfile ¶
StopCpuProfile stops writing already cpu profile
type PackageStatusHandler ¶
type PackageStatusHandler interface {
Status() interface{}
}
PackageStatusHandler to be implemented by the package objects that are registered as status handlers output of Status() is expected to be json encodable by default