mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 20:37:23 +08:00
refactor
This commit is contained in:
@@ -50,7 +50,7 @@ func ReplicatedWrite(masterFn operation.GetMasterFn, s *storage.Store, volumeId
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(remoteLocations) > 0 { //send to other replica locations
|
if len(remoteLocations) > 0 { //send to other replica locations
|
||||||
if err = distributedOperation(remoteLocations, s, func(location operation.Location) error {
|
if err = DistributedOperation(remoteLocations, func(location operation.Location) error {
|
||||||
u := url.URL{
|
u := url.URL{
|
||||||
Scheme: "http",
|
Scheme: "http",
|
||||||
Host: location.Url,
|
Host: location.Url,
|
||||||
@@ -115,7 +115,7 @@ func ReplicatedDelete(masterFn operation.GetMasterFn, store *storage.Store,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(remoteLocations) > 0 { //send to other replica locations
|
if len(remoteLocations) > 0 { //send to other replica locations
|
||||||
if err = distributedOperation(remoteLocations, store, func(location operation.Location) error {
|
if err = DistributedOperation(remoteLocations, func(location operation.Location) error {
|
||||||
return util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate", string(jwt))
|
return util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate", string(jwt))
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
size = 0
|
size = 0
|
||||||
@@ -144,7 +144,7 @@ type RemoteResult struct {
|
|||||||
Error error
|
Error error
|
||||||
}
|
}
|
||||||
|
|
||||||
func distributedOperation(locations []operation.Location, store *storage.Store, op func(location operation.Location) error) error {
|
func DistributedOperation(locations []operation.Location, op func(location operation.Location) error) error {
|
||||||
length := len(locations)
|
length := len(locations)
|
||||||
results := make(chan RemoteResult)
|
results := make(chan RemoteResult)
|
||||||
for _, location := range locations {
|
for _, location := range locations {
|
||||||
|
Reference in New Issue
Block a user