File size: 2,006 Bytes
cef0de3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""
API Performance Utilities

This module provides easy access to all performance-related
components including caching, rate limiting, compression, and HTTP client.

Usage:
    from performance import (
        cache, cached, CacheTTL,
        rate_limiter, RateLimitConfig,
        http_client, fetch_json,
        CompressionMiddleware
    )
"""
from .cache import (
    InMemoryCache,
    CacheEntry,
    CacheTTL,
    cached,
    cache,
    create_cache_key,
    invalidate_pattern
)

from .rate_limit import (
    SlidingWindowRateLimiter,
    RateLimitExceeded,
    RateLimitInfo,
    RateLimitConfig,
    rate_limiter,
    get_rate_limit_headers,
    create_rate_limit_dependency
)

from .compression import (
    CompressionMiddleware,
    ETaggerMiddleware,
    get_compression_stats,
    BROTLI_AVAILABLE
)

from .async_http import (
    AsyncHTTPClient,
    HTTPResponse,
    CircuitBreaker,
    CircuitBreakerConfig,
    CircuitBreakerError,
    CircuitState,
    http_client,
    fetch_json,
    post_json
)


__all__ = [
    # Cache
    "InMemoryCache",
    "CacheEntry", 
    "CacheTTL",
    "cached",
    "cache",
    "create_cache_key",
    "invalidate_pattern",
    
    # Rate Limiting
    "SlidingWindowRateLimiter",
    "RateLimitExceeded",
    "RateLimitInfo",
    "RateLimitConfig",
    "rate_limiter",
    "get_rate_limit_headers",
    "create_rate_limit_dependency",
    
    # Compression
    "CompressionMiddleware",
    "ETaggerMiddleware",
    "get_compression_stats",
    "BROTLI_AVAILABLE",
    
    # HTTP Client
    "AsyncHTTPClient",
    "HTTPResponse",
    "CircuitBreaker",
    "CircuitBreakerConfig",
    "CircuitBreakerError",
    "CircuitState",
    "http_client",
    "fetch_json",
    "post_json"
]


def get_performance_stats() -> dict:
    """Get combined performance statistics"""
    return {
        "cache": cache.stats,
        "rate_limiter": rate_limiter.stats,
        "http_client": http_client.stats,
        "brotli_available": BROTLI_AVAILABLE
    }