pub struct XetCommon {
pub file_ingestion_semaphore: Arc<Semaphore>,
pub file_download_semaphore: Arc<Semaphore>,
pub reconstruction_download_buffer: Arc<AdjustableSemaphore>,
pub active_downloads: Arc<AtomicU64>,
/* private fields */
}Expand description
Holds shared state that is common across the entire context.
Accessible via ctx.common on a super::XetContext.
Fields§
§file_ingestion_semaphore: Arc<Semaphore>Limits the number of files being ingested (cleaned/uploaded) concurrently.
file_download_semaphore: Arc<Semaphore>Limits the number of files being downloaded concurrently.
reconstruction_download_buffer: Arc<AdjustableSemaphore>Limits total memory used for buffering data during reconstruction downloads.
active_downloads: Arc<AtomicU64>Tracks the number of currently active file downloads for dynamic buffer scaling.
Implementations§
Source§impl XetCommon
impl XetCommon
Sourcepub fn new(config: &XetConfig) -> Self
pub fn new(config: &XetConfig) -> Self
Creates a new XetCommon instance with the given configuration.
Sourcepub fn cache_get_or_create<T, F>(&self, key: &str, create: F) -> T
pub fn cache_get_or_create<T, F>(&self, key: &str, create: F) -> T
Retrieves a cached value by key, or creates and stores it using create.
Values are stored as type-erased Box<dyn Any> and recovered via downcast_ref.
Typical stored types are Arc<Mutex<...>> or Arc<RwLock<...>>, making
the clone cheap (just an Arc bump).
Sourcepub fn get_or_create_reqwest_client<F>(
&self,
tag: String,
create_client_fn: F,
) -> Result<Client>
pub fn get_or_create_reqwest_client<F>( &self, tag: String, create_client_fn: F, ) -> Result<Client>
Gets or creates a reqwest client, using a tag to identify the client type.
§Arguments
tag- A string identifier for the client (e.g., “tcp” for regular, socket path for UDS)create_client_fn- A function that creates the client if needed
§Returns
Returns a clone of the cached client if the tag matches, or creates a new client if the tag differs.