Trait JobHandler

Source
pub trait JobHandler<U = NoFiles>: Send
where U: UploadableFile + Send + 'static,
{ // Required method fn step<'life0, 'life1, 'async_trait>( &'life0 mut self, script: &'life1 [String], phase: Phase, ) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: '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

In the event of being cancelled by GitLab, the step function will have its future dropped instantly. If manual handling of cancellation is required, use CancellableJobHandler 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§

Source

fn step<'life0, 'life1, 'async_trait>( &'life0 mut self, script: &'life1 [String], phase: Phase, ) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: '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, its future will dropped, resulting in the function’s termination.

Note that gitlab concatinates the before_script and script arrays into a single Phase::Script step

Provided Methods§

Source

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.

Source

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 cancelled, allowing the job handler to clean up as necessary.

Implementors§