Skip to main content

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, RateLimitExceeded
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())

Release files for nexalware-decorator 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nexalware-decorator 0.2.0
File Size Uploaded
nexalware_decorator-0.2.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nexalware-decorator 0.2.0
File Interpreter ABI Platform
nexalware_decorator-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / nexalware_decorator-0.2.0.tar.gz

Download URL nexalware_decorator-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1fd8484c30ff3a8c02ebace739e6aa8e0940af64120615175af535c9541a6648
BLAKE2b-256 checksum
How to use checksums
3b5732fa6d2df833eed3e5fd6212763c41da9b512643a6f9d0e793e4d10e9f2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / nexalware_decorator-0.2.0-py3-none-any.whl

Download URL nexalware_decorator-0.2.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efefbab4bc2d4880f84a3c6d924cd3463b42f356c7a8ee7679e0ebee2344e4ee
BLAKE2b-256 checksum
How to use checksums
4f485857718e2af49da71e473427f4dc3e2ac5ccfb7865510da53cb750d35b54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page