docs.rs failed to build moosicbox_server_simulator-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
moosicbox_server_simulator-0.1.1
MoosicBox Server Simulator
Simulation utilities for testing MoosicBox server components and network interactions.
Overview
The MoosicBox Server Simulator package provides:
- Action Queue System: Centralized action management for simulation steps
- Host Bouncing: Server restart and failover simulation via
queue_bounceandhandle_actions - Connection Utilities: Robust TCP connection establishment with retry logic
- Simulation Actors: Pre-built client actors (health checker, fault injector) and host implementations (MoosicBox server)
- HTTP Utilities: HTTP request generation, response parsing, and header validation
Features
Action Management
- Queue System: Thread-safe action queuing with VecDeque
- Action Processing: Batch action execution during simulation steps
- Host Bouncing: Simulate server restarts and failovers
Connection Utilities
- Retry Logic: Automatic connection retry with backoff
- Timeout Handling: 5-second timeout per connection attempt
- Error Recovery: Handle connection refused and reset scenarios
Simulation Integration
- Simvar Integration: Built on the simvar deterministic simulation framework
- TCP Streams: Simulated network connection support
- Multi-Attempt Logic: Robust connection establishment with configurable retries
Cargo Features
- default: Enables
player,sqlite,telemetry, andupnp - player: Enables player-related server functionality through
moosicbox_server/player - sqlite: Enables SQLite-backed server functionality through
moosicbox_server/sqlite - telemetry: Enables telemetry integration through
moosicbox_server/telemetryandsimvar/telemetry - upnp: Enables UPnP integration through
moosicbox_server/upnpandsimvar/upnp(also enablesplayer) - fail-on-warnings: Propagates strict warning-as-error behavior to simulator dependencies
Installation
Add this to your Cargo.toml:
[]
= { = "../server/simulator" }
Usage
Action Queue Management
use ;
// Queue a host bounce action
queue_bounce;
// Process queued actions in simulation step
handle_actions;
Connection Testing
use try_connect;
// Attempt connection with retry logic
let stream = try_connect.await?;
// Use the established connection
perform_test_operations.await;
Integration with Simvar
use Sim;
use handle_actions;
// In simulation step handler
Full Simulator Bootstrap
use ;
use ;
;
HTTP Utilities
use ;
let mut stream = try_connect.await?;
let raw = http_request.await?;
let parsed = parse_http_response?;
assert_eq!;
Running the Simulator Binary
Optional environment variable:
PORT: service port used byhost::moosicbox_server::startin the simulator binary
Modules
client
Client-side simulation actors and utilities:
- health_checker: Health check client with interaction plans
- fault_injector: Fault injection client for testing resilience
host
Host/server-side simulation implementations:
- moosicbox_server: MoosicBox server host actor with TCP proxying
http
HTTP request and response utilities:
- HTTP request generation
- HTTP response parsing
- Header validation helpers
Error Handling
Connection Errors
- ConnectionRefused: Retry with backoff
- ConnectionReset: Retry with backoff
- TimedOut: Timeout after maximum duration
- Other Errors: Immediate failure
Retry Logic
- Max Attempts: Configurable retry limit
- Backoff: 5-second delay between attempts
- Timeout: 5-second timeout per attempt
Dependencies
Core Dependencies
- simvar: Deterministic simulation framework with async, TCP, HTTP, and network support
- tokio: Async runtime and networking
- actix-web: Web server framework (used by moosicbox_server host)
- openport: Port allocation utilities
MoosicBox Dependencies
- moosicbox_assert: Assertion utilities
- moosicbox_config: Configuration management
- moosicbox_env_utils: Environment variable utilities
- moosicbox_logging: Logging utilities
- moosicbox_server: MoosicBox server implementation
Switchy Dependencies
- switchy_async: Async runtime abstraction
- switchy_env: Environment variable abstraction
- switchy_telemetry: Telemetry support
Other Dependencies
- log: Logging facade
- net2: Network utilities for TCP configuration
- serde_json: JSON serialization
- strum: Enum utilities
Integration
This package enables:
- Failover Testing: Simulating server restarts and testing high availability scenarios
- Network Simulation: Testing connection failure and recovery behaviors
- Integration Testing: Running multi-component system simulations with deterministic network and timing