#[non_exhaustive]pub struct ServiceWorkerManager { /* private fields */ }
Expand description
ServiceWorkerManager
allows plugin services
to create long-live jobs and manage their life cycle.
Implementations§
Source§impl ServiceWorkerManager
impl ServiceWorkerManager
Sourcepub fn register_job<F>(&self, job: F) -> Result<()>where
F: FnOnce(CancellationToken) + 'static,
pub fn register_job<F>(&self, job: F) -> Result<()>where
F: FnOnce(CancellationToken) + 'static,
Add a new job to the execution. Job work life cycle will be tied to the service life cycle; this means that job will be canceled just before service is stopped.
§Arguments
job
: callback that will be executed in separated fiber. Note that it is your responsibility to organize job graceful shutdown, see aCancellationToken
for details.
§Examples
use std::time::Duration;
use picodata_plugin::background::CancellationToken;
// this job will print "hello" every second,
// and print "bye" after being canceled
fn hello_printer(cancel: CancellationToken) {
while cancel.wait_timeout(Duration::from_secs(1)).is_err() {
println!("hello!");
}
println!("job cancelled, bye!")
}
worker_manager.register_job(hello_printer).unwrap();
Sourcepub fn register_tagged_job<F>(&self, job: F, tag: &str) -> Result<()>where
F: FnOnce(CancellationToken) + 'static,
pub fn register_tagged_job<F>(&self, job: F, tag: &str) -> Result<()>where
F: FnOnce(CancellationToken) + 'static,
Same as ServiceWorkerManager::register_job
but caller may provide a special tag.
This tag may be used for manual job cancellation using ServiceWorkerManager::cancel_tagged
.
§Arguments
job
: callback that will be executed in separated fibertag
: tag, that will be related to a job, single tag may be related to the multiple jobs
Sourcepub fn cancel_tagged(&self, tag: &str, timeout: Duration) -> Result<(), Error>
pub fn cancel_tagged(&self, tag: &str, timeout: Duration) -> Result<(), Error>
Cancel all jobs related to the given tag.
This function return after all related jobs will be gracefully shutdown or
after timeout
duration.
May return Error::PartialCompleted
if timeout is reached.
§Arguments
tag
: determine what jobs should be cancelledtimeout
: shutdown timeout
Sourcepub fn set_shutdown_timeout(&self, timeout: Duration)
👎Deprecated: use PicoContext::set_jobs_shutdown_timeout
instead
pub fn set_shutdown_timeout(&self, timeout: Duration)
PicoContext::set_jobs_shutdown_timeout
insteadIn case when jobs were canceled by picodata
use this function for determine
a shutdown timeout - time duration that picodata
uses to ensure that all
jobs gracefully end.
By default, 5-second timeout are used.
Trait Implementations§
Source§impl Clone for ServiceWorkerManager
impl Clone for ServiceWorkerManager
Source§fn clone(&self) -> ServiceWorkerManager
fn clone(&self) -> ServiceWorkerManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ServiceWorkerManager
impl RefUnwindSafe for ServiceWorkerManager
impl Send for ServiceWorkerManager
impl Sync for ServiceWorkerManager
impl Unpin for ServiceWorkerManager
impl UnwindSafe for ServiceWorkerManager
Blanket Implementations§
Source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoClones<(T,)> for Twhere
T: Clone,
impl<T> IntoClones<(T,)> for Twhere
T: Clone,
fn into_clones(self) -> (T,)
Source§impl<T> IntoClones<(T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T)
Source§impl<T> IntoClones<(T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T)
Source§impl<T> IntoClones<(T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T, T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T, T, T, T, T, T)
Source§impl<T> IntoClones<(T, T, T, T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
impl<T> IntoClones<(T, T, T, T, T, T, T, T, T, T, T)> for Twhere
T: Clone,
fn into_clones(self) -> (T, T, T, T, T, T, T, T, T, T, T)
Source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more