domain-status 0.2.1

Concurrent URL status checker that captures comprehensive metadata in SQLite.
Documentation
//! Application initialization and resource setup.
//!
//! This module provides functions to initialize all shared resources:
//! - HTTP clients (with rate limiting and timeouts)
//! - DNS resolver
//! - Database connection pool
//! - Processing context
//!
//! All initialization functions return proper error types for error handling.

mod client;
mod host_rate_limiter;
mod log_filters;
mod logger;
mod rate_limiter;
mod resolver;

use std::sync::Arc;

use rustls::crypto::{ring::default_provider, CryptoProvider};
use tokio::sync::Semaphore;

// Re-export public API
pub(crate) use client::build_download_client;
pub use client::{init_client, init_redirect_client};
pub use host_rate_limiter::{init_host_rate_limiter, HostRateLimiter};
pub use logger::{init_logger_to_file, init_logger_with};
pub use rate_limiter::{init_rate_limiter, RateLimiter};
pub use resolver::init_resolver;
#[cfg(test)]
pub(crate) use resolver::test_resolver;

/// Initializes a semaphore for controlling concurrency.
///
/// Creates a new semaphore with the specified permit count. This semaphore is used
/// to limit the number of concurrent URL processing tasks.
///
/// # Arguments
///
/// * `count` - Maximum number of concurrent operations allowed
///
/// # Returns
///
/// An `Arc<Semaphore>` that can be shared across multiple tasks.
#[must_use]
pub fn init_semaphore(count: usize) -> Arc<Semaphore> {
    Arc::new(Semaphore::new(count))
}

/// Initializes the crypto provider for TLS operations.
///
/// Configures the global crypto provider for `rustls`. This must be called before
/// any TLS connections are established. Uses the default provider which supports
/// all standard TLS features.
pub fn init_crypto_provider() {
    // The return value is ignored because reinstalling the provider is harmless
    let _ = CryptoProvider::install_default(default_provider());
}