#[non_exhaustive]pub struct JobId {
pub id: Uuid,
pub task_id: TaskId,
}
Expand description
JobId
uniquely identifies running instance of Task
.
You don’t need to construct this object manually:
task_id
is provided fromScheduler
during planned starting of theTask
instance,job_id
is a created automaticallyUuid
.
Executor creates JobId
for each running job and provides it to job’s closure as a parameter (id
in the example below).
String representation of the JobId
is "{task_id}/{id}"
.
Common usage of JobId
inside task closure is for logging.
§Examples
use sacs::task::{Task, TaskSchedule};
use std::time::Duration;
let task = Task::new(TaskSchedule::Once, |id| {
Box::pin(async move {
println!("Starting job, TaskId={}, JobId={}.", id.task_id, id.id);
// Actual async workload here
tokio::time::sleep(Duration::from_secs(1)).await;
// ...
println!("Job {id} finished.");
})
});
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.id: Uuid
Unique ID of the running Job within particular Task
.
task_id: TaskId
ID of the Task
which owns this Job, is provided from Scheduler
during scheduled starting of the Task
instance.
Trait Implementations§
source§impl Ord for JobId
impl Ord for JobId
source§impl PartialEq for JobId
impl PartialEq for JobId
source§impl PartialOrd for JobId
impl PartialOrd for JobId
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for JobId
impl StructuralPartialEq for JobId
Auto Trait Implementations§
impl Freeze for JobId
impl RefUnwindSafe for JobId
impl Send for JobId
impl Sync for JobId
impl Unpin for JobId
impl UnwindSafe for JobId
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