session 是单次 Session 的状态: - inflight:reqID -> cancelFunc,用于响应 cancel_id; - acks:seq -> chan struct{},用于 WaitAck; - sendMu:保护 stream.Send,多 goroutine 串行写。
| 71 | // - acks:seq -> chan struct{},用于 WaitAck; |
| 72 | // - sendMu:保护 stream.Send,多 goroutine 串行写。 |
| 73 | type session struct { |
| 74 | ctx context.Context |
| 75 | cancel context.CancelFunc |
| 76 | cfg Config |
| 77 | stream nodev1.NodeAgent_SessionClient |
| 78 | |
| 79 | sendMu sync.Mutex |
| 80 | |
| 81 | mu sync.Mutex |
| 82 | inflight map[string]context.CancelFunc |
| 83 | acks map[uint64]chan struct{} |
| 84 | |
| 85 | wg sync.WaitGroup |
| 86 | } |
| 87 | |
| 88 | func newSession(ctx context.Context, cancel context.CancelFunc, cfg Config, stream nodev1.NodeAgent_SessionClient) *session { |
| 89 | return &session{ |
nothing calls this directly
no outgoing calls
no test coverage detected