Add grpc retry (#1160)
* Add grpc retry * Update grpc retry * Add tests * Fix a bug * Add api && some tests * Add comment * Add double check * Add server retry quota * Update optimize code * Fix bug * Update optimize code * Update optimize code * Fix bug
This commit is contained in:
25
core/retry/retryinterceptor_test.go
Normal file
25
core/retry/retryinterceptor_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDo(t *testing.T) {
|
||||
n := 4
|
||||
for i := 0; i < n; i++ {
|
||||
count := 0
|
||||
err := Do(context.Background(), func(ctx context.Context, opts ...grpc.CallOption) error {
|
||||
count++
|
||||
return status.Error(codes.ResourceExhausted, "ResourceExhausted")
|
||||
|
||||
}, WithMax(i))
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, i+1, count)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user