Skip to main content

Crate ryo_server

Crate ryo_server 

Source
Expand description

RYO Server - tarpc-based RPC server

This crate provides the server implementation for RYO RPC. It wraps the Api and exposes it via tarpc over Unix Domain Socket.

§Architecture

┌─────────────────────────────────────────────────────────────────────┐
│  RyoServer                                                          │
│  ├── api: Arc<Mutex<Api>>  (single mutex for all operations)       │
│  ├── shutdown_tx: Shutdown signal sender                           │
│  └── last_activity: Atomic timestamp for idle detection            │
└─────────────────────────────────────────────────────────────────────┘
                             │
                             │ UDS + tarpc (serde_transport)
                             ▼
┌─────────────────────────────────────────────────────────────────────┐
│  Clients (ryo-cli)                                                  │
│  └── RyoServiceClient                                               │
└─────────────────────────────────────────────────────────────────────┘

§Idle Timeout

Server automatically shuts down after configurable idle time (default 1 hour). Configure via ~/.ryo/config.toml:

[server]
idle_timeout = 3600  # 1 hour (0 = never timeout)

§Parallel Initialization

By default, server uses parallel initialization for faster startup. Configure via ~/.ryo/config.toml:

[server]
parallel_init = true

§Locking Strategy

All operations acquire a single Mutex. This is sufficient because:

  • Write operations (run) are high-frequency but short-duration (~100μs)
  • Read operations (discover, suggest) are low-frequency
  • Lock contention is ~1% (100 writes/sec × 100μs = 10ms/sec)

RWLock overhead is unnecessary for this workload.

Modules§

watcher
File system watcher for automatic reloading

Structs§

RyoServer
Server wraps Api and implements RyoService
ServerOptions
Server startup options

Constants§

DEFAULT_IDLE_TIMEOUT
Default idle timeout: 1 hour (from config default)

Functions§

run_server
Run the server on Unix Domain Socket with default options from config
run_server_with_options
Run the server on Unix Domain Socket with full options
run_server_with_timeout
Run the server on Unix Domain Socket with configurable idle timeout (legacy)