Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ coverage.txt
.vscode
tmp/*

# 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
Binary file added e2e.test
Binary file not shown.
14 changes: 9 additions & 5 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 @@ -26,16 +26,20 @@ func main() {
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()
hitlessManager := rdb.GetMaintNotificationsManager()
if hitlessManager == nil {
panic("hitless manager is nil")
}
loggingHook := hitless.NewLoggingHook(logging.LogLevelDebug)
loggingHook := maintnotifications.NewLoggingHook(int(logging.LogLevelDebug))
hitlessManager.AddNotificationHook(loggingHook)

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

This file was deleted.

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