feat: add subscription management and graceful shutdown support (v0.3.6)

- Add SubscriptionHandle for managing stream lifecycle
- Implement graceful shutdown with stop() methods
- Update documentation with new features
- Bump version to 0.3.6
This commit is contained in:
ysq
2025-08-21 15:47:31 +08:00
parent 372bb765af
commit 9ec7194d2a
10 changed files with 238 additions and 68 deletions
+20
View File
@@ -130,6 +130,16 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
)
.await?;
// 支持 stop 方法,测试代码 - 异步1000秒之后停止
let grpc_clone = grpc.clone();
tokio::spawn(async move {
tokio::time::sleep(std::time::Duration::from_secs(1000)).await;
grpc_clone.stop().await;
});
println!("Waiting for Ctrl+C to stop...");
tokio::signal::ctrl_c().await?;
Ok(())
}
@@ -163,6 +173,16 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
println!("Listening for events, press Ctrl+C to stop...");
shred_stream.shredstream_subscribe(protocols, None, event_type_filter, callback).await?;
// 支持 stop 方法,测试代码 - 异步1000秒之后停止
let shred_clone = shred_stream.clone();
tokio::spawn(async move {
tokio::time::sleep(std::time::Duration::from_secs(1000)).await;
shred_clone.stop().await;
});
println!("Waiting for Ctrl+C to stop...");
tokio::signal::ctrl_c().await?;
Ok(())
}