Skip to main content

Generic message bus transport — Unix Socket message routing, session management, heartbeat

Project description

hermes-bus

English | 中文

A generic message bus for Unix Socket IPC — message routing, session management, heartbeat.

Transport-only. Notification logic is injected via configurable hooks — the bus itself knows nothing about audio, display, or LLM context.

Install

pip install hermes-bus

Or from source:

git clone https://github.com/mlinquan/hermes-bus.git
cd hermes-bus && pip install -e .

CLI

# Daemon management
hermes-busd start       # Start the bus daemon
hermes-busd stop        # Stop the daemon
hermes-busd status      # Check daemon + connected endpoints
hermes-busd restart     # Restart the daemon

# Foreground server (for debugging)
hermes-bus-server

Python API

from hermes_bus.client import BusClient, send_message

# Long-lived: register as an endpoint and receive messages
client = BusClient("my-service")
client.connect()
for msg in client.poll():
    print(msg)

# Short-lived: fire-and-forget
send_message("target-service", {"text": "hello", "type": "ack"})

Architecture

client.py ──── Unix Socket ──── server.py
  (BusClient)                    (BusServer)
   - Register endpoint           - Session management
   - Heartbeat (60s)             - Message routing
   - Auto-reconnect              - Hook triggers
   - Thread-safe message queue
   
busd.py — Daemon manager: start / stop / status / restart

Protocol

4-byte big-endian length prefix + JSON body. Max payload: 10 MB.

Long-lived connections register an endpoint name and can send/receive. Short-lived connections send one message and disconnect — no registration, no endpoint_map pollution.

Hooks

After each message is routed, hook scripts are triggered asynchronously. Resolution priority:

  1. HERMES_BUS_HOOKS env var (comma-separated or JSON array of script paths)
  2. hooks.yaml config file
  3. Default: auto-discover hermes-notify/bus_callback.py

Each hook receives the full message JSON on stdin. Hook execution is non-blocking — the bus continues routing.

Messages

{
  "type": "message",
  "to": "target-endpoint",
  "from": "sender-endpoint",
  "text": "hello",
  "body": { }
}

Special message types: register (endpoint registration), ping/pong (heartbeat), list_endpoints (admin query).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hermes_bus-0.1.1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hermes_bus-0.1.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file hermes_bus-0.1.1.tar.gz.

File metadata

  • Download URL: hermes_bus-0.1.1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for hermes_bus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bf03ccbd9ae972b0d3cfc8f9a5332efdd917a21a57f8984a0afa2ff7d9529b33
MD5 aad0336fde907d7c7a1d311a11c4218c
BLAKE2b-256 8291b725f9ab52c7bfa82bbe66301123670921d9efe174ca7087bde90c60ca48

See more details on using hashes here.

File details

Details for the file hermes_bus-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hermes_bus-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for hermes_bus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58c09c1d3d9dc2ab854221f9456c481e1c40845967263fa70d3b828f98d29f2d
MD5 149ebadb91ea5e0c6bcf631ea2a73755
BLAKE2b-256 18823d84eac159f1dc73f1848972332422b08b13ee5bc6440a29e57a7be80906

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page