pub struct HostPoolBuilder { /* private fields */ }Expand description
Builder for a HostPool
Implementations§
Source§impl HostPoolBuilder
impl HostPoolBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Instantiate a nnew HostPoolBuilder with default settings.
let builder = HostPoolBuilder::new();Sourcepub fn name<T: AsRef<str>>(self, name: T) -> Self
pub fn name<T: AsRef<str>>(self, name: T) -> Self
Set the name for the HostPool.
let builder = HostPoolBuilder::new().name("My Module");Sourcepub fn factory<F>(self, factory: F) -> Self
pub fn factory<F>(self, factory: F) -> Self
Set the WapcHost generator function to use when spawning new workers.
let engine = wasmtime_provider::WasmtimeEngineProvider::new(&bytes, None).unwrap();
let pool = HostPoolBuilder::new()
.factory(move || {
let engine = engine.clone();
WapcHost::new(Box::new(engine), None).unwrap()
})
.build();Sourcepub fn min_threads(self, min: usize) -> Self
pub fn min_threads(self, min: usize) -> Self
Set the minimum, base number of threads to spawn.
let builder = HostPoolBuilder::new().min_threads(1);Sourcepub fn max_threads(self, max: usize) -> Self
pub fn max_threads(self, max: usize) -> Self
Set the upper limit on the number of threads to spawn.
let builder = HostPoolBuilder::new().max_threads(5);Sourcepub fn max_idle(self, timeout: Duration) -> Self
pub fn max_idle(self, timeout: Duration) -> Self
Set the timeout for threads to self-close.
let builder = HostPoolBuilder::new().max_idle(Duration::from_secs(60));Sourcepub fn max_wait(self, duration: Duration) -> Self
pub fn max_wait(self, duration: Duration) -> Self
Set the maximum amount of time to wait before spawning a new worker.
let builder = HostPoolBuilder::new().max_wait(Duration::from_millis(100));Sourcepub fn build(self) -> HostPool
pub fn build(self) -> HostPool
Builds a HostPool with the current configuration. Warning: this will panic if a factory function is not supplied.
let engine = wasmtime_provider::WasmtimeEngineProvider::new(&bytes, None).unwrap();
let pool = HostPoolBuilder::new()
.factory(move || {
let engine = engine.clone();
WapcHost::new(Box::new(engine), None).unwrap()
})
.build();Trait Implementations§
Source§impl Debug for HostPoolBuilder
impl Debug for HostPoolBuilder
Auto Trait Implementations§
impl Freeze for HostPoolBuilder
impl !RefUnwindSafe for HostPoolBuilder
impl Send for HostPoolBuilder
impl Sync for HostPoolBuilder
impl Unpin for HostPoolBuilder
impl !UnwindSafe for HostPoolBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more