aboutsummaryrefslogtreecommitdiff
path: root/postgres-examples/test_client.py
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-10-30 21:10:38 -0700
committerchrislu <chris.lu@gmail.com>2025-10-30 21:10:38 -0700
commit8b9a48c1b5e87a607692cc229d9ecbf2cade675d (patch)
tree92cb9af0d0424ccdece319b97c9a9be2f45ef304 /postgres-examples/test_client.py
parent498922dbb2f7f2ac02bd695367b459fe1fe57a8e (diff)
downloadseaweedfs-8b9a48c1b5e87a607692cc229d9ecbf2cade675d.tar.xz
seaweedfs-8b9a48c1b5e87a607692cc229d9ecbf2cade675d.zip
Refactor: Extract common locking patterns into helper methods
Eliminated code duplication by introducing two helper methods that encapsulate the common locking patterns used throughout MasterClient: 1. getStableVidMap() - For read operations - Acquires lock, gets pointer, releases immediately - Returns stable snapshot for thread-safe reads - Used by: GetLocations, GetLocationsClone, GetVidLocations, LookupFileId, LookupVolumeServerUrl, GetDataCenter 2. withCurrentVidMap(f func(vm *vidMap)) - For write operations - Holds RLock during callback execution - Prevents pointer swap while allowing concurrent operations - Used by: addLocation, deleteLocation, addEcLocation, deleteEcLocation Benefits: - Reduced code duplication (eliminated 48 lines of repetitive locking code) - Centralized locking logic makes it easier to understand and maintain - Self-documenting pattern through named helper methods - Easier to modify locking strategy in the future (single point of change) - Improved readability - accessor methods are now one-liners Code size reduction: ~40% fewer lines for accessor/helper methods Verified with: go test -race ./weed/wdclient/... (passes)
Diffstat (limited to 'postgres-examples/test_client.py')
0 files changed, 0 insertions, 0 deletions