process

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BridgeInfo

type BridgeInfo struct {
	Port  int
	Token string
}

type Controller

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

Controller implements a stateless approach to process management It queries the actual system state rather than maintaining internal state

func (*Controller) Configure

func (c *Controller) Configure(spec LaunchSpec) error

Configure sets up the controller with the given launch specification

func (*Controller) GetLaunchMode

func (c *Controller) GetLaunchMode() string

GetLaunchMode returns the launch mode

func (*Controller) GetPID

func (c *Controller) GetPID() int

GetPID returns the process ID if available

func (*Controller) GetStopProcessName

func (c *Controller) GetStopProcessName() string

GetStopProcessName returns the stop process name

func (*Controller) IsLauncherProcessRunning

func (c *Controller) IsLauncherProcessRunning() bool

IsLauncherProcessRunning checks if the launcher process itself is still running

func (*Controller) IsRunning

func (c *Controller) IsRunning() bool

IsRunning queries the actual system state to determine if the process is running This is stateless - it directly checks the real process state

func (*Controller) Kill

func (c *Controller) Kill() error

Kill forcefully terminates the process

func (*Controller) Restart

func (c *Controller) Restart() error

Restart stops and then starts the process

func (*Controller) SetBridgeInfo

func (c *Controller) SetBridgeInfo(port int, token string)

SetBridgeInfo sets the bridge connection information

func (*Controller) Start

func (c *Controller) Start() error

Start launches the process and waits for verification

func (*Controller) Stop

func (c *Controller) Stop(grace time.Duration) error

Stop gracefully stops the process

func (*Controller) WaitForProcessStart

func (c *Controller) WaitForProcessStart(timeout time.Duration) error

WaitForProcessStart waits for the process to be detectable in the system

type ControllerInterface

type ControllerInterface interface {
	Configure(spec LaunchSpec) error
	SetBridgeInfo(port int, token string)
	Start() error
	Stop(grace time.Duration) error
	Kill() error
	IsRunning() bool
	GetPID() int
	GetLaunchMode() string
	GetStopProcessName() string
	IsLauncherProcessRunning() bool
}

ControllerInterface defines the interface for process controllers

func NewController

func NewController() ControllerInterface

NewController creates a new controller instance This maintains the existing API while using the consolidated implementation

type GABPConnector

type GABPConnector interface {
	AttemptConnection(ctx context.Context, gameID string, port int, token string) bool
}

GABPConnector interface for testing and abstraction

type LaunchSpec

type LaunchSpec struct {
	GameId          string
	Mode            string // DirectPath|SteamAppId|EpicAppId|CustomCommand
	PathOrId        string
	Args            []string
	WorkingDir      string
	StopProcessName string // Optional process name for stopping the game
}

type ProcessError

type ProcessError struct {
	Type    ProcessErrorType
	Context string
	Err     error
}

ProcessError represents different types of process-related errors

func (*ProcessError) Error

func (e *ProcessError) Error() string

type ProcessErrorType

type ProcessErrorType int
const (
	ProcessErrorTypeConfiguration ProcessErrorType = iota
	ProcessErrorTypeStart
	ProcessErrorTypeStop
	ProcessErrorTypeStatus
	ProcessErrorTypeNotFound
)

type ProcessStartResult

type ProcessStartResult struct {
	ProcessStarted bool // Process found in system
	GABPConnected  bool // Successfully connected to GABP server
	Error          error
}

ProcessStartResult represents the result of a process start operation

type SerializedStarter

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

SerializedStarter ensures only one process is starting at a time This implements the serialized starting approach requested by @pardeike

func NewSerializedStarter

func NewSerializedStarter() *SerializedStarter

NewSerializedStarter creates a new serialized starter with default timeouts

func NewSerializedStarterForTesting

func NewSerializedStarterForTesting() *SerializedStarter

NewSerializedStarterForTesting creates a serialized starter with shorter timeouts for testing

func (*SerializedStarter) SetTimeouts

func (s *SerializedStarter) SetTimeouts(processStart, gabpConnect time.Duration)

SetTimeouts allows customization of timeout values

func (*SerializedStarter) StartWithVerification

func (s *SerializedStarter) StartWithVerification(
	controller ControllerInterface,
	gabpConnector GABPConnector,
	gameID string,
	port int,
	token string,
) *ProcessStartResult

StartWithVerification starts a process with full verification This method serializes the starting process as requested by @pardeike

Jump to

Keyboard shortcuts

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