chore: execute goimports to format the code (#7983)
* chore: execute goimports to format the code Signed-off-by: promalert <promalert@outlook.com> * goimports -w . --------- Signed-off-by: promalert <promalert@outlook.com> Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@ func (s3a *S3ApiServer) WithFilerClient(streamingMode bool, fn func(filer_pb.Sea
|
||||
if s3a.filerClient != nil {
|
||||
return s3a.withFilerClientFailover(streamingMode, fn)
|
||||
}
|
||||
|
||||
|
||||
// Fallback to direct connection if filerClient not initialized
|
||||
// This should only happen during initialization or testing
|
||||
return pb.WithGrpcClient(streamingMode, s3a.randomClientId, func(grpcConnection *grpc.ClientConn) error {
|
||||
@@ -34,41 +34,41 @@ func (s3a *S3ApiServer) WithFilerClient(streamingMode bool, fn func(filer_pb.Sea
|
||||
func (s3a *S3ApiServer) withFilerClientFailover(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||
// Get current filer as starting point
|
||||
currentFiler := s3a.filerClient.GetCurrentFiler()
|
||||
|
||||
|
||||
// Try current filer first (fast path)
|
||||
err := pb.WithGrpcClient(streamingMode, s3a.randomClientId, func(grpcConnection *grpc.ClientConn) error {
|
||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||
return fn(client)
|
||||
}, currentFiler.ToGrpcAddress(), false, s3a.option.GrpcDialOption)
|
||||
|
||||
|
||||
if err == nil {
|
||||
s3a.filerClient.RecordFilerSuccess(currentFiler)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Record failure for current filer
|
||||
s3a.filerClient.RecordFilerFailure(currentFiler)
|
||||
|
||||
|
||||
// Current filer failed - try all other filers with health-aware selection
|
||||
filers := s3a.filerClient.GetAllFilers()
|
||||
var lastErr error = err
|
||||
|
||||
|
||||
for _, filer := range filers {
|
||||
if filer == currentFiler {
|
||||
continue // Already tried this one
|
||||
}
|
||||
|
||||
|
||||
// Skip filers known to be unhealthy (circuit breaker pattern)
|
||||
if s3a.filerClient.ShouldSkipUnhealthyFiler(filer) {
|
||||
glog.V(2).Infof("WithFilerClient: skipping unhealthy filer %s", filer)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
err = pb.WithGrpcClient(streamingMode, s3a.randomClientId, func(grpcConnection *grpc.ClientConn) error {
|
||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||
return fn(client)
|
||||
}, filer.ToGrpcAddress(), false, s3a.option.GrpcDialOption)
|
||||
|
||||
|
||||
if err == nil {
|
||||
// Success! Record success and update current filer for future requests
|
||||
s3a.filerClient.RecordFilerSuccess(filer)
|
||||
@@ -76,13 +76,13 @@ func (s3a *S3ApiServer) withFilerClientFailover(streamingMode bool, fn func(file
|
||||
glog.V(1).Infof("WithFilerClient: failover from %s to %s succeeded", currentFiler, filer)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Record failure for health tracking
|
||||
s3a.filerClient.RecordFilerFailure(filer)
|
||||
glog.V(2).Infof("WithFilerClient: failover to %s failed: %v", filer, err)
|
||||
lastErr = err
|
||||
}
|
||||
|
||||
|
||||
// All filers failed
|
||||
return fmt.Errorf("all filers failed, last error: %w", lastErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user