refactor(link): bound every teardown and handler wait behind one helper [CI]
This commit is contained in:
1 parent
c05842fd91
commit
d95acc6575
10 files changed
+130
-31
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user