pub trait CancellableJobHandler<U = NoFiles>: Sendwhere
U: UploadableFile + Send + 'static,{
// Required method
fn step<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
script: &'life1 [String],
phase: Phase,
cancel_token: &'life2 CancellationToken,
) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn get_uploadable_files<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = U> + Send>, ()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn cleanup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Async trait for handling a single Job that handles its own cancellation
This trait is largely identical to JobHandler
, but its methods explicitly take a
CancellationToken
, which will be triggered if GitLab cancels the job, after which the method
will be responsible for cancellation appropriately. In most cases, the entire execution should
simply be cancelled, in which case JobHandler
’s default behavior is desirable instead. (Even
when cancelled, cleanup
will still be called, allowing any cleanup tasks to be performed.)
Note that this is an asynchronous trait which should be implemented by using the async_trait
crate. However this also means the rustdoc documentation is interesting…
Required Methods§
Sourcefn step<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
script: &'life1 [String],
phase: Phase,
cancel_token: &'life2 CancellationToken,
) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn step<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
script: &'life1 [String],
phase: Phase,
cancel_token: &'life2 CancellationToken,
) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Do a single step of a job
This gets called for each phase of the job (e.g. script and after_script). The passed
string array is the same array as was passed for a given step in the job definition. If the
job is cancelled while this is running, the given cancel_token
will be triggered.
Note that gitlab concatinates the before_script
and script
arrays into a single
Phase::Script step
Provided Methods§
Sourcefn get_uploadable_files<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = U> + Send>, ()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_uploadable_files<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = U> + Send>, ()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a list of the files available to upload
See the description UploadableFile
for more information.
Sourcefn cleanup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cleanup after the job is finished
This method always get called whether or not the job succeeded or was acancelled, allowing the job handler to clean up as necessary.