Documentation
¶
Index ¶
- Constants
- Variables
- func GetConfigParser(format ConfigFormat) (koanf.Parser, error)
- type ConfigFormat
- type ConfigLoaderFunc
- type ConfigManager
- type GoProcClient
- func (c *GoProcClient) Cleanup() error
- func (c *GoProcClient) Exec(args []string, cwd string, env []string, wait bool) (int, error)
- func (c *GoProcClient) Kill(pid int) error
- func (c *GoProcClient) ListProcesses() ([]*proto.ProcessInfo, error)
- func (c *GoProcClient) Signal(pid int, signal int) error
- func (c *GoProcClient) Status(pid int) (int, error)
- func (c *GoProcClient) Stderr(pid int) (string, error)
- func (c *GoProcClient) Stdout(pid int) (string, error)
- func (c *GoProcClient) Wait(pid int) (int, error)
- type GoProcConfig
- type GoProcServer
- func (cs *GoProcServer) Exec(ctx context.Context, req *proto.ExecProcessRequest) (*proto.ExecProcessResponse, error)
- func (cs *GoProcServer) Kill(ctx context.Context, req *proto.KillProcessRequest) (*proto.KillProcessResponse, error)
- func (cs *GoProcServer) ListProcesses(ctx context.Context, req *proto.ListProcessesRequest) (*proto.ListProcessesResponse, error)
- func (cs *GoProcServer) Signal(ctx context.Context, req *proto.SignalProcessRequest) (*proto.SignalProcessResponse, error)
- func (cs *GoProcServer) StartServer(ctx context.Context, port uint) error
- func (cs *GoProcServer) Status(ctx context.Context, req *proto.StatusProcessRequest) (*proto.StatusProcessResponse, error)
- func (cs *GoProcServer) Stderr(ctx context.Context, req *proto.StderrProcessRequest) (*proto.StderrProcessResponse, error)
- func (cs *GoProcServer) Stdout(ctx context.Context, req *proto.StdoutProcessRequest) (*proto.StdoutProcessResponse, error)
- func (cs *GoProcServer) Wait(ctx context.Context, req *proto.WaitProcessRequest) (*proto.WaitProcessResponse, error)
- type ParserFunc
- type Process
- func (p *Process) Exec(args []string, cwd string, env []string, wait bool) (int, error)
- func (p *Process) ExitCode() int
- func (p *Process) Kill() error
- func (p *Process) Logs() string
- func (p *Process) Running() bool
- func (p *Process) Signal(sig os.Signal) error
- func (p *Process) Stderr() string
- func (p *Process) Stdout() string
- func (p *Process) Wait() (int, error)
- type SafeBuffer
Constants ¶
const (
GoProcVersion string = "dev"
)
Variables ¶
var (
ErrProcessNotFound = errors.New("process not found")
)
Functions ¶
func GetConfigParser ¶
func GetConfigParser(format ConfigFormat) (koanf.Parser, error)
Types ¶
type ConfigFormat ¶
type ConfigFormat string
var ( JSONConfigFormat ConfigFormat = ".json" YAMLConfigFormat ConfigFormat = ".yaml" YMLConfigFormat ConfigFormat = ".yml" )
type ConfigLoaderFunc ¶
ConfigLoaderFunc is a function type used to load configuration into a Koanf instance. It takes a Koanf pointer 'k' as a parameter and returns an error if the loading process encounters any issues.
type ConfigManager ¶
type ConfigManager[T any] struct { // contains filtered or unexported fields }
ConfigManager is a generic configuration manager that allows handling and manipulation of configuration data for various types. It includes a Koanf instance ('kf') for managing configuration settings.
func NewConfigManager ¶
func NewConfigManager[T any]() (*ConfigManager[T], error)
NewConfigManager creates a new instance of the ConfigManager[T] type for managing configuration of type 'T'. It initializes the ConfigManager with the specified 'T' type, loads a default configuration, and optionally loads a user configuration if the 'CONFIG_PATH' environment variable is provided. If debug mode is enabled, it prints the current configuration.
func (*ConfigManager[T]) GetConfig ¶
func (cm *ConfigManager[T]) GetConfig() T
GetConfig retrieves the current configuration of type 'T' from the ConfigManager. It unmarshals the configuration data and returns it. If any errors occur during unmarshaling, it logs a fatal error and exits the application.
func (*ConfigManager[T]) LoadConfig ¶
func (cm *ConfigManager[T]) LoadConfig(format ConfigFormat, provider koanf.Provider) error
LoadConfig loads configuration data from a given provider in the specified format into the ConfigManager. It obtains a parser for the format, and then loads the configuration data. If any errors occur during the loading process, they are returned as an error.
func (*ConfigManager[T]) Print ¶
func (cm *ConfigManager[T]) Print() string
Print returns a string representation of the current configuration state.
type GoProcClient ¶
type GoProcClient struct {
// contains filtered or unexported fields
}
func NewGoProcClient ¶
func (*GoProcClient) Cleanup ¶
func (c *GoProcClient) Cleanup() error
func (*GoProcClient) Kill ¶ added in v0.1.2
func (c *GoProcClient) Kill(pid int) error
func (*GoProcClient) ListProcesses ¶ added in v0.1.2
func (c *GoProcClient) ListProcesses() ([]*proto.ProcessInfo, error)
func (*GoProcClient) Signal ¶ added in v0.1.2
func (c *GoProcClient) Signal(pid int, signal int) error
func (*GoProcClient) Stderr ¶ added in v0.1.2
func (c *GoProcClient) Stderr(pid int) (string, error)
type GoProcConfig ¶
type GoProcConfig struct {
ServerPort uint `key:"serverPort" json:"server_port"`
GRPCDialTimeoutS int `key:"grpcDialTimeoutS" json:"grpc_dial_timeout_s"`
GRPCMessageSizeBytes int `key:"grpcMessageSizeBytes" json:"grpc_message_size_bytes"`
DebugMode bool `key:"debugMode" json:"debug_mode"`
PrettyLogs bool `key:"prettyLogs" json:"pretty_logs"`
}
type GoProcServer ¶
type GoProcServer struct {
proto.UnimplementedGoProcServer
// contains filtered or unexported fields
}
func NewGoProcServer ¶
func NewGoProcServer(cfg GoProcConfig) (*GoProcServer, error)
func (*GoProcServer) Exec ¶
func (cs *GoProcServer) Exec(ctx context.Context, req *proto.ExecProcessRequest) (*proto.ExecProcessResponse, error)
func (*GoProcServer) Kill ¶
func (cs *GoProcServer) Kill(ctx context.Context, req *proto.KillProcessRequest) (*proto.KillProcessResponse, error)
func (*GoProcServer) ListProcesses ¶
func (cs *GoProcServer) ListProcesses(ctx context.Context, req *proto.ListProcessesRequest) (*proto.ListProcessesResponse, error)
func (*GoProcServer) Signal ¶
func (cs *GoProcServer) Signal(ctx context.Context, req *proto.SignalProcessRequest) (*proto.SignalProcessResponse, error)
func (*GoProcServer) StartServer ¶
func (cs *GoProcServer) StartServer(ctx context.Context, port uint) error
func (*GoProcServer) Status ¶
func (cs *GoProcServer) Status(ctx context.Context, req *proto.StatusProcessRequest) (*proto.StatusProcessResponse, error)
func (*GoProcServer) Stderr ¶
func (cs *GoProcServer) Stderr(ctx context.Context, req *proto.StderrProcessRequest) (*proto.StderrProcessResponse, error)
func (*GoProcServer) Stdout ¶
func (cs *GoProcServer) Stdout(ctx context.Context, req *proto.StdoutProcessRequest) (*proto.StdoutProcessResponse, error)
func (*GoProcServer) Wait ¶
func (cs *GoProcServer) Wait(ctx context.Context, req *proto.WaitProcessRequest) (*proto.WaitProcessResponse, error)
type ParserFunc ¶
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
type SafeBuffer ¶
type SafeBuffer struct {
// contains filtered or unexported fields
}
func (*SafeBuffer) String ¶
func (b *SafeBuffer) String() string
func (*SafeBuffer) StringAndReset ¶
func (b *SafeBuffer) StringAndReset() string