MCPcopy
hub / github.com/redis/go-redis / TrackMovingOperationWithConnID

Method TrackMovingOperationWithConnID

maintnotifications/manager.go:158–189  ·  view source on GitHub ↗

TrackMovingOperationWithConnID starts a new MOVING operation with a specific connection ID.

(ctx context.Context, newEndpoint string, deadline time.Time, seqID int64, connID uint64)

Source from the content-addressed store, hash-verified

156
157// TrackMovingOperationWithConnID starts a new MOVING operation with a specific connection ID.
158func (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.
192func (hm *Manager) UntrackOperationWithConnID(seqID int64, connID uint64) {

Callers 1

TestManagerRefactoringFunction · 0.95

Calls 5

DuplicateMovingOperationFunction · 0.92
TrackingMovingOperationFunction · 0.92
DebugOrAboveMethod · 0.80
PrintfMethod · 0.65
AddMethod · 0.65

Tested by 1

TestManagerRefactoringFunction · 0.76