session

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsExecError

func AsExecError(err error, target **exec.Error) bool

func AsExitError

func AsExitError(err error, target **exec.ExitError) bool

func ClearHealthURLFile

func ClearHealthURLFile(alias string, root state.Root)

func DefaultProfileDir

func DefaultProfileDir(lookupEnv func(string) (string, bool)) (string, error)

func LogPath

func LogPath(alias string, root state.Root) string

func LogTail

func LogTail(pathValue string, maxLines int) string

func NormalizeHealthBaseURL

func NormalizeHealthBaseURL(rawHealthURL string) string

func NormalizeProfileName

func NormalizeProfileName(profileName string, alias string) (string, error)

func PIDIsRunning

func PIDIsRunning(pid int) bool

func ParsePortFromHealthURL

func ParsePortFromHealthURL(raw string) int

func ProfileHealthURLFile

func ProfileHealthURLFile(alias string, root state.Root) string

func ReadHealthURL

func ReadHealthURL(path string) string

func ResolveProfileDir

func ResolveProfileDir(profileDir string, lookupEnv func(string) (string, bool)) (string, error)

func TerminateProcess

func TerminateProcess(pid int) error

func TmuxAvailable

func TmuxAvailable(rt Runtime) (bool, error)

func TmuxHasSessionName

func TmuxHasSessionName(rt Runtime, sessionName string) (bool, error)

func TmuxSessionName

func TmuxSessionName(alias string, root state.Root) string

func TunnelClientArgs

func TunnelClientArgs(tunnelClientBin string, profileName string, profileDir string) []string

func TunnelClientCommand

func TunnelClientCommand(tunnelClientBin string, profileName string, profileDir string) string

func WaitForProcessExit

func WaitForProcessExit(pid int) bool

func WriteRuntimeProfile

func WriteRuntimeProfile(
	alias string,
	profileName string,
	tunnelID string,
	baseURL string,
	urlPath string,
	apiKey string,
	target Target,
	profileDir string,
	root state.Root,
	lookupEnv func(string) (string, bool),
) (string, error)

Types

type CompletedProcess

type CompletedProcess struct {
	ReturnCode int
	Stdout     string
	Stderr     string
}

func StartTmux

func StartTmux(rt Runtime, sessionName string, tunnelClientBin string, profileName string, profileDir string, env map[string]string, logPath string) (CompletedProcess, error)

func StopTmux

func StopTmux(rt Runtime, sessionName string) (CompletedProcess, error)

type EndpointProbe

type EndpointProbe struct {
	URL    string `json:"url,omitempty"`
	OK     bool   `json:"ok"`
	Status int    `json:"status,omitempty"`
	Body   string `json:"body,omitempty"`
	Error  string `json:"error,omitempty"`
}

type HealthProbe

type HealthProbe struct {
	BaseURL string        `json:"base_url,omitempty"`
	Healthz EndpointProbe `json:"healthz"`
	Readyz  EndpointProbe `json:"readyz"`
}

func ProbeHealthEndpoints

func ProbeHealthEndpoints(rawHealthURL string) HealthProbe

type LaunchResult

type LaunchResult struct {
	Mode           string `json:"mode"`
	Command        string `json:"command"`
	Launched       bool   `json:"launched"`
	Started        bool   `json:"started"`
	Running        bool   `json:"running"`
	Healthy        bool   `json:"healthy"`
	Ready          bool   `json:"ready"`
	AlreadyRunning bool   `json:"already_running"`
	HealthURL      string `json:"health_url,omitempty"`
	SessionName    string `json:"session_name,omitempty"`
	PID            int    `json:"pid,omitempty"`
	LogPath        string `json:"log_path,omitempty"`
	ExitCode       *int   `json:"exit_code,omitempty"`
	LogTail        string `json:"log_tail,omitempty"`
}

func StartOrReuse

func StartOrReuse(
	rt Runtime,
	alias string,
	profileName string,
	profileDir string,
	tunnelClientBin string,
	root state.Root,
	envOverrides map[string]string,
	existingPID int,
	replaceExisting bool,
) (LaunchResult, error)

type Process

type Process interface {
	PID() int
	Poll() *int
}

type Runner

type Runner func(args []string, env map[string]string) (CompletedProcess, error)

type RunnerWithInput

type RunnerWithInput func(args []string, env map[string]string, stdin string) (CompletedProcess, error)

type Runtime

type Runtime struct {
	Run      Runner
	RunInput RunnerWithInput
	Start    Starter
}

func DefaultRuntime

func DefaultRuntime() Runtime

type RuntimeObservation

type RuntimeObservation struct {
	Running     bool        `json:"running"`
	HealthURL   string      `json:"health_url,omitempty"`
	Healthy     bool        `json:"healthy"`
	Ready       bool        `json:"ready"`
	HealthProbe HealthProbe `json:"health_probe"`
}

func WaitForRuntimeHealth

func WaitForRuntimeHealth(rt Runtime, alias string, root state.Root, mode string, pid int, sessionName string) RuntimeObservation

type Starter

type Starter func(args []string, env map[string]string, logPath string) (Process, error)

type Target

type Target struct {
	Kind  string
	Value string
}

Jump to

Keyboard shortcuts

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