goproc

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GoProcVersion string = "dev"
)

Variables

View Source
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

type ConfigLoaderFunc func(k *koanf.Koanf) error

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 NewGoProcClient(ctx context.Context, addr string, port uint) (*GoProcClient, error)

func (*GoProcClient) Cleanup

func (c *GoProcClient) Cleanup() error

func (*GoProcClient) Exec added in v0.1.2

func (c *GoProcClient) Exec(args []string, cwd string, env []string, wait bool) (int, 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) Status added in v0.1.2

func (c *GoProcClient) Status(pid int) (int, error)

func (*GoProcClient) Stderr added in v0.1.2

func (c *GoProcClient) Stderr(pid int) (string, error)

func (*GoProcClient) Stdout added in v0.1.2

func (c *GoProcClient) Stdout(pid int) (string, error)

func (*GoProcClient) Wait added in v0.1.2

func (c *GoProcClient) Wait(pid int) (int, 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 (*GoProcServer) Kill

func (*GoProcServer) ListProcesses

func (*GoProcServer) Signal

func (*GoProcServer) StartServer

func (cs *GoProcServer) StartServer(ctx context.Context, port uint) error

func (*GoProcServer) Status

func (*GoProcServer) Stderr

func (*GoProcServer) Stdout

func (*GoProcServer) Wait

type ParserFunc

type ParserFunc func() (koanf.Parser, error)

type Process

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

func NewProcess

func NewProcess(ctx context.Context) (*Process, error)

func (*Process) Exec

func (p *Process) Exec(args []string, cwd string, env []string, wait bool) (int, error)

func (*Process) ExitCode

func (p *Process) ExitCode() int

func (*Process) Kill

func (p *Process) Kill() error

func (*Process) Logs

func (p *Process) Logs() string

func (*Process) Running

func (p *Process) Running() bool

func (*Process) Signal

func (p *Process) Signal(sig os.Signal) error

func (*Process) Stderr

func (p *Process) Stderr() string

func (*Process) Stdout

func (p *Process) Stdout() string

func (*Process) Wait

func (p *Process) Wait() (int, error)

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

func (*SafeBuffer) Write

func (b *SafeBuffer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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