Expand description
Async checksum adapter (wraps sync domain trait for async contexts)
§Async Checksum Adapter
This module provides an async adapter for the synchronous ChecksumService
domain trait. It demonstrates the proper pattern for handling sync domain
services in async infrastructure contexts.
§Architecture Pattern
Following the hybrid DDD/Clean/Hexagonal architecture:
- Domain: Defines sync
ChecksumServicetrait (business logic) - Infrastructure: Provides async adapter (execution model)
- Separation of Concerns: Domain doesn’t dictate async/sync execution
§Usage
ⓘ
use std::sync::Arc;
use adaptive_pipeline::infrastructure::adapters::AsyncChecksumAdapter;
use adaptive_pipeline_domain::services::checksum_service::ChecksumProcessor;
// Create sync implementation
let sync_service = Arc::new(ChecksumProcessor::sha256_processor(true));
// Wrap in async adapter
let async_service = AsyncChecksumAdapter::new(sync_service);
// Use in async context
let result = async_service.process_chunk_async(chunk, &mut context, "stage").await?;Structs§
- Async
Checksum Adapter - Async adapter for
ChecksumService