refactor(link): bound every teardown and handler wait behind one helper [CI]
ci/woodpecker/push/web-build Pipeline was successful
ci/woodpecker/push/verify Pipeline was successful
ci/woodpecker/push/dev-image Pipeline was successful

This commit is contained in:
justme committed 2026-10-19 10:07:36 +08:00
1 parent c05842fd91
commit d95acc6575
10 files changed
+130 -31

No files matched your search

+3 -8
View File
@@ -50,6 +50,7 @@ public sealed class RpcSession<TContext> : IAsyncDisposable
private readonly IRpcTransport _transport;
private readonly RpcRouter<TContext> _router;
private readonly TContext _context;
private static readonly TimeSpan s_dispatcherGrace = TimeSpan.FromSeconds(5);
private readonly TimeProvider _time;
private readonly RpcSessionOptions _options;
private readonly ConcurrentDictionary<long, TaskCompletionSource<RpcMessage>> _pending = new();
@@ -135,14 +136,8 @@ public sealed class RpcSession<TContext> : IAsyncDisposable
}
await linked.CancelAsync();
try
{
await dispatcher;
}
catch (OperationCanceledException)
{
// 正常结束
}
// 某个入站处理器卡住了也不能拖住整个会话的结束(链路据此重连):它随取消令牌自己收尾
await Bounded.WaitAsync(dispatcher, s_dispatcherGrace, _time);
}
}