eventx


Nameeventx JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/Tryboy869/eventx
SummaryEvent-driven messaging via exceptions - Ultra-lightweight event system
upload_time2025-08-30 20:10:00
maintainerNone
docs_urlNone
authorAnzize Daouda
requires_python>=3.8
licenseMIT License Copyright (c) 2025 Tryboy869 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords events messaging exceptions event-driven lightweight async-alternative microservices python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ⚡ EventX

[![PyPI version](https://badge.fury.io/py/eventx.svg)](https://pypi.org/project/eventx/)
[![Python Support](https://img.shields.io/pypi/pyversions/eventx.svg)](https://pypi.org/project/eventx/)
[![Downloads](https://pepy.tech/badge/eventx)](https://pepy.tech/project/eventx)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> **Event-driven messaging via exceptions** - Because `raise Event()` is simpler than async hell

Stop fighting with async/await, message brokers, and callback complexity. EventX transforms exceptions into elegant event systems.

```python
from eventx import EventBus, Event

bus = EventBus()

@bus.on("user_signup")
def send_email(event):
    print(f"📧 Welcome {event.data['email']}!")

def signup():
    raise Event("user_signup", {"email": "alice@example.com"})

bus.dispatch(signup)
# 📧 Welcome alice@example.com!
```

## 🤔 The Problem with Python Events

Current solutions are **painful**:

```python
# Celery = Redis dependency + complex config
from celery import Celery
celery_app = Celery('tasks', broker='redis://localhost:6379')

# asyncio = async/await everywhere  
async def handler():
    await some_async_operation()
    await another_async_operation()

# EventEmitter ports = verbose callback hell
emitter.on('event', lambda data: callback_function(data))
```

## ✨ The EventX Solution

**Natural exception-based events**:

```python
# Zero config, zero dependencies, zero async complexity
@bus.on("data_ready")
def process(event):
    print(f"Got {len(event.data)} items")
    raise Event("processing_done", {"status": "success"})

bus.dispatch(lambda: raise Event("data_ready", [1, 2, 3, 4, 5]))
```

## 🚀 Why EventX Wins

| Feature | EventX | Celery | asyncio | Callbacks |
|---------|------|---------|---------|-----------|
| **Setup** | `pip install eventx` | Redis + config | Complex | Manual wiring |
| **Syntax** | `raise Event()` | `@task` decorators | `async/await` | `callback()` |
| **Dependencies** | **0** | Redis/RabbitMQ | Built-in | Varies |
| **Learning curve** | **5 minutes** | Hours | Days | Medium |
| **Performance** | **43K events/sec** | Network limited | High | High |
| **Debugging** | **Stack traces** | Distributed logs | Complex | Manual |

## ⚡ Quick Start

### Installation
```bash
pip install eventx
```

### Basic Usage (2 minutes)
```python
from eventx import EventBus, Event

# Create event bus
bus = EventBus()

# Listen for events
@bus.on("order_placed")
def process_payment(event):
    order = event.data
    print(f"💳 Processing ${order['total']} payment")
    
    # Events can trigger other events
    raise Event("payment_processed", order)

@bus.on("payment_processed")
def send_receipt(event):
    order = event.data
    print(f"📧 Receipt sent for order #{order['id']}")

# Trigger event workflow
def place_order():
    order = {"id": "12345", "total": 99.99, "items": ["laptop"]}
    raise Event("order_placed", order)

# Execute
bus.dispatch(place_order)

# Output:
# 💳 Processing $99.99 payment  
# 📧 Receipt sent for order #12345
```

### Real-World Example (5 minutes)
```python
# E-commerce pipeline with EventX
from eventx import EventBus, Event

shop = EventBus()

@shop.on("cart_checkout")
def validate_cart(event):
    cart = event.data
    if cart["total"] > 0:
        raise Event("cart_valid", cart)
    else:
        raise Event("cart_empty", cart)

@shop.on("cart_valid")
def charge_payment(event):
    cart = event.data
    print(f"💳 Charging ${cart['total']}")
    raise Event("payment_success", {"order_id": "ORD001"})

@shop.on("payment_success")
def fulfill_order(event):
    order_id = event.data["order_id"]
    print(f"📦 Fulfilling order {order_id}")
    raise Event("order_shipped", {"tracking": "TRK123"})

@shop.on("order_shipped")
def notify_customer(event):
    tracking = event.data["tracking"]
    print(f"📱 SMS sent: Your order shipped! Track: {tracking}")

@shop.on("cart_empty")
def suggest_products(event):
    print("🛍️ Your cart is empty. Check out these recommendations!")

# Test the pipeline
cart_data = {"items": ["phone", "case"], "total": 599.99}
shop.dispatch(lambda: raise Event("cart_checkout", cart_data))
```

## 📚 Learn More

- **[Examples](examples.md)** - Comprehensive real-world examples
- **[API Reference](#api-reference)** - Complete API documentation
- **[Roadmap](#roadmap)** - What's coming next

## 🛣️ Roadmap

### 🎯 v0.1.0 - Foundation (Current)
- [x] Core event system via exceptions
- [x] Event cascading and chaining  
- [x] Multiple handlers per event
- [x] Thread-safe operation
- [x] Built-in performance stats
- [x] Zero dependencies

### 🔄 v0.2.0 - Enhanced (Next Month)
- [ ] Async/await handler support
- [ ] Event middleware system
- [ ] Wildcard event listeners (`@bus.on("*")`)
- [ ] Event filtering and transformation
- [ ] Performance optimizations
- [ ] Enhanced debugging tools

### 🌐 v0.3.0 - Ecosystem (Q1 2025)
- [ ] FastAPI/Flask/Django integrations
- [ ] Event persistence (Redis/SQLite backends)
- [ ] Distributed events across processes
- [ ] Event replay and debugging
- [ ] Monitoring dashboard
- [ ] Event schema validation

### 🏢 v1.0.0 - Production (Q2 2025)
- [ ] Enterprise features (metrics, logging)
- [ ] Cloud-native integrations (AWS/GCP/Azure)
- [ ] Advanced routing and filtering
- [ ] Event sourcing patterns
- [ ] Performance analytics
- [ ] Professional support options

## 🤝 Contributing

EventX is currently in private development. Interested in contributing? Reach out!

**Contact**: nexusstudio100@gmail.com

## 📊 API Reference

### Core Classes

#### `Event(name, data=None, **metadata)`
Exception-based event class.

**Parameters:**
- `name` (str): Event identifier
- `data` (Any): Event payload  
- `**metadata`: Additional event metadata

**Properties:**
- `.name`: Event name
- `.data`: Event data
- `.timestamp`: Creation timestamp
- `.handled`: Whether event was processed

#### `EventBus(name="default", max_cascade=50)`
Main event bus for handling events.

**Methods:**
- `.on(event_name, handler=None)`: Register event handler
- `.dispatch(func)`: Execute function and handle raised Events
- `.emit(event_name, data=None)`: Directly emit an event
- `.get_stats()`: Get performance statistics

### Global Functions

```python
from eventx import on, dispatch, emit, Event

@on("global_event")  # Uses global bus
def handler(event): pass

dispatch(lambda: raise Event("test", "data"))  # Uses global bus
emit("direct_event", "data")  # Uses global bus
```

## 🏆 Performance

EventX delivers surprising performance:

- **🔥 43,000+ events/second** (local processing)
- **⚡ Sub-millisecond** event cascading
- **💾 <100KB** memory footprint
- **🚀 Instant startup** (no broker connections)

Perfect for high-frequency events in web apps, data pipelines, and real-time systems.

## 💡 Philosophy

**"Exceptions are just events with attitude"**

EventX recognizes that exceptions are already a perfect event propagation mechanism. We just needed to separate "error exceptions" from "event exceptions" and build elegant APIs around this insight.

The result? **Event-driven Python that feels like native Python.**

---

<div align="center">

**🔥 Ready to simplify your event-driven code?**

```bash
pip install eventx
```

<strong>Powered by Nexus Studio</strong><br>
<em>Making Python event-driven development effortless</em>

</div>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Tryboy869/eventx",
    "name": "eventx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Anzize Daouda <nexusstudio100@gmail.com>",
    "keywords": "events, messaging, exceptions, event-driven, lightweight, async-alternative, microservices, python",
    "author": "Anzize Daouda",
    "author_email": "Anzize Daouda <nexusstudio100@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a0/e5/adf6b93f1cd179cd7ed21d9f753a74e7755c85434d3dc5d07e35e3aec412/eventx-0.1.0.tar.gz",
    "platform": null,
    "description": "# \u26a1 EventX\n\n[![PyPI version](https://badge.fury.io/py/eventx.svg)](https://pypi.org/project/eventx/)\n[![Python Support](https://img.shields.io/pypi/pyversions/eventx.svg)](https://pypi.org/project/eventx/)\n[![Downloads](https://pepy.tech/badge/eventx)](https://pepy.tech/project/eventx)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n> **Event-driven messaging via exceptions** - Because `raise Event()` is simpler than async hell\n\nStop fighting with async/await, message brokers, and callback complexity. EventX transforms exceptions into elegant event systems.\n\n```python\nfrom eventx import EventBus, Event\n\nbus = EventBus()\n\n@bus.on(\"user_signup\")\ndef send_email(event):\n    print(f\"\ud83d\udce7 Welcome {event.data['email']}!\")\n\ndef signup():\n    raise Event(\"user_signup\", {\"email\": \"alice@example.com\"})\n\nbus.dispatch(signup)\n# \ud83d\udce7 Welcome alice@example.com!\n```\n\n## \ud83e\udd14 The Problem with Python Events\n\nCurrent solutions are **painful**:\n\n```python\n# Celery = Redis dependency + complex config\nfrom celery import Celery\ncelery_app = Celery('tasks', broker='redis://localhost:6379')\n\n# asyncio = async/await everywhere  \nasync def handler():\n    await some_async_operation()\n    await another_async_operation()\n\n# EventEmitter ports = verbose callback hell\nemitter.on('event', lambda data: callback_function(data))\n```\n\n## \u2728 The EventX Solution\n\n**Natural exception-based events**:\n\n```python\n# Zero config, zero dependencies, zero async complexity\n@bus.on(\"data_ready\")\ndef process(event):\n    print(f\"Got {len(event.data)} items\")\n    raise Event(\"processing_done\", {\"status\": \"success\"})\n\nbus.dispatch(lambda: raise Event(\"data_ready\", [1, 2, 3, 4, 5]))\n```\n\n## \ud83d\ude80 Why EventX Wins\n\n| Feature | EventX | Celery | asyncio | Callbacks |\n|---------|------|---------|---------|-----------|\n| **Setup** | `pip install eventx` | Redis + config | Complex | Manual wiring |\n| **Syntax** | `raise Event()` | `@task` decorators | `async/await` | `callback()` |\n| **Dependencies** | **0** | Redis/RabbitMQ | Built-in | Varies |\n| **Learning curve** | **5 minutes** | Hours | Days | Medium |\n| **Performance** | **43K events/sec** | Network limited | High | High |\n| **Debugging** | **Stack traces** | Distributed logs | Complex | Manual |\n\n## \u26a1 Quick Start\n\n### Installation\n```bash\npip install eventx\n```\n\n### Basic Usage (2 minutes)\n```python\nfrom eventx import EventBus, Event\n\n# Create event bus\nbus = EventBus()\n\n# Listen for events\n@bus.on(\"order_placed\")\ndef process_payment(event):\n    order = event.data\n    print(f\"\ud83d\udcb3 Processing ${order['total']} payment\")\n    \n    # Events can trigger other events\n    raise Event(\"payment_processed\", order)\n\n@bus.on(\"payment_processed\")\ndef send_receipt(event):\n    order = event.data\n    print(f\"\ud83d\udce7 Receipt sent for order #{order['id']}\")\n\n# Trigger event workflow\ndef place_order():\n    order = {\"id\": \"12345\", \"total\": 99.99, \"items\": [\"laptop\"]}\n    raise Event(\"order_placed\", order)\n\n# Execute\nbus.dispatch(place_order)\n\n# Output:\n# \ud83d\udcb3 Processing $99.99 payment  \n# \ud83d\udce7 Receipt sent for order #12345\n```\n\n### Real-World Example (5 minutes)\n```python\n# E-commerce pipeline with EventX\nfrom eventx import EventBus, Event\n\nshop = EventBus()\n\n@shop.on(\"cart_checkout\")\ndef validate_cart(event):\n    cart = event.data\n    if cart[\"total\"] > 0:\n        raise Event(\"cart_valid\", cart)\n    else:\n        raise Event(\"cart_empty\", cart)\n\n@shop.on(\"cart_valid\")\ndef charge_payment(event):\n    cart = event.data\n    print(f\"\ud83d\udcb3 Charging ${cart['total']}\")\n    raise Event(\"payment_success\", {\"order_id\": \"ORD001\"})\n\n@shop.on(\"payment_success\")\ndef fulfill_order(event):\n    order_id = event.data[\"order_id\"]\n    print(f\"\ud83d\udce6 Fulfilling order {order_id}\")\n    raise Event(\"order_shipped\", {\"tracking\": \"TRK123\"})\n\n@shop.on(\"order_shipped\")\ndef notify_customer(event):\n    tracking = event.data[\"tracking\"]\n    print(f\"\ud83d\udcf1 SMS sent: Your order shipped! Track: {tracking}\")\n\n@shop.on(\"cart_empty\")\ndef suggest_products(event):\n    print(\"\ud83d\udecd\ufe0f Your cart is empty. Check out these recommendations!\")\n\n# Test the pipeline\ncart_data = {\"items\": [\"phone\", \"case\"], \"total\": 599.99}\nshop.dispatch(lambda: raise Event(\"cart_checkout\", cart_data))\n```\n\n## \ud83d\udcda Learn More\n\n- **[Examples](examples.md)** - Comprehensive real-world examples\n- **[API Reference](#api-reference)** - Complete API documentation\n- **[Roadmap](#roadmap)** - What's coming next\n\n## \ud83d\udee3\ufe0f Roadmap\n\n### \ud83c\udfaf v0.1.0 - Foundation (Current)\n- [x] Core event system via exceptions\n- [x] Event cascading and chaining  \n- [x] Multiple handlers per event\n- [x] Thread-safe operation\n- [x] Built-in performance stats\n- [x] Zero dependencies\n\n### \ud83d\udd04 v0.2.0 - Enhanced (Next Month)\n- [ ] Async/await handler support\n- [ ] Event middleware system\n- [ ] Wildcard event listeners (`@bus.on(\"*\")`)\n- [ ] Event filtering and transformation\n- [ ] Performance optimizations\n- [ ] Enhanced debugging tools\n\n### \ud83c\udf10 v0.3.0 - Ecosystem (Q1 2025)\n- [ ] FastAPI/Flask/Django integrations\n- [ ] Event persistence (Redis/SQLite backends)\n- [ ] Distributed events across processes\n- [ ] Event replay and debugging\n- [ ] Monitoring dashboard\n- [ ] Event schema validation\n\n### \ud83c\udfe2 v1.0.0 - Production (Q2 2025)\n- [ ] Enterprise features (metrics, logging)\n- [ ] Cloud-native integrations (AWS/GCP/Azure)\n- [ ] Advanced routing and filtering\n- [ ] Event sourcing patterns\n- [ ] Performance analytics\n- [ ] Professional support options\n\n## \ud83e\udd1d Contributing\n\nEventX is currently in private development. Interested in contributing? Reach out!\n\n**Contact**: nexusstudio100@gmail.com\n\n## \ud83d\udcca API Reference\n\n### Core Classes\n\n#### `Event(name, data=None, **metadata)`\nException-based event class.\n\n**Parameters:**\n- `name` (str): Event identifier\n- `data` (Any): Event payload  \n- `**metadata`: Additional event metadata\n\n**Properties:**\n- `.name`: Event name\n- `.data`: Event data\n- `.timestamp`: Creation timestamp\n- `.handled`: Whether event was processed\n\n#### `EventBus(name=\"default\", max_cascade=50)`\nMain event bus for handling events.\n\n**Methods:**\n- `.on(event_name, handler=None)`: Register event handler\n- `.dispatch(func)`: Execute function and handle raised Events\n- `.emit(event_name, data=None)`: Directly emit an event\n- `.get_stats()`: Get performance statistics\n\n### Global Functions\n\n```python\nfrom eventx import on, dispatch, emit, Event\n\n@on(\"global_event\")  # Uses global bus\ndef handler(event): pass\n\ndispatch(lambda: raise Event(\"test\", \"data\"))  # Uses global bus\nemit(\"direct_event\", \"data\")  # Uses global bus\n```\n\n## \ud83c\udfc6 Performance\n\nEventX delivers surprising performance:\n\n- **\ud83d\udd25 43,000+ events/second** (local processing)\n- **\u26a1 Sub-millisecond** event cascading\n- **\ud83d\udcbe <100KB** memory footprint\n- **\ud83d\ude80 Instant startup** (no broker connections)\n\nPerfect for high-frequency events in web apps, data pipelines, and real-time systems.\n\n## \ud83d\udca1 Philosophy\n\n**\"Exceptions are just events with attitude\"**\n\nEventX recognizes that exceptions are already a perfect event propagation mechanism. We just needed to separate \"error exceptions\" from \"event exceptions\" and build elegant APIs around this insight.\n\nThe result? **Event-driven Python that feels like native Python.**\n\n---\n\n<div align=\"center\">\n\n**\ud83d\udd25 Ready to simplify your event-driven code?**\n\n```bash\npip install eventx\n```\n\n<strong>Powered by Nexus Studio</strong><br>\n<em>Making Python event-driven development effortless</em>\n\n</div>\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Tryboy869\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "Event-driven messaging via exceptions - Ultra-lightweight event system",
    "version": "0.1.0",
    "project_urls": {
        "Bug Reports": "https://github.com/Tryboy869/eventx/issues",
        "Documentation": "https://github.com/Tryboy869/eventx#readme",
        "Homepage": "https://github.com/Tryboy869/eventx",
        "Repository": "https://github.com/Tryboy869/eventx"
    },
    "split_keywords": [
        "events",
        " messaging",
        " exceptions",
        " event-driven",
        " lightweight",
        " async-alternative",
        " microservices",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "af853bc396bc0f8416aa8535588215043535c87a8a28a9223b1a1a69757a8d31",
                "md5": "f238a330105cc92f500518fa113a3308",
                "sha256": "527862016f2f22b513d951b33a943855878bc404b946ba6f8f1ba81bb6177335"
            },
            "downloads": -1,
            "filename": "eventx-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f238a330105cc92f500518fa113a3308",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6168,
            "upload_time": "2025-08-30T20:09:59",
            "upload_time_iso_8601": "2025-08-30T20:09:59.308895Z",
            "url": "https://files.pythonhosted.org/packages/af/85/3bc396bc0f8416aa8535588215043535c87a8a28a9223b1a1a69757a8d31/eventx-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a0e5adf6b93f1cd179cd7ed21d9f753a74e7755c85434d3dc5d07e35e3aec412",
                "md5": "a36c9ad1453350b98034a9eb0a1fd844",
                "sha256": "dc3cb92feca7b4a262dedeb6529ddd8a6fa5942d8b109540d9432e7cefbea76d"
            },
            "downloads": -1,
            "filename": "eventx-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a36c9ad1453350b98034a9eb0a1fd844",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6468,
            "upload_time": "2025-08-30T20:10:00",
            "upload_time_iso_8601": "2025-08-30T20:10:00.736193Z",
            "url": "https://files.pythonhosted.org/packages/a0/e5/adf6b93f1cd179cd7ed21d9f753a74e7755c85434d3dc5d07e35e3aec412/eventx-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-30 20:10:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Tryboy869",
    "github_project": "eventx",
    "github_not_found": true,
    "lcname": "eventx"
}
        
Elapsed time: 1.21966s