A collection of advanced, production-ready Python decorators (Rate Limiting, 2FA, Caching, Retry, Hooks, Dynamic Behavior, Enterprise Security).
Project description
nexalware-decorator
Advanced, reusable Python decorators for production-ready applications.
Includes decorators for security, rate limiting, caching, retries, hooks, dynamic behavior, and enterprise-grade function management.
Features
1. Two-Factor Authentication / Access Control
- Secure critical functions with roles, OTP, or login verification
- Attributes:
attempts,last_user,last_success_time - Example use-case: Banking, admin APIs, sensitive operations
2. Rate Limiter
- Limit function calls per time window
- Supports global or per-user limits
- Optional cooldown after limit exceeded
- Example use-case: API endpoints, messaging services, email sending
3. Cache / Memoization
- Cache function outputs for performance
- Attributes:
hits,misses,cache_size - Supports TTL (time-to-live) for cached entries
- Example use-case: Expensive computations, ML predictions, web API responses
4. Retry / Circuit Breaker
- Retry function calls on failure
- Circuit breaker disables functions after N failures
- Attributes:
fail_count,last_exception,is_open - Example use-case: Network requests, database queries, unstable services
5. Pre/Post Hook
- Attach hooks dynamically before and after function execution
- Modify inputs or outputs conditionally
- Example use-case: Event systems, logging, monitoring pipelines
6. Dynamic Behavior / Configurable Functions
- Change function behavior at runtime via attributes
- Attributes:
multiplier,mode,threshold - Enable/disable behaviors dynamically
- Example use-case: Algorithmic trading, AI scoring, feature toggles
7. Combined “Security + Logging + Metrics”
- Enterprise-grade decorator for sensitive operations
- Features: access control, 2FA, rate limiting, metrics
- Attributes:
call_history,last_user,average_runtime - Example use-case: Admin panels, API endpoints, financial operations
Installation
Install from PyPI:
pip install nexalware-decorator
---
## Rate Limiter Example
from nexalware_decorator import RateLimiter
import asyncio
limiter = RateLimiter(limit=3, window=10, per_user=True, cooldown=5)
@limiter
async def send_message(text, user_id):
print(f"Sent: {text}")
async def main():
user = "user123"
for i in range(5):
try:
await send_message(f"Hello {i}", user_id=user)
except RateLimitExceeded as e:
print(e)
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexalware_decorator-0.1.1.tar.gz.
File metadata
- Download URL: nexalware_decorator-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
932ed31fa7d3c26f355ac60eac8cf8ede83bb93bf31195c445ebb864bb42b611
|
|
| MD5 |
4a55c9a5fbefcd7eafaa94f247c67b3e
|
|
| BLAKE2b-256 |
7f08a9e8edc7164303656836de4cc0288b7a5dfc8bddb93080a86feb2cdd77e4
|
File details
Details for the file nexalware_decorator-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nexalware_decorator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31b86037f676f28ff1a62dc2dde934d45359a9933efedb1d65487e399d403733
|
|
| MD5 |
55611002a331e8777905721ae61072c2
|
|
| BLAKE2b-256 |
69bc6dccafd5cb9d7aefe1bf03f3b6dcedee9680c9a5d8b1ac59170df83deaa5
|