optimized_upload_demo/
optimized_upload_demo.rs1use docker_image_pusher::cli::operation_mode::OperationMode;
4use docker_image_pusher::error::Result;
5use docker_image_pusher::image::ImageManager;
6use docker_image_pusher::registry::PipelineConfig;
7use docker_image_pusher::registry::RegistryClientBuilder;
8
9#[tokio::main]
10async fn main() -> Result<()> {
11 println!("Docker Image Pusher - Optimized Upload Demo");
12
13 let mut manager = ImageManager::new(None, true)?;
15
16 let config = PipelineConfig {
18 max_concurrent: 8,
19 buffer_size: 1024,
20 small_blob_threshold: 10 * 1024 * 1024, medium_blob_threshold: 100 * 1024 * 1024, large_blob_threshold: 500 * 1024 * 1024, timeout_seconds: 7200,
24 retry_attempts: 3,
25 memory_limit_mb: 512,
26 enable_compression: true,
27 enable_streaming: true,
28 };
29 manager.configure_pipeline(config);
30
31 let (optimized, pipeline_config) = manager.get_config();
33 println!("Optimized mode: {}", optimized);
34 println!("Pipeline config: {:?}", pipeline_config);
35
36 let client = RegistryClientBuilder::new("https://registry.example.com".to_string())
38 .with_verbose(true)
39 .build()?;
40
41 println!("Testing registry connectivity...");
43 match client.test_connectivity().await {
44 Ok(_) => println!("✓ Registry connectivity successful"),
45 Err(e) => println!(
46 "✗ Registry connectivity failed: {} (expected with example URL)",
47 e
48 ),
49 }
50
51 let mode = OperationMode::PushFromTar {
53 tar_file: "example-image.tar".to_string(),
54 repository: "myapp".to_string(),
55 reference: "latest".to_string(),
56 };
57
58 println!("Operation mode: {}", mode.description());
59
60 println!("Demo completed successfully!");
64 println!("\nKey benefits of optimized mode:");
65 println!("• Priority-based upload scheduling (small blobs first)");
66 println!("• Streaming TAR processing with parallel uploads");
67 println!("• Memory-efficient processing of large files");
68 println!("• Configurable pipeline parameters");
69
70 Ok(())
71}