- 引入 LogicalConn/TransportConn 分层,ClientConn 保留兼容适配层 - 新增 Stream、Bulk、RecordStream 三条数据面能力及对应控制路径 - 完成 transfer/file 传输内核与状态快照、诊断能力 - 补齐 reconnect、inbound dispatcher、modern psk 等基础模块 - 增加大规模回归、并发与基准测试覆盖 - 更新依赖库
77 lines
2.5 KiB
Go
77 lines
2.5 KiB
Go
package notify
|
|
|
|
import "time"
|
|
|
|
type snapshotBindingDiagnostics struct {
|
|
BindingOwner string
|
|
BindingAlive bool
|
|
BindingCurrent bool
|
|
BindingReason string
|
|
BindingError string
|
|
TransportAttached bool
|
|
TransportHasRuntimeConn bool
|
|
TransportCurrent bool
|
|
TransportDetachReason string
|
|
TransportDetachKind string
|
|
TransportDetachError string
|
|
TransportDetachGeneration uint64
|
|
TransportDetachedAt time.Time
|
|
ReattachEligible bool
|
|
}
|
|
|
|
func snapshotBindingDiagnosticsFromClient(c *ClientCommon, sessionEpoch uint64) snapshotBindingDiagnostics {
|
|
diag := snapshotBindingDiagnostics{
|
|
BindingOwner: "client-session",
|
|
}
|
|
if c == nil {
|
|
return diag
|
|
}
|
|
status := c.Status()
|
|
diag.BindingAlive = status.Alive
|
|
diag.BindingCurrent = sessionEpoch == 0 || c.isClientSessionEpochCurrent(sessionEpoch)
|
|
diag.BindingReason = status.Reason
|
|
if status.Err != nil {
|
|
diag.BindingError = status.Err.Error()
|
|
}
|
|
diag.TransportAttached = c.clientTransportAttachedSnapshot()
|
|
diag.TransportHasRuntimeConn = c.clientTransportConnSnapshot() != nil
|
|
diag.TransportCurrent = diag.BindingCurrent && diag.TransportAttached
|
|
return diag
|
|
}
|
|
|
|
func snapshotBindingDiagnosticsFromLogical(logical *LogicalConn, transport *TransportConn, transportGeneration uint64) snapshotBindingDiagnostics {
|
|
if logical == nil && transport != nil {
|
|
logical = transport.LogicalConn()
|
|
}
|
|
diag := snapshotBindingDiagnostics{}
|
|
if logical == nil {
|
|
return diag
|
|
}
|
|
runtime := logical.runtimeSnapshot()
|
|
diag.BindingOwner = "server-logical"
|
|
if transport != nil {
|
|
diag.BindingOwner = "server-transport"
|
|
}
|
|
diag.BindingAlive = runtime.Alive
|
|
diag.BindingReason = runtime.Reason
|
|
diag.BindingError = runtime.Error
|
|
diag.TransportAttached = runtime.TransportAttached
|
|
diag.TransportHasRuntimeConn = runtime.HasRuntimeConn
|
|
diag.TransportDetachReason = runtime.TransportDetachReason
|
|
diag.TransportDetachKind = runtime.TransportDetachKind
|
|
diag.TransportDetachError = runtime.TransportDetachError
|
|
diag.TransportDetachGeneration = runtime.TransportDetachGeneration
|
|
diag.TransportDetachedAt = runtime.TransportDetachedAt
|
|
diag.ReattachEligible = runtime.ReattachEligible
|
|
switch {
|
|
case transport != nil:
|
|
diag.TransportCurrent = transport.IsCurrent()
|
|
case transportGeneration != 0:
|
|
diag.TransportCurrent = runtime.TransportAttached && runtime.TransportGeneration == transportGeneration
|
|
default:
|
|
diag.TransportCurrent = runtime.TransportAttached
|
|
}
|
|
diag.BindingCurrent = diag.BindingAlive && diag.TransportCurrent
|
|
return diag
|
|
}
|