diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-30 13:26:22 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-30 15:44:45 +0300 |
commit | 0a98fece5a9b54f16afeb3a94b3eb3105e9c3962 (patch) | |
tree | 291d72dbd7e9865399f668c84d11ed86fb190bbf /vendor/github.com/go-redis/redis/v8/internal/rand | |
parent | cb2c8d75065e5b3c47094067cb4aa407d4813298 (diff) | |
download | ydb-0a98fece5a9b54f16afeb3a94b3eb3105e9c3962.tar.gz |
YQ Connector:Use docker-compose in integrational tests
Diffstat (limited to 'vendor/github.com/go-redis/redis/v8/internal/rand')
-rw-r--r-- | vendor/github.com/go-redis/redis/v8/internal/rand/rand.go | 50 | ||||
-rw-r--r-- | vendor/github.com/go-redis/redis/v8/internal/rand/ya.make | 7 |
2 files changed, 57 insertions, 0 deletions
diff --git a/vendor/github.com/go-redis/redis/v8/internal/rand/rand.go b/vendor/github.com/go-redis/redis/v8/internal/rand/rand.go new file mode 100644 index 0000000000..2edccba94f --- /dev/null +++ b/vendor/github.com/go-redis/redis/v8/internal/rand/rand.go @@ -0,0 +1,50 @@ +package rand + +import ( + "math/rand" + "sync" +) + +// Int returns a non-negative pseudo-random int. +func Int() int { return pseudo.Int() } + +// Intn returns, as an int, a non-negative pseudo-random number in [0,n). +// It panics if n <= 0. +func Intn(n int) int { return pseudo.Intn(n) } + +// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). +// It panics if n <= 0. +func Int63n(n int64) int64 { return pseudo.Int63n(n) } + +// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n). +func Perm(n int) []int { return pseudo.Perm(n) } + +// Seed uses the provided seed value to initialize the default Source to a +// deterministic state. If Seed is not called, the generator behaves as if +// seeded by Seed(1). +func Seed(n int64) { pseudo.Seed(n) } + +var pseudo = rand.New(&source{src: rand.NewSource(1)}) + +type source struct { + src rand.Source + mu sync.Mutex +} + +func (s *source) Int63() int64 { + s.mu.Lock() + n := s.src.Int63() + s.mu.Unlock() + return n +} + +func (s *source) Seed(seed int64) { + s.mu.Lock() + s.src.Seed(seed) + s.mu.Unlock() +} + +// Shuffle pseudo-randomizes the order of elements. +// n is the number of elements. +// swap swaps the elements with indexes i and j. +func Shuffle(n int, swap func(i, j int)) { pseudo.Shuffle(n, swap) } diff --git a/vendor/github.com/go-redis/redis/v8/internal/rand/ya.make b/vendor/github.com/go-redis/redis/v8/internal/rand/ya.make new file mode 100644 index 0000000000..eb2f7feb15 --- /dev/null +++ b/vendor/github.com/go-redis/redis/v8/internal/rand/ya.make @@ -0,0 +1,7 @@ +GO_LIBRARY() + +LICENSE(BSD-2-Clause) + +SRCS(rand.go) + +END() |