Report generation workflow states¶
The report generation process follows a state machine model managed by ReportDownloadRecordService and persisted in the database^[001-todo-code.md]. The ReportStatus enumeration defines the three primary lifecycle stages for a report record^[001-todo-code.md].
States¶
- RUNNING: The initial state for a newly created report request^[001-todo-code.md]. It indicates that the report is currently being processed or waiting for data chunks to be generated^[001-todo-code.md].
- SUCCESS: The terminal state achieved when the report generation completes without errors^[001-todo-code.md]. In this state, the
file_pathattribute is populated with the location of the final document^[001-todo-code.md]. - FAIL: The terminal state resulting from an error during generation, a timeout, or a manual failure update^[001-todo-code.md]. This state captures the
error_messageexplaining why the report could not be produced^[001-todo-code.md].
State Transitions¶
Initialization¶
A report request begins by inserting a record with the RUNNING status^[001-todo-code.md]. The system performs a duplicate check to ensure a RUNNING or SUCCESS report with the same parameters does not already exist within a specific time window^[001-todo-code.md].
Processing¶
While the status is RUNNING, the system accepts document updates^[001-todo-code.md]. This phase involves the asynchronous generation and storage of temporary file chunks^[001-todo-code.md].
Completion (Success)¶
Once all data pages are generated and merged, the system transitions the record to SUCCESS^[001-todo-code.md]. This update commits the final file path to the database, making the record available for download^[001-todo-code.md].
Failure Handling¶
The system transitions to the FAIL state under specific conditions: * Exception during processing: If an error occurs while creating a specific document page, the status is updated to FAIL with the corresponding error message^[001-todo-code.md]. * Timeout: Records that remain in processing for too long are detected by a delay queue listener, which triggers an update to FAIL^[001-todo-code.md].
Related Concepts¶
- [[Async processing]]
- [[State machine]]
- [[Report generation]]
Sources¶
- 001-todo-code.md