admin

package
v1.5.0-preview.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

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

func StartServer(ctx context.Context) error

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

func (*Admin) GetFormattedEnv(env string, reply *string) (err error)

GetFormattedEnv return the formatted env

func (*Admin) GetLoggingConfig

func (*Admin) GetLoggingConfig(_ struct{}, reply *string) (err error)

GetLoggingConfig returns the logging configuration

func (*Admin) HeapDump

func (*Admin) HeapDump(path, reply *string) (err error)

HeapDump creates heap profile at given path using pprof

func (*Admin) PrintStack

func (*Admin) PrintStack(_ struct{}, reply *string) (err error)

PrintStack fetches stack traces of all running goroutines

func (*Admin) ServerConfig

func (*Admin) ServerConfig(_ struct{}, reply *string) (err error)

ServerConfig fetches current configuration as set in viper

func (*Admin) SetLogLevel

func (*Admin) SetLogLevel(l LogLevel, reply *string) (err error)

func (*Admin) StartCpuProfile

func (*Admin) StartCpuProfile(path, reply *string) (err error)

StartCpuProfile starts writing cpu profile at given path using pprof

func (*Admin) Status

func (a *Admin) Status(_ struct{}, reply *string) (err error)

Status reports overall server status by fetching status of all registered admin handlers

func (*Admin) StopCpuProfile

func (*Admin) StopCpuProfile(_ struct{}, reply *string) (err error)

StopCpuProfile stops writing already cpu profile

type LogLevel

type LogLevel struct {
	Module string
	Level  string
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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