docker_image_pusher/registry/
mod.rs1pub mod auth;
14pub mod client;
15pub mod tar;
16pub mod tar_utils;
17
18pub mod progress;
20pub mod stats;
21pub mod unified_pipeline;
22
23pub use auth::Auth;
25pub use client::{RegistryClient, RegistryClientBuilder};
26pub use tar_utils::TarUtils;
27
28pub use progress::ProgressTracker;
30pub use stats::{LayerUploadStats, ProgressReporter, UploadStats};
31pub use unified_pipeline::{PipelineConfig, PipelineTask, TaskOperation, UnifiedPipeline};
32
33use crate::error::Result;
36use crate::logging::Logger;
37
38#[derive(Debug, Clone)]
40pub struct UploadConfig {
41 pub max_concurrent: usize,
42 pub timeout_seconds: u64,
43 pub retry_attempts: usize,
44 pub large_layer_threshold: u64,
45 pub small_blob_threshold: u64,
46 pub enable_streaming: bool,
47}
48
49impl Default for UploadConfig {
50 fn default() -> Self {
51 Self {
52 max_concurrent: 4,
53 timeout_seconds: 7200,
54 retry_attempts: 3,
55 large_layer_threshold: 100 * 1024 * 1024, small_blob_threshold: 10 * 1024 * 1024, enable_streaming: true,
58 }
59 }
60}
61
62pub struct Uploader {
64 pipeline: UnifiedPipeline,
65}
66
67impl Uploader {
68 pub fn new(pipeline: UnifiedPipeline) -> Self {
70 Self { pipeline }
71 }
72
73 pub async fn upload_layers(
75 &self,
76 layers: &[crate::image::parser::LayerInfo],
77 repository: &str,
78 tar_path: &std::path::Path,
79 token: &Option<String>,
80 client: std::sync::Arc<crate::registry::RegistryClient>,
81 ) -> Result<()> {
82 self.pipeline
83 .process_uploads(layers, repository, tar_path, token, client)
84 .await
85 }
86}
87
88pub struct RegistryCoordinator {
90 pipeline: UnifiedPipeline,
91 config: PipelineConfig,
92}
93
94impl RegistryCoordinator {
95 pub fn new(output: Logger) -> Self {
97 let config = PipelineConfig::default();
98 let pipeline = UnifiedPipeline::new(output).with_config(config.clone());
99
100 Self { pipeline, config }
101 }
102
103 pub fn with_config(output: Logger, config: PipelineConfig) -> Self {
105 let pipeline = UnifiedPipeline::new(output).with_config(config.clone());
106
107 Self { pipeline, config }
108 }
109
110 pub fn create_uploader(&self) -> Uploader {
112 Uploader::new(self.pipeline.clone())
113 }
114
115 pub fn get_config(&self) -> &PipelineConfig {
117 &self.config
118 }
119
120 pub async fn upload_layers(
122 &self,
123 layers: &[crate::image::parser::LayerInfo],
124 repository: &str,
125 tar_path: &std::path::Path,
126 token: &Option<String>,
127 client: std::sync::Arc<crate::registry::RegistryClient>,
128 ) -> Result<()> {
129 self.pipeline
130 .process_uploads(layers, repository, tar_path, token, client)
131 .await
132 }
133
134 pub async fn download_layers(
136 &self,
137 layers: &[crate::image::parser::LayerInfo],
138 repository: &str,
139 token: &Option<String>,
140 client: std::sync::Arc<crate::registry::RegistryClient>,
141 cache: &mut crate::image::cache::Cache,
142 ) -> Result<()> {
143 self.pipeline
144 .process_downloads(layers, repository, token, client, cache)
145 .await
146 }
147}