util

package
v0.0.0-...-698c3d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDelta = 0.000001

Variables

View Source
var SlotTable = [...]string{}/* 16384 elements not displayed */

SlotTable is a table of the shortest possible alphanumeric string that is mapped by redis's crc16 to any given redis cluster slot.

The array indexes are slot numbers, so that given a desired slot, this string is guaranteed to make redis cluster route a request to the shard holding this slot

Functions

func BetweenValues

func BetweenValues[T constraints.Ordered](t testing.TB, d, start, end T, msgAndArgs ...interface{})

BetweenValues asserts start <= d <= end

func BetweenValuesEx

func BetweenValuesEx[T constraints.Ordered](t testing.TB, d, start, end T, msgAndArgs ...interface{})

BetweenValuesEx asserts start < d < end

func CLIPath

func CLIPath() string

func DefaultTLSConfig

func DefaultTLSConfig() (*tls.Config, error)

func ErrorRegexp

func ErrorRegexp(t testing.TB, err error, rx interface{}, msgAndArgs ...interface{})

func FindInfoEntry

func FindInfoEntry(rdb *redis.Client, key string, section ...string) string

func Populate

func Populate(t testing.TB, rdb *redis.Client, prefix string, n, size int)

func RandPath

func RandPath[T any](f ...func() T) T

func RandPathNoResult

func RandPathNoResult(f ...func())

func RandString

func RandString(min, max int, typ RandStringType) string

func RandStringWithSeed

func RandStringWithSeed(min, max int, typ RandStringType, seed int64) string

func RandomBool

func RandomBool() bool

func RandomInt

func RandomInt(max int64) int64

RandomInt return an integer in [0, max)

func RandomIntWithSeed

func RandomIntWithSeed(max, seed int64) int64

func RandomSignedInt

func RandomSignedInt(max int32) int64

RandomSignedInt returns an integer in (-max, max)

func RandomValue

func RandomValue() string

func RandomValueWithSeed

func RandomValueWithSeed(seed int64) string

func RetryEventually

func RetryEventually(t testing.TB, condition func() bool, maxAttempts int, msgAndArgs ...interface{})

func ReverseSlice

func ReverseSlice[T any](s []T)

func SlaveOf

func SlaveOf(t testing.TB, slave *redis.Client, master *KvrocksServer)

func TLSEnable

func TLSEnable() bool

func WaitForOffsetSync

func WaitForOffsetSync(t testing.TB, master, slave *redis.Client, waitFor time.Duration)

func WaitForSync

func WaitForSync(t testing.TB, slave *redis.Client)

Types

type ConfigOptions

type ConfigOptions struct {
	Name       string
	Options    []string
	ConfigType FieldType
}

type FieldType

type FieldType int
const (
	YesNo FieldType = iota
)

type KvrocksServer

type KvrocksServer struct {
	// contains filtered or unexported fields
}

func StartServer

func StartServer(t testing.TB, configs map[string]string) *KvrocksServer

func StartServerWithCLIOptions

func StartServerWithCLIOptions(
	t testing.TB,
	withConfigFile bool,
	configs map[string]string,
	options []string,
) *KvrocksServer

func StartTLSServer

func StartTLSServer(t testing.TB, configs map[string]string) *KvrocksServer

func (*KvrocksServer) Close

func (s *KvrocksServer) Close()

func (*KvrocksServer) CloseWithoutCleanup

func (s *KvrocksServer) CloseWithoutCleanup()

func (*KvrocksServer) Host

func (s *KvrocksServer) Host() string

func (*KvrocksServer) HostPort

func (s *KvrocksServer) HostPort() string

func (*KvrocksServer) LogFileMatches

func (s *KvrocksServer) LogFileMatches(t testing.TB, pattern string) bool

func (*KvrocksServer) NewClient

func (s *KvrocksServer) NewClient() *redis.Client

func (*KvrocksServer) NewClientWithOption

func (s *KvrocksServer) NewClientWithOption(options *redis.Options) *redis.Client

func (*KvrocksServer) NewTCPClient

func (s *KvrocksServer) NewTCPClient() *TCPClient

func (*KvrocksServer) NewTCPTLSClient

func (s *KvrocksServer) NewTCPTLSClient(conf *tls.Config) *TCPClient

func (*KvrocksServer) Port

func (s *KvrocksServer) Port() uint64

func (*KvrocksServer) Restart

func (s *KvrocksServer) Restart()

func (*KvrocksServer) Start

func (s *KvrocksServer) Start()

func (*KvrocksServer) TLSAddr

func (s *KvrocksServer) TLSAddr() string

func (*KvrocksServer) TLSPort

func (s *KvrocksServer) TLSPort() uint64

type KvrocksServerConfigs

type KvrocksServerConfigs map[string]string

func GenerateConfigsMatrix

func GenerateConfigsMatrix(configOptions []ConfigOptions) ([]KvrocksServerConfigs, error)

/ GenerateConfigsMatrix generates all possible combinations of config options

type RandStringType

type RandStringType int
const (
	Alpha RandStringType = iota
	Binary
)

type TCPClient

type TCPClient struct {
	// contains filtered or unexported fields
}

func (*TCPClient) Close

func (c *TCPClient) Close() error

func (*TCPClient) MustFail

func (c *TCPClient) MustFail(t testing.TB)

func (*TCPClient) MustMatch

func (c *TCPClient) MustMatch(t testing.TB, rx string)

func (*TCPClient) MustRead

func (c *TCPClient) MustRead(t testing.TB, s string)

func (*TCPClient) MustReadStrings

func (c *TCPClient) MustReadStrings(t testing.TB, s []string)

func (*TCPClient) MustReadStringsWithKey

func (c *TCPClient) MustReadStringsWithKey(t testing.TB, key string, s []string)

func (*TCPClient) ReadLine

func (c *TCPClient) ReadLine() (string, error)

func (*TCPClient) TLSState

func (c *TCPClient) TLSState() *tls.ConnectionState

func (*TCPClient) Write

func (c *TCPClient) Write(s string) error

func (*TCPClient) WriteArgs

func (c *TCPClient) WriteArgs(args ...string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL