pub struct InMemoryJobState { /* private fields */ }Expand description
Implementation of JobState which keeps all state in memory. If using InMemoryJobState
no job state will be shared between schedulers
Implementations§
Source§impl InMemoryJobState
impl InMemoryJobState
pub fn new( scheduler: impl Into<String>, session_builder: fn(SessionConfig) -> SessionState, ) -> Self
Trait Implementations§
Source§impl JobState for InMemoryJobState
impl JobState for InMemoryJobState
Source§fn submit_job<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: String,
graph: &'life1 ExecutionGraph,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn submit_job<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: String,
graph: &'life1 ExecutionGraph,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Submit a new job to the
JobState. It is assumed that the submitter owns the job.
In local state the job should be save as JobStatus::Active and in shared state
it should be saved as JobStatus::Running with scheduler set to the current schedulerSource§fn get_job_status<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<JobStatus>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_job_status<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<JobStatus>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch the job status
Source§fn get_execution_graph<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionGraph>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_execution_graph<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionGraph>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the
ExecutionGraph for job. The job may or may not belong to the caller
and should return the ExecutionGraph for the given job (if it exists) at the
time this method is called with no guarantees that the graph has not been
subsequently updated by another scheduler.Source§fn try_acquire_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionGraph>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_acquire_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ExecutionGraph>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attempt to acquire ownership of the given job. If the job is still in a running state
and is successfully acquired by the caller, return the current
ExecutionGraph,
otherwise return NoneSource§fn save_job<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
graph: &'life2 ExecutionGraph,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn save_job<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
graph: &'life2 ExecutionGraph,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Persist the current state of an owned job to global state. This should fail
if the job is not owned by the caller.
Source§fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<SessionContext>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<SessionContext>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the
SessionContext associated with session_id. Returns an error if the
session does not existSource§fn create_session<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 KapotConfig,
) -> Pin<Box<dyn Future<Output = Result<Arc<SessionContext>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_session<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 KapotConfig,
) -> Pin<Box<dyn Future<Output = Result<Arc<SessionContext>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new saved session
fn update_session<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
config: &'life2 KapotConfig,
) -> Pin<Box<dyn Future<Output = Result<Arc<SessionContext>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Arc<SessionContext>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn job_state_events<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<JobStateEventStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn job_state_events<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<JobStateEventStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a stream of all
JobState events. An event should be published any time that status
of a job changes in stateSource§fn remove_job<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_job<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a job from the global state
Source§fn get_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HashSet<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HashSet<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return a
Vec of all active job IDs in the JobStateSource§fn accept_job(&self, job_id: &str, job_name: &str, queued_at: u64) -> Result<()>
fn accept_job(&self, job_id: &str, job_name: &str, queued_at: u64) -> Result<()>
Accept job into a scheduler’s job queue. This should be called when a job is
received by the scheduler but before it is planned and may or may not be saved
in global state
Source§fn pending_job_number(&self) -> usize
fn pending_job_number(&self) -> usize
Get the number of queued jobs. If it’s big, then it means the scheduler is too busy.
In normal case, it’s better to be 0.
Source§fn fail_unscheduled_job<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
reason: String,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fail_unscheduled_job<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
reason: String,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark a job which has not been submitted as failed. This should be called if a job fails
during planning (and does not yet have an
ExecutionGraph)Auto Trait Implementations§
impl Freeze for InMemoryJobState
impl !RefUnwindSafe for InMemoryJobState
impl Send for InMemoryJobState
impl Sync for InMemoryJobState
impl Unpin for InMemoryJobState
impl !UnwindSafe for InMemoryJobState
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request