Skip to main content

Tasklet

Trait Tasklet 

Source
pub trait Tasklet {
    // Required method
    fn execute(
        &self,
        step_execution: &StepExecution,
    ) -> Result<RepeatStatus, BatchError>;
}
Expand description

A tasklet represents a single task or operation that can be executed as part of a step.

Tasklets are useful for operations that don’t fit the chunk-oriented processing model, such as file operations, database maintenance, or custom business logic.

§Examples

use spring_batch_rs::core::step::{StepExecution, RepeatStatus};
use spring_batch_rs::BatchError;

use spring_batch_rs::core::step::Tasklet;

struct FileCleanupTasklet {
    directory: String,
}

impl Tasklet for FileCleanupTasklet {
    fn execute(&self, _step_execution: &StepExecution) -> Result<RepeatStatus, BatchError> {
        // Perform file cleanup logic here
        println!("Cleaning up directory: {}", self.directory);
        Ok(RepeatStatus::Finished)
    }
}

Required Methods§

Source

fn execute( &self, step_execution: &StepExecution, ) -> Result<RepeatStatus, BatchError>

Executes the tasklet operation.

§Parameters
  • step_execution: The current step execution context for accessing metrics and state
§Returns
  • Ok(RepeatStatus): The tasklet completed successfully
  • Err(BatchError): An error occurred during execution

Implementors§

Source§

impl Tasklet for FtpGetFolderTasklet

Available on crate feature ftp only.
Source§

impl Tasklet for FtpGetTasklet

Available on crate feature ftp only.
Source§

impl Tasklet for FtpPutFolderTasklet

Available on crate feature ftp only.
Source§

impl Tasklet for FtpPutTasklet

Available on crate feature ftp only.
Source§

impl Tasklet for ZipTasklet

Available on crate feature zip only.