redistool

package
v14.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_internal_tool_redistool_redistool_proto protoreflect.FileDescriptor

Functions

func PrefixedInt64Key

func PrefixedInt64Key(prefix string, key int64) string

Types

type ExpiringHash

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

func NewExpiringHash

func NewExpiringHash(log *zap.Logger, client redis.UniversalClient, keyToRedisKey KeyToRedisKey, ttl time.Duration) *ExpiringHash

func (*ExpiringHash) GC

func (h *ExpiringHash) GC(ctx context.Context) (int, error)

func (*ExpiringHash) Refresh

func (h *ExpiringHash) Refresh(ctx context.Context) error

func (*ExpiringHash) Scan

func (h *ExpiringHash) Scan(ctx context.Context, key interface{}, cb ScanCallback) (keysDeleted int, retErr error)

func (*ExpiringHash) Set

func (h *ExpiringHash) Set(ctx context.Context, key interface{}, hashKey int64, value *anypb.Any) error

func (*ExpiringHash) Unset

func (h *ExpiringHash) Unset(ctx context.Context, key interface{}, hashKey int64) error

type ExpiringHashInterface

type ExpiringHashInterface interface {
	Set(ctx context.Context, key interface{}, hashKey int64, value *anypb.Any) error
	Unset(ctx context.Context, key interface{}, hashKey int64) error
	Scan(ctx context.Context, key interface{}, cb ScanCallback) (int, error)
	// GC iterates all relevant stored data and deletes expired entries.
	// It returns number of deleted Redis (hash) keys, including when an error occurs.
	// It only inspects/GCs hashes where it has entries. Other concurrent clients GC same and/or other corresponding hashes.
	// Hashes that don't have a corresponding client (e.g. because it crashed) will expire because of TTL on the hash key.
	GC(ctx context.Context) (int, error)
	Refresh(ctx context.Context) error
}

type ExpiringValue

type ExpiringValue struct {
	ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
	Value     *anypb.Any             `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*ExpiringValue) Descriptor deprecated

func (*ExpiringValue) Descriptor() ([]byte, []int)

Deprecated: Use ExpiringValue.ProtoReflect.Descriptor instead.

func (*ExpiringValue) GetExpiresAt

func (x *ExpiringValue) GetExpiresAt() *timestamppb.Timestamp

func (*ExpiringValue) GetValue

func (x *ExpiringValue) GetValue() *anypb.Any

func (*ExpiringValue) ProtoMessage

func (*ExpiringValue) ProtoMessage()

func (*ExpiringValue) ProtoReflect

func (x *ExpiringValue) ProtoReflect() protoreflect.Message

func (*ExpiringValue) Reset

func (x *ExpiringValue) Reset()

func (*ExpiringValue) String

func (x *ExpiringValue) String() string

type KeyToRedisKey

type KeyToRedisKey func(key interface{}) string

KeyToRedisKey is used to convert key1 in HSET key1 key2 value.

type RpcApi added in v14.3.1

type RpcApi interface {
	Log() *zap.Logger
	HandleProcessingError(msg string, err error)
	AgentToken() string
}

type ScanCallback

type ScanCallback func(value *anypb.Any, err error) (bool, error)

type TokenLimiter

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

TokenLimiter is a redis-based rate limiter implementing the algorithm in https://redislabs.com/redis-best-practices/basic-rate-limiting/

func NewTokenLimiter

func NewTokenLimiter(redisClient redis.UniversalClient, keyPrefix string,
	limitPerMinute uint64, getApi func(context.Context) RpcApi) *TokenLimiter

NewTokenLimiter returns a new TokenLimiter

func (*TokenLimiter) Allow

func (l *TokenLimiter) Allow(ctx context.Context) bool

Allow consumes one limitable event from the token in the context

Jump to

Keyboard shortcuts

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