kevo/pkg/replication/replicator_ext.go
Jeremy Tregunna 5963538bc5
All checks were successful
Go Tests / Run Tests (1.24.2) (pull_request) Successful in 9m49s
feat: implement replication transport layer
This commit implements the replication transport layer as part of Phase 2 of the replication plan.
Key components include:

- Add protocol buffer definitions for replication services
- Implement WALReplicator extension for processor management
- Create replication service server implementation
- Add replication client and server transport implementations
- Implement storage snapshot interface for bootstrap operations
- Standardize package naming across replication components
2025-04-26 13:05:54 -06:00

46 lines
935 B
Go

package replication
// No imports needed
// processorIndex finds the index of a processor in the processors slice
// Returns -1 if not found
func (r *WALReplicator) processorIndex(target EntryProcessor) int {
r.mu.RLock()
defer r.mu.RUnlock()
for i, p := range r.processors {
if p == target {
return i
}
}
return -1
}
// RemoveProcessor removes an EntryProcessor from the replicator
func (r *WALReplicator) RemoveProcessor(processor EntryProcessor) {
if processor == nil {
return
}
r.mu.Lock()
defer r.mu.Unlock()
// Find the processor in the slice
idx := -1
for i, p := range r.processors {
if p == processor {
idx = i
break
}
}
// If found, remove it
if idx >= 0 {
// Remove the element by replacing it with the last element and truncating
lastIdx := len(r.processors) - 1
if idx < lastIdx {
r.processors[idx] = r.processors[lastIdx]
}
r.processors = r.processors[:lastIdx]
}
}