Module generic_result_builder

Module generic_result_builder 

Source
Expand description

§Generic Result Builder

This module provides a generic, reusable result building system for the adaptive pipeline system. It supports fluent result construction, metrics collection, and comprehensive operation tracking.

§Overview

The generic result builder provides:

  • Fluent Interface: Fluent API for building operation results
  • Type Safety: Generic result building for any operation type
  • Metrics Integration: Automatic metrics collection and reporting
  • Error Handling: Comprehensive error handling and context
  • Performance Tracking: Detailed timing and performance measurements

§Architecture

The result builder follows the Builder pattern:

  • Generic Design: Works with any operation result type
  • Fluent API: Chainable methods for result construction
  • Metrics Collection: Automatic collection of operation metrics
  • Error Context: Rich error context and debugging information

§Key Features

§Fluent Result Building

  • Chainable Methods: Fluent API for building complex results
  • Type Safety: Compile-time type checking for result construction
  • Immutable Building: Immutable result building with copy-on-write
  • Validation: Automatic validation of result consistency

§Metrics Integration

  • Automatic Collection: Automatic collection of operation metrics
  • Custom Metrics: Support for custom metric types
  • Performance Tracking: Detailed timing and performance measurements
  • Statistical Analysis: Statistical analysis of operation results

§Error Handling

  • Rich Context: Rich error context with operation details
  • Error Chaining: Chain errors from multiple operations
  • Recovery Information: Information for error recovery
  • Debugging Support: Comprehensive debugging information

§Usage Examples

§Basic Result Building

§Result Building with Error Handling

§Advanced Result Building with Custom Metrics

§Builder Pattern Features

§Fluent API

  • Method Chaining: Chain methods for fluent result construction
  • Type Safety: Compile-time type checking for method calls
  • Immutable Building: Each method returns a new builder instance
  • Validation: Automatic validation at each step

§Processing Steps

  • Step Definition: Define processing steps with names and logic
  • Step Metrics: Collect metrics for individual processing steps
  • Step Data: Store intermediate data between processing steps
  • Error Handling: Handle errors within individual steps

§Timing and Performance

  • Automatic Timing: Automatic timing of overall operation
  • Step Timing: Individual timing for each processing step
  • Performance Metrics: Comprehensive performance measurements
  • Throughput Calculation: Automatic throughput calculations

§Error Handling

§Error Types

  • Validation Errors: Input validation failures
  • Processing Errors: Errors during processing steps
  • Configuration Errors: Invalid builder configuration
  • System Errors: System-level errors and failures

§Error Context

  • Rich Context: Detailed error context with operation state
  • Error Chaining: Chain errors from multiple operations
  • Recovery Information: Information for error recovery
  • Debugging Data: Comprehensive debugging information

§Performance Considerations

§Builder Efficiency

  • Minimal Overhead: Designed for minimal performance impact
  • Lazy Evaluation: Lazy evaluation of expensive operations
  • Memory Efficiency: Efficient memory usage during building
  • Copy Optimization: Optimized copying for immutable building

§Metrics Collection

  • Low Overhead: Low-overhead metrics collection
  • Selective Collection: Collect only necessary metrics
  • Batched Operations: Batch metrics operations for efficiency

§Integration

The result builder integrates with:

  • Processing Pipeline: Build results for pipeline operations
  • Metrics System: Integrate with metrics collection system
  • Error Handling: Integrate with error handling framework
  • Logging System: Integrate with logging and monitoring

§Thread Safety

The result builder is designed for thread safety:

  • Immutable Building: Immutable builder instances
  • Thread-Safe Operations: All operations are thread-safe
  • Concurrent Building: Support for concurrent result building

§Future Enhancements

Planned enhancements include:

  • Async Building: Full async support for result building
  • Streaming Results: Support for streaming result construction
  • Advanced Metrics: More sophisticated metrics collection
  • Result Caching: Caching of frequently built results

Structs§

GenericProcessingResult
Generic processing result that implements OperationResult
GenericResultBuilder
Generic result builder for fluent API construction

Traits§

OperationResult
Generic trait for operation results that can be built fluently

Type Aliases§

CompressionGenericResult
CompressionResultBuilder
EncryptionGenericResult
EncryptionResultBuilder
FileProcessingGenericResult
Type aliases for common result patterns
FileProcessingResultBuilder
Builder type aliases for convenience