Skip to main content

nodus-adapter-base

Abstract base class for nodus-channels adapters.

Provides the reconnect loop, health recording, and connection management so concrete adapters (Slack, Discord, webhook, etc.) only implement the three transport-specific methods.

Status: v0.1.0 — prepared, not yet published.


Install

pip install nodus-adapter-base

Requires nodus-channels>=0.1.0.


What it provides

Class Purpose
BaseChannelAdapter Abstract base with connect() retry backoff, health recording, send(), subscribe()
ConnectionManager start_all(), stop_all(), health_check_all() across a ChannelRegistry

Implementing an adapter

from nodus_channels import ChannelInfo, Message
from nodus_adapter_base import BaseChannelAdapter

class SlackAdapter(BaseChannelAdapter):
    @property
    def channel_id(self) -> str:
        return "slack"

    @property
    def info(self) -> ChannelInfo:
        return ChannelInfo(id="slack", display_name="Slack")

    async def _do_connect(self) -> None:
        # establish websocket / API connection
        ...

    async def _do_send(self, content, peer_id, *, thread_id=None,
                       reply_to_id=None, attachments=None) -> str:
        # send message; return message ID
        return "slack-msg-id"

    def _do_subscribe(self):
        # return an async generator yielding Message objects
        async def _gen():
            ...
            yield message
        return _gen()

Reconnect backoff

connect() retries up to max_reconnect_attempts times (default 5) using the backoff schedule [1, 5, 30, 60, 300] seconds. Each failure is recorded on the HealthMonitor. Raises the last exception if all attempts fail.

Health recording

Every connect(), send(), and health_check() call records success or failure on the adapter's HealthMonitor. Access it via adapter.health_monitor.


ConnectionManager

from nodus_channels import ChannelRegistry
from nodus_adapter_base import ConnectionManager

registry = ChannelRegistry()
registry.register(SlackAdapter())
registry.register(DiscordAdapter())

manager = ConnectionManager(registry)
results = await manager.start_all()        # {"slack": True, "discord": True}
health  = await manager.health_check_all() # {"slack": True, "discord": False}
await manager.stop_all()

Development

cd base
pip install -e ".[dev]"
pytest tests/ -q

License

MIT — see LICENSE.

Metadata

Release files for nodus-adapter-base 0.1.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 nodus-adapter-base 0.1.0
File Size Uploaded
nodus_adapter_base-0.1.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nodus-adapter-base 0.1.0
File Interpreter ABI Platform
nodus_adapter_base-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / nodus_adapter_base-0.1.0.tar.gz

Download URL nodus_adapter_base-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5f655a051e92105dd1ae8793a4cced93816fc34b66b871c121fbbe2bbcd97836
BLAKE2b-256 checksum
How to use checksums
2492d26cb759f505e86536d5d4e45e882ec635b7b0c9f873a98c6619ddeaf7b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / nodus_adapter_base-0.1.0-py3-none-any.whl

Download URL nodus_adapter_base-0.1.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94ad24f3faa9b372def845ba2464fc98fba2154fed8f5bde883aef0c3ae01bf2
BLAKE2b-256 checksum
How to use checksums
b3b543da8597b3dc8569c86c345ddd1e5c7da410bf0c7436b7acf992870ab5cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

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