util

package
v0.0.0-...-27a6d8a Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 27 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 LuaJITEnable

func LuaJITEnable() bool

func PausableTCPProxy

func PausableTCPProxy(ctx context.Context, t testing.TB, to string, pauseCh <-chan bool) uint64

PausableTCPProxy creates a TCP proxy that can be paused/resumed via a channel. Send true to pause, false to resume. Returns the proxy port. When paused, the proxy stops reading from the source, causing the sender's TCP buffer to fill up and eventually blocking writes.

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(minInt, maxInt int, typ RandStringType) string

func RandStringWithSeed

func RandStringWithSeed(minInt, maxInt int, typ RandStringType, seed int64) string

func RandomBool

func RandomBool() bool

func RandomInt

func RandomInt(maxInt int64) int64

RandomInt return an integer in [0, maxInt)

func RandomIntWithSeed

func RandomIntWithSeed(maxInt, seed int64) int64

func RandomSignedInt

func RandomSignedInt(maxInt int32) int64

RandomSignedInt returns an integer in (-maxInt, maxInt)

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 SimpleTCPProxy

func SimpleTCPProxy(ctx context.Context, t testing.TB, to string, slowdown bool) uint64

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
}

type KMetadataResponse

type KMetadataResponse struct {
	Expire  int64
	Size    int64
	Type    string
	Flags   int64
	Version int64
	Mode    string
	Format  string
	Persist int64
	Lower   int64
	Upper   int64
	Head    int64
	Tail    int64
}

func ExtractKMetadataResponse

func ExtractKMetadataResponse(result interface{}) (*KMetadataResponse, error)

func GetKMetadata

func GetKMetadata(t testing.TB, rdb *redis.Client, ctx context.Context, key string) KMetadataResponse

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) MustReadBulkString

func (c *TCPClient) MustReadBulkString(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