Documentation
¶
Overview ¶
pkg/management/bulk.go
pkg/management/key.go
pkg/management/redis.go
pkg/management/redis.go
pkg/management/redis.go
pkg/management/redis.go
Index ¶
- Constants
- Variables
- type BulkOperation
- type BulkProcessor
- type CircuitBreaker
- type DBRange
- type KeyManager
- type RedisService
- func (rs *RedisService) AddBulkOperation(ctx context.Context, command string, key string, value interface{}, ...) error
- func (rs *RedisService) Close() error
- func (rs *RedisService) Delete(ctx context.Context, key string) error
- func (rs *RedisService) DeleteBatch(ctx context.Context, keys []string) error
- func (rs *RedisService) Get(ctx context.Context, key string) (string, error)
- func (rs *RedisService) GetBatch(ctx context.Context, keys []string) (map[string]string, error)
- func (rs *RedisService) GetBatchTTL(ctx context.Context, keys []string) (map[string]time.Duration, error)
- func (rs *RedisService) GetPoolStats() *redis.PoolStats
- func (rs *RedisService) GetTTL(ctx context.Context, key string) (time.Duration, error)
- func (rs *RedisService) Ping(ctx context.Context) error
- func (rs *RedisService) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- func (rs *RedisService) SetBatch(ctx context.Context, items map[string]interface{}, expiration time.Duration) error
- func (rs *RedisService) SetBatchTTL(ctx context.Context, keys []string, ttl time.Duration) error
- func (rs *RedisService) SetBatchWithDefaultTTL(ctx context.Context, items map[string]interface{}) error
- func (rs *RedisService) SetTTL(ctx context.Context, key string, ttl time.Duration) error
- func (rs *RedisService) SetWithDefaultTTL(ctx context.Context, key string, value interface{}) error
Constants ¶
const ( StateClosed = iota // Normal operation StateOpen // Not allowing operations StateHalfOpen // Testing if service is healthy )
Circuit breaker states
Variables ¶
var ( ErrCircuitOpen = errors.New("circuit breaker is open") ErrTooManyRequests = errors.New("too many requests in half-open state") )
Functions ¶
This section is empty.
Types ¶
type BulkOperation ¶
type BulkOperation struct { Command string Key string Value interface{} ExpiresAt time.Duration Result chan error }
BulkOperation represents a single operation in the bulk queue
type BulkProcessor ¶
type BulkProcessor struct {
// contains filtered or unexported fields
}
BulkProcessor handles bulk operations
func NewBulkProcessor ¶
func NewBulkProcessor(service *RedisService) *BulkProcessor
NewBulkProcessor creates a new bulk processor
func (*BulkProcessor) Start ¶
func (bp *BulkProcessor) Start(ctx context.Context)
Start begins processing bulk operations
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
func NewCircuitBreaker ¶
func NewCircuitBreaker(threshold int64, resetAfter time.Duration, maxHalfOpen int32) *CircuitBreaker
NewCircuitBreaker creates a new circuit breaker
func (*CircuitBreaker) AllowRequest ¶
func (cb *CircuitBreaker) AllowRequest() bool
AllowRequest checks if a request should be allowed
func (*CircuitBreaker) Execute ¶
func (cb *CircuitBreaker) Execute(fn func() error) error
Execute runs the given function with circuit breaker protection
func (*CircuitBreaker) GetState ¶
func (cb *CircuitBreaker) GetState() string
GetState returns the current state of the circuit breaker
func (*CircuitBreaker) RecordResult ¶
func (cb *CircuitBreaker) RecordResult(err error)
RecordResult records the result of a request
type KeyManager ¶
type KeyManager struct {
// contains filtered or unexported fields
}
func NewKeyManager ¶
func NewKeyManager(cfg *config.Config) (*KeyManager, error)
func (*KeyManager) GetKey ¶
func (km *KeyManager) GetKey(key string) string
func (*KeyManager) GetShardIndex ¶
func (km *KeyManager) GetShardIndex(key string) (int, error)
type RedisService ¶
type RedisService struct {
// contains filtered or unexported fields
}
func NewRedisService ¶
func NewRedisService(cfg *config.Config) (*RedisService, error)
func (*RedisService) AddBulkOperation ¶
func (rs *RedisService) AddBulkOperation(ctx context.Context, command string, key string, value interface{}, expires time.Duration) error
Add bulk operation methods
func (*RedisService) Close ¶
func (rs *RedisService) Close() error
func (*RedisService) Delete ¶
func (rs *RedisService) Delete(ctx context.Context, key string) error
Delete method with circuit breaker support
func (*RedisService) DeleteBatch ¶
func (rs *RedisService) DeleteBatch(ctx context.Context, keys []string) error
DeleteBatch removes multiple keys in a single operation
func (*RedisService) GetBatchTTL ¶ added in v1.2.0
func (*RedisService) GetPoolStats ¶
func (rs *RedisService) GetPoolStats() *redis.PoolStats
GetPoolStats returns current pool statistics with additional safety checks
func (*RedisService) Ping ¶
func (rs *RedisService) Ping(ctx context.Context) error
Ping checks if Redis is responding
func (*RedisService) Set ¶
func (rs *RedisService) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
Modify Set method to use circuit breaker if enabled
func (*RedisService) SetBatch ¶
func (rs *RedisService) SetBatch(ctx context.Context, items map[string]interface{}, expiration time.Duration) error
SetBatch stores multiple key-value pairs in a single operation
func (*RedisService) SetBatchTTL ¶ added in v1.2.0
func (*RedisService) SetBatchWithDefaultTTL ¶ added in v1.1.0
func (rs *RedisService) SetBatchWithDefaultTTL(ctx context.Context, items map[string]interface{}) error
SetBatchWithDefaultTTL stores multiple values with configured default TTL
func (*RedisService) SetWithDefaultTTL ¶ added in v1.1.0
func (rs *RedisService) SetWithDefaultTTL(ctx context.Context, key string, value interface{}) error
SetWithDefaultTTL stores a value with configured default TTL