TrackMovingOperationWithConnID starts a new MOVING operation with a specific connection ID.
(ctx context.Context, newEndpoint string, deadline time.Time, seqID int64, connID uint64)
| 156 | |
| 157 | // TrackMovingOperationWithConnID starts a new MOVING operation with a specific connection ID. |
| 158 | func (hm *Manager) TrackMovingOperationWithConnID(ctx context.Context, newEndpoint string, deadline time.Time, seqID int64, connID uint64) error { |
| 159 | // Create composite key |
| 160 | key := MovingOperationKey{ |
| 161 | SeqID: seqID, |
| 162 | ConnID: connID, |
| 163 | } |
| 164 | |
| 165 | // Create MOVING operation record |
| 166 | movingOp := &MovingOperation{ |
| 167 | SeqID: seqID, |
| 168 | NewEndpoint: newEndpoint, |
| 169 | StartTime: time.Now(), |
| 170 | Deadline: deadline, |
| 171 | } |
| 172 | |
| 173 | // Use LoadOrStore for atomic check-and-set operation |
| 174 | if _, loaded := hm.activeMovingOps.LoadOrStore(key, movingOp); loaded { |
| 175 | // Duplicate MOVING notification, ignore |
| 176 | if internal.LogLevel.DebugOrAbove() { // Debug level |
| 177 | internal.Logger.Printf(context.Background(), logs.DuplicateMovingOperation(connID, newEndpoint, seqID)) |
| 178 | } |
| 179 | return nil |
| 180 | } |
| 181 | if internal.LogLevel.DebugOrAbove() { // Debug level |
| 182 | internal.Logger.Printf(context.Background(), logs.TrackingMovingOperation(connID, newEndpoint, seqID)) |
| 183 | } |
| 184 | |
| 185 | // Increment active operation count atomically |
| 186 | hm.activeOperationCount.Add(1) |
| 187 | |
| 188 | return nil |
| 189 | } |
| 190 | |
| 191 | // UntrackOperationWithConnID completes a MOVING operation with a specific connection ID. |
| 192 | func (hm *Manager) UntrackOperationWithConnID(seqID int64, connID uint64) { |