Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ coverage.txt
**/coverage.txt
.vscode
tmp/*
*.test

# Hitless upgrade documentation (temporary)
hitless/docs/
# maintenanceNotifications upgrade documentation (temporary)
maintenanceNotifications/docs/
10 changes: 5 additions & 5 deletions async_handoff_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/redis/go-redis/v9/hitless"
"github.com/redis/go-redis/v9/maintnotifications"
"github.com/redis/go-redis/v9/internal/pool"
"github.com/redis/go-redis/v9/logging"
)
Expand Down Expand Up @@ -42,7 +42,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
}

// Create processor with event-driven handoff support
processor := hitless.NewPoolHook(baseDialer, "tcp", nil, nil)
processor := maintnotifications.NewPoolHook(baseDialer, "tcp", nil, nil)
defer processor.Shutdown(context.Background())

// Create a test pool with hooks
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
return &mockNetConn{addr: addr}, nil
}

processor := hitless.NewPoolHook(baseDialer, "tcp", nil, nil)
processor := maintnotifications.NewPoolHook(baseDialer, "tcp", nil, nil)
defer processor.Shutdown(context.Background())

// Create hooks manager and add processor as hook
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
return nil, &net.OpError{Op: "dial", Err: &net.DNSError{Name: addr}}
}

processor := hitless.NewPoolHook(failingDialer, "tcp", nil, nil)
processor := maintnotifications.NewPoolHook(failingDialer, "tcp", nil, nil)
defer processor.Shutdown(context.Background())

// Create hooks manager and add processor as hook
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
return &mockNetConn{addr: addr}, nil
}

processor := hitless.NewPoolHook(slowDialer, "tcp", nil, nil)
processor := maintnotifications.NewPoolHook(slowDialer, "tcp", nil, nil)
defer processor.Shutdown(context.Background())

// Create hooks manager and add processor as hook
Expand Down
2 changes: 1 addition & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (c cmdable) ClientInfo(ctx context.Context) *ClientInfoCmd {
return cmd
}

// ClientMaintNotifications enables or disables maintenance notifications for hitless upgrades.
// ClientMaintNotifications enables or disables maintenance notifications for maintenance upgrades.
// When enabled, the client will receive push notifications about Redis maintenance events.
func (c cmdable) ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string) *StatusCmd {
args := []interface{}{"client", "maint_notifications"}
Expand Down
22 changes: 13 additions & 9 deletions example/pubsub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"time"

"github.com/redis/go-redis/v9"
"github.com/redis/go-redis/v9/hitless"
"github.com/redis/go-redis/v9/logging"
"github.com/redis/go-redis/v9/maintnotifications"
)

var ctx = context.Background()
Expand All @@ -19,24 +19,28 @@ var cntSuccess atomic.Int64
var startTime = time.Now()

// This example is not supposed to be run as is. It is just a test to see how pubsub behaves in relation to pool management.
// It was used to find regressions in pool management in hitless mode.
// It was used to find regressions in pool management in maintnotifications mode.
// Please don't use it as a reference for how to use pubsub.
func main() {
startTime = time.Now()
wg := &sync.WaitGroup{}
rdb := redis.NewClient(&redis.Options{
Addr: ":6379",
HitlessUpgradeConfig: &redis.HitlessUpgradeConfig{
Mode: hitless.MaintNotificationsEnabled,
MaintNotificationsConfig: &maintnotifications.Config{
Mode: maintnotifications.ModeEnabled,
EndpointType: maintnotifications.EndpointTypeExternalIP,
HandoffTimeout: 10 * time.Second,
RelaxedTimeout: 10 * time.Second,
PostHandoffRelaxedDuration: 10 * time.Second,
},
})
_ = rdb.FlushDB(ctx).Err()
hitlessManager := rdb.GetHitlessManager()
if hitlessManager == nil {
panic("hitless manager is nil")
maintnotificationsManager := rdb.GetMaintNotificationsManager()
if maintnotificationsManager == nil {
panic("maintnotifications manager is nil")
}
loggingHook := hitless.NewLoggingHook(logging.LogLevelDebug)
hitlessManager.AddNotificationHook(loggingHook)
loggingHook := maintnotifications.NewLoggingHook(int(logging.LogLevelDebug))
maintnotificationsManager.AddNotificationHook(loggingHook)

go func() {
for {
Expand Down
105 changes: 0 additions & 105 deletions hitless/errors.go

This file was deleted.

4 changes: 2 additions & 2 deletions internal/interfaces/interfaces.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package interfaces provides shared interfaces used by both the main redis package
// and the hitless upgrade package to avoid circular dependencies.
// and the maintnotifications upgrade package to avoid circular dependencies.
package interfaces

import (
Expand All @@ -16,7 +16,7 @@ type NotificationProcessor interface {
GetHandler(pushNotificationName string) interface{}
}

// ClientInterface defines the interface that clients must implement for hitless upgrades.
// ClientInterface defines the interface that clients must implement for maintnotifications upgrades.
type ClientInterface interface {
// GetOptions returns the client options.
GetOptions() OptionsInterface
Expand Down
46 changes: 46 additions & 0 deletions internal/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,49 @@ func NewDefaultLogger() Logging {
// Logger calls Output to print to the stderr.
// Arguments are handled in the manner of fmt.Print.
var Logger Logging = NewDefaultLogger()

var LogLevel LogLevelT = LogLevelError

// LogLevelT represents the logging level
type LogLevelT int

// Log level constants for the entire go-redis library
const (
LogLevelError LogLevelT = iota // 0 - errors only
LogLevelWarn // 1 - warnings and errors
LogLevelInfo // 2 - info, warnings, and errors
LogLevelDebug // 3 - debug, info, warnings, and errors
)

// String returns the string representation of the log level
func (l LogLevelT) String() string {
switch l {
case LogLevelError:
return "ERROR"
case LogLevelWarn:
return "WARN"
case LogLevelInfo:
return "INFO"
case LogLevelDebug:
return "DEBUG"
default:
return "UNKNOWN"
}
}

// IsValid returns true if the log level is valid
func (l LogLevelT) IsValid() bool {
return l >= LogLevelError && l <= LogLevelDebug
}

func (l LogLevelT) WarnOrAbove() bool {
return l >= LogLevelWarn
}

func (l LogLevelT) InfoOrAbove() bool {
return l >= LogLevelInfo
}

func (l LogLevelT) DebugOrAbove() bool {
return l >= LogLevelDebug
}
Loading
Loading