mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-14 02:33:03 +02:00
parent
3c65f16737
commit
f0878b0a78
@ -161,7 +161,7 @@ func (n *Node) Pick() selector.DoneFunc {
|
||||
}
|
||||
var netErr net.Error
|
||||
if errors.Is(context.DeadlineExceeded, di.Err) || errors.Is(context.Canceled, di.Err) ||
|
||||
errors.IsServiceUnavailable(di.Err) || errors.IsGatewayTimeout(di.Err) || errors.As(di.Err, netErr) {
|
||||
errors.IsServiceUnavailable(di.Err) || errors.IsGatewayTimeout(di.Err) || errors.As(di.Err, &netErr) {
|
||||
success = 0
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package ewma
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@ -100,11 +101,15 @@ func TestDirectErrorHandler(t *testing.T) {
|
||||
Endpoints: []string{"http://127.0.0.1:9090"},
|
||||
Metadata: map[string]string{"weight": "10"},
|
||||
}))
|
||||
|
||||
errs := []error{
|
||||
context.DeadlineExceeded,
|
||||
context.Canceled,
|
||||
net.ErrClosed,
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
var err error
|
||||
if i != 0 {
|
||||
err = context.DeadlineExceeded
|
||||
err = errs[i%len(errs)]
|
||||
}
|
||||
done := wn.Pick()
|
||||
if done == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user