Documentation
¶
Overview ¶
Package pythonsidecar provides a mechanism to manage the lifecycle of a Python process as a sidecar component in a Go application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Module is the Python module name to run using the "-m" flag. (Required)
Module string
// Args contains any additional arguments to pass to the module. (Optional)
Args []string
// Stdout redirects the sidecar's standard output. (Optional)
Stdout io.Writer
// Stderr redirects the sidecar's standard error. (Optional)
Stderr io.Writer
// ReadyFunc is an optional function to check if the server is ready to accept requests.
// When provided, Start will poll ReadyFunc until it returns nil or the context expires. (Optional)
ReadyFunc func(ctx context.Context) error
}
Config holds the configuration parameters for the sidecar lifecycle.
type SetupOptions ¶
type SetupOptions struct {
// FS is the embedded filesystem containing Python assets (e.g., python.FS). (Required)
FS fs.FS
}
SetupOptions configures asset extraction and environment setup for a Python sidecar.
type Sidecar ¶
type Sidecar struct {
// contains filtered or unexported fields
}
Sidecar manages the lifecycle of the underlying Python process.
func (*Sidecar) Start ¶
Start launches the Python process and monitors its lifecycle in the background. If ReadyFunc is configured, Start blocks until the server is ready or the context expires. If the process fails to start or become ready, an error is returned immediately.
func (*Sidecar) Stop ¶
Stop gracefully terminates the Python process using SIGTERM, falling back to SIGKILL if necessary.