internal

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(n int) int

func AdaptType

func AdaptType(s string) interface{}

func CompareLex

func CompareLex(s1 string, s2 string) int

CompareLex returns -1 when s2 is lexicographically greater than s1, 0 if they're equal and 1 if s2 is lexicographically less than s1.

func CompareNestedStringArrays

func CompareNestedStringArrays(got [][]string, want [][]string) bool

func Decode

func Decode(raw []byte) ([]string, error)

func EncodeCommand

func EncodeCommand(cmd []string) []byte

func FilterExpiredKeys

func FilterExpiredKeys(now time.Time, state map[string]KeyData) map[string]KeyData

FilterExpiredKeys filters out keys that are already expired, so they are not persisted.

func GetFreePort added in v0.5.0

func GetFreePort() (int, error)

func GetIPAddress

func GetIPAddress() (string, error)

func GetSubCommand

func GetSubCommand(command Command, cmd []string) (interface{}, error)

func IsMaxMemoryExceeded

func IsMaxMemoryExceeded(maxMemory uint64) bool

IsMaxMemoryExceeded checks whether we have exceeded the current maximum memory limit.

func IsWriteCommand

func IsWriteCommand(command Command, subCommand SubCommand) bool

func ParseBooleanArrayResponse

func ParseBooleanArrayResponse(b []byte) ([]bool, error)

func ParseBooleanResponse

func ParseBooleanResponse(b []byte) (bool, error)

func ParseFloatResponse

func ParseFloatResponse(b []byte) (float64, error)

func ParseIntegerArrayResponse

func ParseIntegerArrayResponse(b []byte) ([]int, error)

func ParseIntegerResponse

func ParseIntegerResponse(b []byte) (int, error)

func ParseMemory

func ParseMemory(memory string) (uint64, error)

ParseMemory returns an integer representing the bytes in the memory string

func ParseNestedStringArrayResponse

func ParseNestedStringArrayResponse(b []byte) ([][]string, error)

func ParseNilResponse

func ParseNilResponse(b []byte) (bool, error)

func ParseStringArrayResponse

func ParseStringArrayResponse(b []byte) ([]string, error)

func ParseStringResponse

func ParseStringResponse(b []byte) (string, error)

func ReadMessage

func ReadMessage(r io.Reader) ([]byte, error)

func RetryBackoff

func RetryBackoff(b retry.Backoff, maxRetries uint64, jitter, cappedDuration, maxDuration time.Duration) retry.Backoff

Types

type ApplyRequest

type ApplyRequest struct {
	Type         string   `json:"Type"` // command | delete-key
	ServerID     string   `json:"ServerID"`
	ConnectionID string   `json:"ConnectionID"`
	CMD          []string `json:"CMD"`
	Key          string   `json:"Key"`
}

type ApplyResponse

type ApplyResponse struct {
	Error    error
	Response []byte
}

type Command added in v0.5.0

type Command struct {
	Command     string
	Module      string
	Categories  []string
	Description string
	SubCommands []SubCommand
	Sync        bool // Specifies if command should be synced across replication cluster
	KeyExtractionFunc
	HandlerFunc
}

type ContextConnID

type ContextConnID string

type ContextServerID

type ContextServerID string

type HandlerFunc added in v0.5.0

type HandlerFunc func(params HandlerFuncParams) ([]byte, error)

type HandlerFuncParams added in v0.5.0

type HandlerFuncParams struct {
	Context               context.Context
	Command               []string
	Connection            *net.Conn
	KeyLock               func(ctx context.Context, key string) (bool, error)
	KeyUnlock             func(ctx context.Context, key string)
	KeyRLock              func(ctx context.Context, key string) (bool, error)
	KeyRUnlock            func(ctx context.Context, key string)
	KeyExists             func(ctx context.Context, key string) bool
	CreateKeyAndLock      func(ctx context.Context, key string) (bool, error)
	GetValue              func(ctx context.Context, key string) interface{}
	SetValue              func(ctx context.Context, key string, value interface{}) error
	GetExpiry             func(ctx context.Context, key string) time.Time
	SetExpiry             func(ctx context.Context, key string, expire time.Time, touch bool)
	RemoveExpiry          func(ctx context.Context, key string)
	DeleteKey             func(ctx context.Context, key string) error
	GetClock              func() clock.Clock
	GetAllCommands        func() []Command
	GetACL                func() interface{}
	GetPubSub             func() interface{}
	TakeSnapshot          func() error
	RewriteAOF            func() error
	GetLatestSnapshotTime func() int64
	LoadModule            func(path string, args ...string) error
	UnloadModule          func(module string)
	ListModules           func() []string
}

type KeyData

type KeyData struct {
	Value    interface{}
	ExpireAt time.Time
}

type KeyExtractionFunc added in v0.5.0

type KeyExtractionFunc func(cmd []string) (KeyExtractionFuncResult, error)

type KeyExtractionFuncResult added in v0.5.0

type KeyExtractionFuncResult struct {
	Channels  []string
	ReadKeys  []string
	WriteKeys []string
}

type SnapshotObject

type SnapshotObject struct {
	State                      map[string]KeyData
	LatestSnapshotMilliseconds int64
}

type SubCommand added in v0.5.0

type SubCommand struct {
	Command     string
	Module      string
	Categories  []string
	Description string
	Sync        bool // Specifies if sub-command should be synced across replication cluster
	KeyExtractionFunc
	HandlerFunc
}

Jump to

Keyboard shortcuts

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