fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey

fix IsOptsWithFromKey
This commit is contained in:
leoyang.yl
2021-09-09 19:32:08 +08:00
parent 884e7ddb14
commit ad69fe0f40
3 changed files with 29 additions and 24 deletions

View File

@ -16,9 +16,6 @@ package clientv3
import (
"math/rand"
"reflect"
"runtime"
"strings"
"time"
)
@ -32,18 +29,3 @@ func jitterUp(duration time.Duration, jitter float64) time.Duration {
multiplier := jitter * (rand.Float64()*2 - 1)
return time.Duration(float64(duration) * (1 + multiplier))
}
// Check if the provided function is being called in the op options.
func isOpFuncCalled(op string, opts []OpOption) bool {
for _, opt := range opts {
v := reflect.ValueOf(opt)
if v.Kind() == reflect.Func {
if opFunc := runtime.FuncForPC(v.Pointer()); opFunc != nil {
if strings.Contains(opFunc.Name(), op) {
return true
}
}
}
}
return false
}