Expand description
Step definition and execution.
Contains types for defining and executing steps:
Step: Interface for individual units of workStepInstance: Specific instance of a step with configurationStepExecution: Execution details for a step runStepBuilder: Builder for creating step instances
§Step Module
This module provides the core step execution functionality for the Spring Batch framework. A step represents a single phase of a batch job that processes data in chunks or executes a single task (tasklet).
§Overview
The step module supports two main execution patterns:
§Chunk-Oriented Processing
Processes data in configurable chunks using the read-process-write pattern:
- Reader: Reads items from a data source
- Processor: Transforms items (optional)
- Writer: Writes processed items to a destination
§Tasklet Processing
Executes a single task or operation that doesn’t follow the chunk pattern.
§Key Features
- Error Handling: Configurable skip limits for fault tolerance
- Metrics Tracking: Comprehensive execution statistics
- Lifecycle Management: Proper resource management with open/close operations
- Builder Pattern: Fluent API for step configuration
§Examples
§Basic Chunk-Oriented Step
use spring_batch_rs::core::step::{StepBuilder, StepExecution, Step};
use spring_batch_rs::core::item::{ItemReader, ItemProcessor, ItemWriter};
use spring_batch_rs::BatchError;
// Implement your reader, processor, and writer
let reader = MyReader;
let processor = MyProcessor;
let writer = MyWriter;
let step = StepBuilder::new("my-step")
.chunk(100) // Process 100 items per chunk
.reader(&reader)
.processor(&processor)
.writer(&writer)
.skip_limit(10) // Allow up to 10 errors
.build();
let mut step_execution = StepExecution::new(step.get_name());
let result = step.execute(&mut step_execution);§Tasklet Step
use spring_batch_rs::core::step::{StepBuilder, StepExecution, RepeatStatus, Step, Tasklet};
use spring_batch_rs::BatchError;
let tasklet = MyTasklet;
let step = StepBuilder::new("my-tasklet-step")
.tasklet(&tasklet)
.build();
let mut step_execution = StepExecution::new(step.get_name());
let result = step.execute(&mut step_execution);Structs§
- Chunk
Oriented Step - A step implementation that processes items in chunks.
- Chunk
Oriented Step Builder - Builder for creating ChunkOrientedStep instances.
- Step
Builder - Main entry point for building steps of any type.
- Step
Execution - Represents the execution context and metrics for a step.
- Tasklet
Builder - Builder for creating TaskletStep instances.
- Tasklet
Step - A step implementation that executes a single tasklet.
Enums§
- Batch
Status - Represents the overall status of a batch job.
- Chunk
Status - Represents the status of a chunk during processing.
- Repeat
Status - Indicates whether a tasklet should continue executing or has finished.
- Step
Status - Represents the current status of a step execution.