controller

package
v0.0.0-...-e368295 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoError        = 1
	StartWithError = 2
	StopWithError  = 3
	NoOperation    = 4
)
View Source
const ControllerComponent string = "controller"
View Source
const PathPrefix = "/"
View Source
const ProfileModule = "profile"

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlRequest

type ControlRequest struct {
	// start / stop
	Operation string

	Pid int
	Tid int

	// json Options
	Options *json.RawMessage
}

type ControlResponse

type ControlResponse struct {
	Code int
	Msg  string
}

type Controller

type Controller interface {
	GetModuleKey() string
	RegistSubModules(subModules ...ExportSubModule)
	HandRequest(*ControlRequest) *ControlResponse
	GetOptions(*json.RawMessage) []Option
}

type ControllerAPI

type ControllerAPI interface {
	RegistController(c Controller)
	RegistModule(module string, subModules ...ExportSubModule)
}

type ControllerConfig

type ControllerConfig struct {
	Http    *HttpControllerConfig
	Modules []string
}

type ControllerFactory

type ControllerFactory struct {
	Controller ControllerAPI
}

func (*ControllerFactory) ConstructConfig

func (cf *ControllerFactory) ConstructConfig(viper *viper.Viper, tools *component.TelemetryTools) error

func (*ControllerFactory) RegistModule

func (cf *ControllerFactory) RegistModule(module string, subModules ...ExportSubModule)

type DefaultModule

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

func NewModule

func NewModule(name string, tools *component.TelemetryTools, status ModuleStatus) *DefaultModule

func (*DefaultModule) ClearSignal

func (m *DefaultModule) ClearSignal() <-chan struct{}

func (*DefaultModule) Name

func (m *DefaultModule) Name() string

func (*DefaultModule) RegisterSubModule

func (m *DefaultModule) RegisterSubModule(subModule string, start func() error, stop func() error) error

func (*DefaultModule) Start

func (m *DefaultModule) Start(opts ...Option) error

func (*DefaultModule) Status

func (m *DefaultModule) Status() ModuleStatus

func (*DefaultModule) Stop

func (m *DefaultModule) Stop(msg string) error

type ExportSubModule

type ExportSubModule func() (name string, start func() error, stop func() error)

type FileWatchOption

type FileWatchOption struct {
	File     string
	DataSize int
}

type HttpAPI

type HttpAPI struct {
	*http.ServeMux
	// contains filtered or unexported fields
}

func NewHttpAPI

func NewHttpAPI(tools *component.TelemetryTools) *HttpAPI

func (*HttpAPI) RegistController

func (hc *HttpAPI) RegistController(c Controller)

func (*HttpAPI) RegistModule

func (hc *HttpAPI) RegistModule(module string, subModules ...ExportSubModule)

func (*HttpAPI) ServeHTTP

func (hc *HttpAPI) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HttpControllerConfig

type HttpControllerConfig struct {
	Enable bool
	Port   string
}

type Module

type Module interface {
	RegisterSubModule(name string, start func() error, stop func() error) error
	Name() string
	Start(...Option) error
	Stop(msg string) error
	Status() ModuleStatus
	ClearSignal() <-chan struct{}
}

type ModuleStatus

type ModuleStatus int
const (
	Started ModuleStatus = iota
	Stopped
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithStopInterval

func WithStopInterval(duration time.Duration) Option

func WithStopSignal

func WithStopSignal(stopch <-chan struct{}) Option

type Profile

type Profile struct {
	Module
}

func NewProfileController

func NewProfileController(tools *component.TelemetryTools) *Profile

func (*Profile) GetModuleKey

func (p *Profile) GetModuleKey() string

func (*Profile) GetOptions

func (p *Profile) GetOptions(raw_opts *json.RawMessage) []Option

func (*Profile) HandRequest

func (p *Profile) HandRequest(req *ControlRequest) *ControlResponse

func (*Profile) RegistSubModules

func (p *Profile) RegistSubModules(subModules ...ExportSubModule)

type ProfileOption

type ProfileOption struct {
	// seconds
	Duration time.Duration

	// bytes
	FileWatch *FileWatchOption
}

func (*ProfileOption) UnmarshalJSON

func (o *ProfileOption) UnmarshalJSON(b []byte) error

type StartModule

type StartModule func() error

type StopModule

type StopModule func() error

Jump to

Keyboard shortcuts

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