pub struct VenvManager { /* private fields */ }Expand description
Builds and caches one plugin’s virtualenv.
Construction is cheap and does no I/O; ensure() does the work and is
called from the plugin’s initialize().
Implementations§
Source§impl VenvManager
impl VenvManager
Sourcepub fn new(
plugin_dirs: &[String],
class_name: &str,
requirements_file: Option<&str>,
manifest_version: Option<&str>,
) -> Result<Self, HostError>
pub fn new( plugin_dirs: &[String], class_name: &str, requirements_file: Option<&str>, manifest_version: Option<&str>, ) -> Result<Self, HostError>
Resolve the layout for a plugin and record its cache inputs.
requirements_file is interpreted relative to the resolved plugin
path when it is not already absolute, mirroring client.py’s
package_path / requirements_file_input.
Sourcepub fn with_pip_timeout_secs(self, secs: u64) -> Self
pub fn with_pip_timeout_secs(self, secs: u64) -> Self
Override the pip install timeout.
Configurable because the right bound is deployment-specific: an air-gapped mirror resolves in seconds, a cold cross-region install of a large wheel set can legitimately take minutes. Tests use a very small value to reach the timeout path without waiting out the default.
Sourcepub fn pip_timeout_secs(&self) -> u64
pub fn pip_timeout_secs(&self) -> u64
The wall-clock bound applied to one pip install.
Sourcepub fn layout(&self) -> &VenvLayout
pub fn layout(&self) -> &VenvLayout
The resolved on-disk layout.
Sourcepub fn owners(&self) -> VenvOwners
pub fn owners(&self) -> VenvOwners
The plugins currently claiming the shared venv directory.
Sourcepub fn python_executable(&self) -> PathBuf
pub fn python_executable(&self) -> PathBuf
The venv’s interpreter, for launching the worker.
Sourcepub fn cache_verdict(&self) -> CacheVerdict
pub fn cache_verdict(&self) -> CacheVerdict
Whether the cached venv is currently reusable, and why not if it isn’t.
Sourcepub async fn ensure(&self) -> Result<EnsureOutcome, HostError>
pub async fn ensure(&self) -> Result<EnsureOutcome, HostError>
Ensure a usable venv exists, building and installing only when the cache says it must.
All blocking work is moved off the runtime thread: the manager awaits
each plugin’s initialize() sequentially, so a cold pip install run
inline would stall every other plugin’s init and the rollback path.
Sourcepub async fn release_owner(&self) -> Result<(), HostError>
pub async fn release_owner(&self) -> Result<(), HostError>
Remove this plugin from the shared venv’s owner registry.
Called from the plugin’s shutdown path so a venv stops being treated as shared once its co-owners are gone — otherwise a stale claim would permanently downgrade every later rebuild to an in-place update, and a removed dependency would never actually disappear.