No project description provided
Project description
Eolic
Eolic is an event-driven library for Python that supports event emission, remote target handling, and listener registration with a simple and intuitive API.
The main purpose be an effective way to trigger hooks based on events and allow communication to another systems based on most common protocols.
Documentation
Read more about the usage with our Documentation and Examples
Installation
To install Eolic, clone this repository and run:
pip install eolic
Usage/Examples
from enum import Enum
from eolic import Eolic
# Defining all events on a enum (not required but it's a good practice)
class GameEvents(Enum):
ON_PLAYER_JOIN = "ON_PLAYER_JOIN"
ON_PLAYER_ATTACK = "ON_PLAYER_ATTACK"
ON_MONSTER_DEFEATED = "ON_MONSTER_DEFEATED"
ON_GAME_OVER = "ON_GAME_OVER"
# Instancing Eolic class defining a webhook as remote_target for "ON_MONSTER_DEFEATED" event
handler = Eolic(remote_targets=[
{
"type": "url",
"address": "https://mysite.site/api/game/hooks",
"headers": {"X-Game-Event":"RPGSecretKey"},
"events": [GameEvents.ON_MONSTER_DEFEATED]
}
])
# Defining hooks that will be executed locally
@handler.on(GameEvents.ON_PLAYER_JOIN)
def handle_player_join(player_name):
print(f"{player_name} has joined the game!")
@handler.on(GameEvents.ON_PLAYER_ATTACK)
def handle_player_attack(player_name, monster_name, damage):
print(f"{player_name} attacked {monster_name} for {damage} damage!")
@handler.on(GameEvents.ON_MONSTER_DEFEATED)
def handle_monster_defeated(player_name, monster_name):
print(f"{player_name} has defeated {monster_name}!")
@handler.on(GameEvents.ON_GAME_OVER)
def handle_game_over():
print("Game Over! Thanks for playing.")
# Emitting player join event
handler.emit(GameEvents.ON_PLAYER_JOIN, "Archer")
# Emitting player attack event
handler.emit(GameEvents.ON_PLAYER_ATTACK, "Archer", "Goblin", 30)
# Emitting monster defeated event
handler.emit(GameEvents.ON_MONSTER_DEFEATED, "Archer", "Goblin")
# Emitting game over event
handler.emit(GameEvents.ON_GAME_OVER)
Roadmap
- Implement integration for celery backend (RabbitMQ, Redis)
- Implement Direct RabbitMQ
- Allow Emit Async and Sync options
License
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
eolic-0.2.0.tar.gz
(13.0 kB
view details)
Built Distribution
eolic-0.2.0-py3-none-any.whl
(13.7 kB
view details)
File details
Details for the file eolic-0.2.0.tar.gz
.
File metadata
- Download URL: eolic-0.2.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.11 Linux/6.5.1-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e9b75550d22ad3be766665006a7d6e28761073c8e774449f5466de5c6e85ebc |
|
MD5 | 507dcc0b1ebdb82005932864d6888034 |
|
BLAKE2b-256 | 451354bf8a6e8fb8bda83b8fe291b11a9aaaed2f645ddddba739a28c8c0c1519 |
File details
Details for the file eolic-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: eolic-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.11 Linux/6.5.1-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ba1dd051e588cb837b0f23e4a42e18fe6ddf20332c07fdfa9cdefe2f52889a5 |
|
MD5 | 41f297278f2b29c05bcd477172972c79 |
|
BLAKE2b-256 | 096b45108eda93585dbcddde2ecb66df228f402d2b176366ce68783d37f5d34f |