v0.2.0 - Hore Async LFG
Breaking Changes
Major Architecture Change: Thread Pool to Async
The library has been completely refactored from a thread pool-based
implementation to an async/tokio-based architecture. This is a major breaking
change.
API Changes:
-
Server::new()replaced withMethods::new() -
server.register()replaced withmethods.add() -
server.run()replaced withjson_rpc::serve(transport, methods) -
Method handlers must now be async functions instead of sync closures
-
Example:
// Old API server.register("add", |params: (i32, i32)| { Ok(params.0 + params.1) })?; server.run()?; // New API methods.add("add", |params: (i32, i32)| async move { Ok(params.0 + params.1) }); json_rpc::serve(transport, methods).await?;
Removed Features:
- Thread pool configuration (concurrency now handled by tokio's task scheduler)
ShutdownSignalfor graceful server shutdownCancellationTokenfor request cancellationwith_thread_pool_size()methodwith_shutdown_signal()methodwith_transport()method (transport now passed toserve())Servertype and all its methods
New Features:
- Full async/await support built on tokio
- HTTP transport using axum web framework
- Improved transport abstraction - each transport implements its own serving
logic - Better separation of concerns between protocol handling and transport
Module Changes:
src/server.rsremoved (functionality moved to lib.rs and transports)src/shutdown.rsremovedsrc/cancellation.rsremovedsrc/methods.rsadded (method registry with builder pattern)src/transports/http.rsadded (new HTTP transport)
Dependency Changes:
- Added:
tokio(1.0) - async runtime - Added:
axum(0.7) - HTTP web server framework - Removed:
num_cpus- no longer needed - Removed:
assert_cmd- testing infrastructure changed
Migration Guide:
To migrate from the old thread pool-based API:
- Add
tokioto yourCargo.tomlwithfeatures = ["full"] - Change all method handlers to async functions
- Replace
Server::new()withMethods::new() - Replace
server.register()calls withmethods.add() - Replace
server.run()withjson_rpc::serve(transport, methods).await - Remove any shutdown signal or cancellation token usage
- Update to use one of the three transports:
Stdio,Http, orInMemory