pub struct SharedServiceBuilder { /* private fields */ }Expand description
Builder for SharedService.
Implementations§
Sourcepub fn base_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn base_dir(self, dir: impl Into<PathBuf>) -> Self
Set base directory for service info files.
Sourcepub fn on_first_acquire<F, Fut>(self, f: F) -> Self
pub fn on_first_acquire<F, Fut>(self, f: F) -> Self
Set callback for first client (service startup).
This is called when the first client acquires a reference. It should start the service and return ServiceInfo.
Sourcepub fn on_last_release<F, Fut>(self, f: F) -> Self
pub fn on_last_release<F, Fut>(self, f: F) -> Self
Set callback for last client (service shutdown).
This is called when the last client releases their reference. It should stop the service.
Sourcepub fn on_health_check<F, Fut>(self, f: F) -> Self
pub fn on_health_check<F, Fut>(self, f: F) -> Self
Set callback for health check.
This is called to verify the service is healthy. Return true if healthy, false if recovery is needed.
Sourcepub fn on_recover<F, Fut>(self, f: F) -> Selfwhere
F: Fn(ServiceInfo) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ServiceInfo>> + Send + 'static,
pub fn on_recover<F, Fut>(self, f: F) -> Selfwhere
F: Fn(ServiceInfo) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ServiceInfo>> + Send + 'static,
Set callback for recovery.
This is called when health check fails. It should recover the service and return new ServiceInfo.
Sourcepub fn build(self) -> Result<SharedService>
pub fn build(self) -> Result<SharedService>
Build the SharedService.
Auto Trait Implementations§
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