Observed since 20 Oct, 20:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AetherMagic - Multi-protocol communications library with channel support (MQTT, Redis, WebSocket, ZeroMQ, RabbitMQ)
AetherMagic is a powerful multi-protocol communication library for microservices, providing a unified API for different transport mechanisms including MQTT, Redis, HTTP/WebSocket, and ZeroMQ.
pip install aethermagic
Install only the protocols you need:
# For MQTT support
pip install aethermagic[mqtt]
# For Redis support
pip install aethermagic[redis]
# For WebSocket support
pip install aethermagic[websocket]
# For ZeroMQ support
pip install aethermagic[zeromq]
# For RabbitMQ support
pip install aethermagic[rabbitmq]
# Install all protocols
pip install aethermagic[all]
import asyncio
from aethermagic import AetherMagic, ProtocolType, AetherTask
# MQTT (original)
aether_mqtt = AetherMagic(
protocol_type=ProtocolType.MQTT,
host='localhost',
port=1883
)
# Redis Pub/Sub
aether_redis = AetherMagic(
protocol_type=ProtocolType.REDIS,
host='localhost',
port=6379
)
# Redis Streams (with reliable delivery)
aether_streams = AetherMagic(
protocol_type=ProtocolType.REDIS,
host='localhost',
port=6379,
use_streams=True,
consumer_group='workers'
)
# HTTP/WebSocket
aether_http = AetherMagic(
protocol_type=ProtocolType.HTTP,
host='localhost',
port=8080,
mode='client' # or 'server'
)
# ZeroMQ
aether_zmq = AetherMagic(
protocol_type=ProtocolType.ZEROMQ,
host='localhost',
port=5555,
pattern='pubsub' # or 'pushpull', 'reqrep'
)
async def handle_task(ae_task, data):
print(f"Processing: {data}")
# Send intermediate status
await ae_task.status(50)
# Simulate work
await asyncio.sleep(2)
# Complete task
await ae_task.complete(True, {"result": "success"})
# Create task
task = AetherTask(
job='my_service',
task='process_data',
context='production',
on_perform=handle_task
)
# Register worker
await task.idle()
# Start main loop
await aether.main()
async def on_status(ae_task, complete, succeed, progress, data):
if complete:
print(f"Task finished: {succeed}")
else:
print(f"Progress: {progress}%")
async def on_complete(ae_task, succeed, data):
print(f"Result: {data}")
# Create client task
client_task = AetherTask(
job='my_service',
task='process_data',
context='production',
on_status=on_status,
on_complete=on_complete
)
# Send task
await client_task.perform({
"input_file": "/path/to/data.csv",
"options": {"format": "json"}
})
AetherMagic automatically distributes tasks among multiple workers for all protocols:
# Multiple workers subscribe to shared topic
# $share/union_job_workgroup/union/job/task/context/+/perform
await aether.listen('image-process', 'resize', 'batch1', 'perform', 'workers', handle_task)
# Atomic LPUSH/BRPOP operations ensure single delivery
await aether.listen('image-process', 'resize', 'batch1', 'perform', 'workers', handle_task)
# Tasks distributed randomly among connected clients
await aether.listen('image-process', 'resize', 'batch1', 'perform', 'workers', handle_task)
# Natural load balancing with PUSH/PULL sockets
await aether.listen('image-process', 'resize', 'batch1', 'perform', 'workers', handle_task)
Key Benefits:
See TASK_DISTRIBUTION.md for detailed examples.
Use when:
Use when:
Use when:
Use when:
Use when:
See examples.py for complete usage examples of each protocol:
# Run Redis example
python examples.py redis
# Run HTTP/WebSocket example
python examples.py http
# Run ZeroMQ example
python examples.py zeromq
# Multi-protocol example
python examples.py multi
config = ConnectionConfig(
protocol_type=ProtocolType.REDIS,
host='localhost',
port=6379,
ssl=False,
username='user',
password='pass',
union='my_app', # namespace for application
timeout=30,
keepalive=60
)
aether = AetherMagic(
protocol_type=ProtocolType.REDIS,
use_streams=True,
consumer_group='workers',
consumer_name='worker_1'
)
aether = AetherMagic(
protocol_type=ProtocolType.HTTP,
mode='server', # or 'client'
ssl=True
)
aether = AetherMagic(
protocol_type=ProtocolType.ZEROMQ,
pattern='pushpull', # 'pubsub', 'reqrep', 'all'
server_mode=True
)
| Protocol | Throughput | Latency | Reliability | Complexity |
|---|---|---|---|---|
| MQTT | Medium | Low | High | Low |
| Redis Pub/Sub | High | Very Low | Medium | Low |
| Redis Streams | High | Low | High | Medium |
| HTTP/WebSocket | Medium | Medium | High | Medium |
| ZeroMQ | Very High | Very Low | Medium | High |
Existing MQTT code continues to work without changes:
# Old code
from aethermagic import AetherMagic
aether = AetherMagic(server="localhost", port=1883)
The new API is fully compatible and adds additional capabilities.
AetherMagic now supports load-balanced task distribution to ensure each task is processed by only one worker:
from aethermagic.protocols.redis_protocol import RedisLoadBalancedProtocol
worker = RedisLoadBalancedProtocol(config, consumer_id="worker_1")
await worker.subscribe_to_tasks("job", "task", "context", callback)
$share prefixUse the new convenience methods for load-balanced task processing:
from aethermagic import AetherMagic, ProtocolType
# Create workers
worker = AetherMagic(protocol_type=ProtocolType.REDIS, host="localhost", port=6379)
await worker.connect()
# Add load-balanced task handler
await worker.add_task(
job="processing",
task="compute",
context="demo",
callback=task_handler,
shared=True # Enable load balancing
)
# Publish load-balanced tasks
await worker.perform_task(
job="processing",
task="compute",
context="demo",
data={"work": "data"},
shared=True # Only one worker will receive this
)
AetherMagic supports running multiple protocols simultaneously using channel isolation:
import asyncio
from aethermagic import AetherMagic, AetherTask
async def multi_protocol_service():
# MQTT for general messaging
mqtt_service = AetherMagic(
protocol_type='mqtt',
host='mqtt.example.com',
port=8883,
ssl=True,
union='production',
channel='messaging' # 🔥 Channel identifier
)
# Redis for caching and AI tasks
redis_service = AetherMagic(
protocol_type='redis',
host='redis.example.com',
port=6379,
ssl=True,
union='production',
channel='caching' # 🔥 Different channel
)
# Start both services
mqtt_task = asyncio.create_task(mqtt_service.main())
redis_task = asyncio.create_task(redis_service.main())
# Create tasks for different channels
mqtt_task = AetherTask(
job='notifications',
task='send_email',
channel='messaging' # Uses MQTT
)
redis_task = AetherTask(
job='ai',
task='generate_image',
channel='caching' # Uses Redis
)
# Execute tasks
await mqtt_task.perform({'email': 'user@example.com'})
await redis_task.perform({'prompt': 'sunset landscape'})
# Run the service
asyncio.run(multi_protocol_service())
AetherMagic automatically installs protocol-specific dependencies when you install the optional packages:
asyncio-mqtt, paho-mqtt, aiomqttredis[hiredis] (includes high-performance hiredis parser)aiohttp, websocketspyzmqaio-pikaAll protocols now support the shared=True parameter for load-balanced task distribution.
See load_balanced_demo.py for complete working examples.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.2.23 | 8 Dec 2025 | 10 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 20:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:8117d3bf85aa395d211b54c3b1378633e7eeb5a092ee52da0e92d46eaedd8499