process

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interceptor

func Interceptor(src io.Reader, dst io.Writer, out chan<- []byte) error

Interceptor copies bytes from src to dst while also sending each chunk to the out channel for observation. The channel receives raw byte slices as they are read; each slice is a fresh copy safe for concurrent use.

Interceptor runs until src returns io.EOF or any other read error. It closes the out channel when it finishes.

func PipelineIn

func PipelineIn(src io.Reader, dst io.Writer, errWriter io.Writer, chain *middleware.SwappableChain, logger *slog.Logger, out chan<- []byte) error

PipelineIn processes the parent→child direction (stdin). Parsed JSON-RPC requests are passed through the middleware chain. If a request is blocked, a JSON-RPC error response is written to errWriter (the upstream stdout) instead of forwarding to the child. Non-JSON or non-request messages are forwarded verbatim.

func PipelineOut

func PipelineOut(src io.Reader, dst io.Writer, chain *middleware.SwappableChain, logger *slog.Logger, out chan<- []byte) error

PipelineOut processes the child→parent direction (stdout). Parsed JSON-RPC responses are passed through the middleware chain. Non-JSON or non-response messages are forwarded verbatim.

func Run

func Run(ctx context.Context, args []string, logger *slog.Logger) error

Run launches the program described by args (args[0] is the executable, args[1:] are its arguments), wires up stdin/stdout interceptors, and forwards signals. It blocks until the child process exits and returns any error. The exit code of the child is propagated via *exec.ExitError.

func RunWithMiddleware

func RunWithMiddleware(ctx context.Context, args []string, logger *slog.Logger, chain *middleware.SwappableChain, metrics *monitor.Metrics, monSrv *monitor.Server) error

RunWithMiddleware launches the child process described by args and wires up PipelineIn/PipelineOut interceptors that run the provided middleware chain. If chain is nil it falls back to the plain Interceptor. monSrv and metrics may be nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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