mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-17 02:48:05 +00:00
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:
+20
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user