pub mod cache_config {
pub const DEFAULT_TTL_SECS: u64 = 300; pub const ROBOTS_TTL_SECS: u64 = 3600; pub const MAX_CACHE_ENTRIES: usize = 10000;
pub const MEMORY_CACHE_MAX_SIZE: usize = 1000;
pub const EVICTION_BUFFER_PERCENT: usize = 10;
}
pub mod default_identity {
pub const DEFAULT_TEAM_ID: crate::domain::id::Id = crate::domain::id::Id::from_u128(1);
pub const DEFAULT_API_KEY_ID: crate::domain::id::Id = crate::domain::id::Id::from_u128(2);
pub const DEFAULT_IDENTITY_TOKEN_HASH: &str = "sha256:default_identity";
}
pub mod server_config {
pub const DEFAULT_HOST: &str = "0.0.0.0";
pub const DEFAULT_PORT: u16 = 8899;
pub const DEFAULT_RATE_LIMIT_RPM: u32 = 100;
pub const DEFAULT_TEAM_LIMIT: u32 = 10;
pub const DEFAULT_TASK_LOCK_DURATION_SECS: u64 = 300;
pub const DEFAULT_PAGE_LIMIT: u32 = 100;
pub const MAX_PAGE_LIMIT: u32 = 1000;
pub const CORS_MAX_AGE_SECS: u64 = 86400; }
pub mod crawl_task {
pub const CRAWL_TASK_CREDITS_COST: i64 = 10;
pub const SCRAPE_TASK_CREDITS_COST: i64 = 5;
pub const EXTRACT_TASK_CREDITS_COST: i64 = 8;
pub const MAX_CONCURRENT_CRAWLS: u32 = 10;
pub const DEFAULT_MAX_RETRIES: u32 = 3;
pub const BASE_POLL_INTERVAL_MS: u64 = 1000;
pub const DEFAULT_TIMEOUT_MS: u64 = 5000;
pub const MAX_SYNC_WAIT_MS: u32 = 30000;
pub const MAX_POLL_COUNT: u32 = 60;
}
pub mod testing {
use std::time::Duration;
pub const API_REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
pub const QUICK_TEST_TIMEOUT: Duration = Duration::from_secs(10);
pub const E2E_TEST_TIMEOUT: Duration = Duration::from_secs(90);
pub const CRAWL_TASK_TIMEOUT: Duration = Duration::from_secs(90);
}
pub mod env_vars {
pub const ENV: &str = "CRAWLRS_ENV";
pub const APP_ENVIRONMENT: &str = "APP_ENVIRONMENT";
pub const RATE_LIMITING_ENABLED: &str = "CRAWLRS_RATE_LIMITING_ENABLED";
pub const DISABLE_SSRF_PROTECTION: &str = "CRAWLRS_DISABLE_SSRF_PROTECTION";
pub const ENABLE_NETWORK_TESTS: &str = "CRAWLRS_ENABLE_NETWORK_TESTS";
pub const PROXY_URL: &str = "CRAWLRS_PROXY_URL";
pub const TEST_NO_BROWSER_REUSE: &str = "CRAWLRS_TEST_NO_BROWSER_REUSE";
pub const DEBUG_SAVE_HTML: &str = "DEBUG_SAVE_HTML";
pub const HEALTH_CHECK_URL: &str = "CRAWLRS_HEALTH_CHECK_URL";
pub const BAIDU_TEST_RESULTS: &str = "BAIDU_TEST_RESULTS";
pub const BING_TEST_RESULTS: &str = "BING_TEST_RESULTS";
pub const GOOGLE_HTTP_FALLBACK_TEST_RESULTS: &str = "GOOGLE_HTTP_FALLBACK_TEST_RESULTS";
pub const SOGOU_TEST_RESULTS: &str = "SOGOU_TEST_RESULTS";
pub const USE_TEST_DATA: &str = "USE_TEST_DATA";
pub const SKIP_SEARCH_TESTS: &str = "SKIP_SEARCH_TESTS";
pub const SKIP_BROWSER_TESTS: &str = "SKIP_BROWSER_TESTS";
pub const CHROMIUM_REMOTE_DEBUGGING_URL: &str = "CHROMIUM_REMOTE_DEBUGGING_URL";
pub const FIRE_ENGINE_CDP_URL: &str = "FIRE_ENGINE_CDP_URL";
pub const FIRE_ENGINE_TLS_URL: &str = "FIRE_ENGINE_TLS_URL";
pub const FIRE_ENGINE_URL: &str = "FIRE_ENGINE_URL";
pub const FLARESOLVERR_URL: &str = "FLARESOLVERR_URL";
pub const TEST_DATABASE_URL: &str = "TEST_DATABASE_URL";
pub const TEST_DATABASE_PASSWORD: &str = "TEST_DATABASE_PASSWORD";
pub const TEST_WEBHOOK_SECRET: &str = "TEST_WEBHOOK_SECRET";
pub const TEST_S3_ACCESS_KEY: &str = "TEST_S3_ACCESS_KEY";
pub const TEST_S3_SECRET_KEY: &str = "TEST_S3_SECRET_KEY";
pub const TEST_S3_ENDPOINT: &str = "TEST_S3_ENDPOINT";
pub const SKIP_S3_TESTS: &str = "SKIP_S3_TESTS";
pub const TEST_FIRE_ENGINE_CDP_URL: &str = "TEST_FIRE_ENGINE_CDP_URL";
}
pub use testing::*;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_cache_constants() {
assert_eq!(cache_config::DEFAULT_TTL_SECS, 300);
assert_eq!(cache_config::MAX_CACHE_ENTRIES, 10000);
}
#[test]
fn test_auth_default_identity_constants() {
assert_ne!(
default_identity::DEFAULT_TEAM_ID,
crate::domain::id::Id::nil(),
"DEFAULT_TEAM_ID must not be nil UUID"
);
assert_ne!(
default_identity::DEFAULT_API_KEY_ID,
crate::domain::id::Id::nil(),
"DEFAULT_API_KEY_ID must not be nil UUID"
);
assert_ne!(
default_identity::DEFAULT_TEAM_ID,
default_identity::DEFAULT_API_KEY_ID,
"DEFAULT_TEAM_ID and DEFAULT_API_KEY_ID must be distinct"
);
}
}