config
config
¶
Configuration management for cocapi
ApiConfig
dataclass
¶
ApiConfig(
base_url: str = "https://api.clashofclans.com/v1",
timeout: int = 20,
max_retries: int = 3,
retry_delay: float = 1.0,
cache_ttl: int = 300,
enable_caching: bool = True,
enable_rate_limiting: bool = True,
use_pydantic_models: bool = False,
requests_per_second: float = 10.0,
burst_limit: int = 20,
enable_metrics: bool = False,
metrics_window_size: int = 1000,
enable_keepalive: bool = True,
max_connections: int = 10,
max_keepalive_connections: int = 5,
key_name: str = "cocapi_auto",
key_count: int = 1,
key_description: str = "Auto-generated by cocapi KeyManager",
auto_refresh_keys: bool = True,
persist_keys: bool = False,
key_storage_path: str | None = None,
)
Configuration class for CocApi
CacheEntry
dataclass
¶
CacheEntry(data: dict, timestamp: float, ttl: int)
Cache entry with TTL support
is_expired
¶
is_expired(current_time: float) -> bool
Check if cache entry is expired
Source code in cocapi/config.py
53 54 55 | |
RequestMetric
dataclass
¶
RequestMetric(
endpoint: str,
method: str,
status_code: int,
response_time: float,
timestamp: float,
cache_hit: bool,
error_type: str | None = None,
)
Metrics for a single API request