backends

package
v1.1.35 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunBackend

func RunBackend(ctx context.Context, config RunnerConfig) error

RunBackend runs a backend process with common error handling and logging. It handles: - Socket cleanup - Argument sanitization for logging - Process lifecycle management - Error channel handling - Context cancellation

func ValidateEnv added in v1.1.35

func ValidateEnv(env []string) error

ValidateEnv checks that every entry in env is in "KEY=VALUE" form with a non-empty key. It returns an error describing the first malformed entry.

Types

type ErrorTransformer added in v1.0.12

type ErrorTransformer func(output string) string

ErrorTransformer is a function that transforms raw error output into a more user-friendly message. Backends can provide their own implementation to customize error presentation.

type Logger

type Logger interface {
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
}

Logger interface for backend logging

type RunnerConfig

type RunnerConfig struct {
	// BackendName is the display name of the backend (e.g., "llama.cpp", "vLLM")
	BackendName string
	// Socket is the unix socket path
	Socket string
	// BinaryPath is the path to the backend binary
	BinaryPath string
	// SandboxPath is the sandbox directory path
	SandboxPath string
	// SandboxConfig is the sandbox configuration string
	SandboxConfig string
	// Args are the command line arguments
	Args []string
	// Logger provides logging functionality
	Logger Logger
	// ServerLogWriter provides a writer for server logs
	ServerLogWriter io.WriteCloser
	// ErrorTransformer is an optional function to transform error output
	// into a more user-friendly message. If nil, the raw output is used.
	ErrorTransformer ErrorTransformer
	// Env is an optional list of extra environment variables for the backend
	// process, each in "KEY=VALUE" form. These are appended to the current
	// process environment. If nil or empty, the backend inherits the parent
	// env as-is (an empty non-nil slice is treated the same as nil).
	Env []string
}

RunnerConfig holds configuration for a backend runner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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