Registry
Backend discovery and registration service for Plexus hubs.
Overview
Registry is a standalone service that enables dynamic discovery of Plexus backend instances. It stores backend connection information and provides a simple API for registration, discovery, and health checks.
Key features:
- SQLite storage with TOML configuration
- Auto-registration of local Plexus instance
- Manual registration via RPC
- Health check timestamps
- Config file hot-reloading
Quick Start
Running the Registry
By default, the registry starts on port 4445 (4444 is reserved for the main Plexus instance).
Configuration
The registry looks for configuration at ~/.config/plexus/backends.toml:
[[]]
= "plexus"
= "127.0.0.1"
= 4444
= "ws"
= "Local Plexus instance"
[[]]
= "prod"
= "plexus.example.com"
= 4444
= "wss"
= "Production Plexus hub"
Environment Variables
REGISTRY_PORT- WebSocket server port (default: 4445)RUST_LOG- Logging level (default: info)
API Methods
All methods are in the registry namespace:
register
Register a new backend.
Parameters:
name(string, required) - Unique backend namehost(string, required) - Host addressport(number, required) - Port numberprotocol(string, optional) - Protocol ("ws" or "wss", default: "ws")description(string, optional) - Human-readable descriptionnamespace(string, optional) - Routing namespace
Example:
list
List all registered backends.
Parameters:
active_only(boolean, optional) - Filter to active backends only (default: true)
Example:
get
Get a specific backend by name.
Parameters:
name(string, required) - Backend name
Example:
update
Update an existing backend.
Parameters:
name(string, required) - Backend name to updatehost(string, optional) - New host addressport(number, optional) - New port numberprotocol(string, optional) - New protocoldescription(string, optional) - New descriptionnamespace(string, optional) - New namespace
Example:
delete
Remove a backend from the registry.
Parameters:
name(string, required) - Backend name to delete
Example:
ping
Update the health check timestamp for a backend.
Parameters:
name(string, required) - Backend name
Example:
reload
Reload backends from the configuration file.
Example:
Testing with websocat
# Start the registry
&
# Connect with websocat
# List backends
}}
# Register a new backend
}}
Integration with Synapse
Synapse can discover backends from the registry:
# Synapse will query the registry for available backends
# This internally:
# 1. Connects to registry at localhost:4445
# 2. Calls registry.get("hub2")
# 3. Connects to the discovered backend
# 4. Executes cone.list
Architecture
Data Flow
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Synapse │────────>│ Registry │────────>│ SQLite │
│ Client │ discover│ Service │ store │ Database │
└──────────┘ └──────────┘ └──────────┘
│
│ load
▼
┌──────────┐
│ TOML │
│ Config │
└──────────┘
Storage Priority
- Runtime registrations (via
registerRPC) - Database (persisted from previous runs)
- Config file (
~/.config/plexus/backends.toml) - Auto-registration (self at localhost:4444)
Source Types
Auto- Automatically registered at startup (e.g., plexus @ localhost:4444)File- Loaded from TOML configuration fileManual- Registered via RPC callEnv- Loaded from environment variables (future)
Development
Building
Running Tests
As a Library
use ;
use TransportServer;
use Arc;
async
License
AGPL-3.0-only