Skip to content

Commit 7c045e4

Browse files
committed
e2e wip
1 parent 0dcfeef commit 7c045e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+8441
-519
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ coverage.txt
1010
.vscode
1111
tmp/*
1212

13-
# Hitless upgrade documentation (temporary)
14-
hitless/docs/
13+
# maintenanceNotifications upgrade documentation (temporary)
14+
maintenanceNotifications/docs/

async_handoff_integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/redis/go-redis/v9/hitless"
10+
"github.com/redis/go-redis/v9/maintnotifications"
1111
"github.com/redis/go-redis/v9/internal/pool"
1212
"github.com/redis/go-redis/v9/logging"
1313
)
@@ -42,7 +42,7 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
4242
}
4343

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

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

144-
processor := hitless.NewPoolHook(baseDialer, "tcp", nil, nil)
144+
processor := maintnotifications.NewPoolHook(baseDialer, "tcp", nil, nil)
145145
defer processor.Shutdown(context.Background())
146146

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

216-
processor := hitless.NewPoolHook(failingDialer, "tcp", nil, nil)
216+
processor := maintnotifications.NewPoolHook(failingDialer, "tcp", nil, nil)
217217
defer processor.Shutdown(context.Background())
218218

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

279-
processor := hitless.NewPoolHook(slowDialer, "tcp", nil, nil)
279+
processor := maintnotifications.NewPoolHook(slowDialer, "tcp", nil, nil)
280280
defer processor.Shutdown(context.Background())
281281

282282
// Create hooks manager and add processor as hook

commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func (c cmdable) ClientInfo(ctx context.Context) *ClientInfoCmd {
520520
return cmd
521521
}
522522

523-
// ClientMaintNotifications enables or disables maintenance notifications for hitless upgrades.
523+
// ClientMaintNotifications enables or disables maintenance notifications for maintenance upgrades.
524524
// When enabled, the client will receive push notifications about Redis maintenance events.
525525
func (c cmdable) ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string) *StatusCmd {
526526
args := []interface{}{"client", "maint_notifications"}

e2e.test

10 MB
Binary file not shown.

example/pubsub/main.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"time"
1010

1111
"github.com/redis/go-redis/v9"
12-
"github.com/redis/go-redis/v9/hitless"
1312
"github.com/redis/go-redis/v9/logging"
13+
"github.com/redis/go-redis/v9/maintnotifications"
1414
)
1515

1616
var ctx = context.Background()
@@ -26,16 +26,20 @@ func main() {
2626
wg := &sync.WaitGroup{}
2727
rdb := redis.NewClient(&redis.Options{
2828
Addr: ":6379",
29-
HitlessUpgradeConfig: &redis.HitlessUpgradeConfig{
30-
Mode: hitless.MaintNotificationsEnabled,
29+
MaintNotificationsConfig: &maintnotifications.Config{
30+
Mode: maintnotifications.ModeEnabled,
31+
EndpointType: maintnotifications.EndpointTypeExternalIP,
32+
HandoffTimeout: 10 * time.Second,
33+
RelaxedTimeout: 10 * time.Second,
34+
PostHandoffRelaxedDuration: 10 * time.Second,
3135
},
3236
})
3337
_ = rdb.FlushDB(ctx).Err()
34-
hitlessManager := rdb.GetHitlessManager()
38+
hitlessManager := rdb.GetMaintNotificationsManager()
3539
if hitlessManager == nil {
3640
panic("hitless manager is nil")
3741
}
38-
loggingHook := hitless.NewLoggingHook(logging.LogLevelDebug)
42+
loggingHook := maintnotifications.NewLoggingHook(int(logging.LogLevelDebug))
3943
hitlessManager.AddNotificationHook(loggingHook)
4044

4145
go func() {

hitless/errors.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

internal/log.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,49 @@ func NewDefaultLogger() Logging {
3131
// Logger calls Output to print to the stderr.
3232
// Arguments are handled in the manner of fmt.Print.
3333
var Logger Logging = NewDefaultLogger()
34+
35+
var LogLevel LogLevelT = LogLevelError
36+
37+
// LogLevelT represents the logging level
38+
type LogLevelT int
39+
40+
// Log level constants for the entire go-redis library
41+
const (
42+
LogLevelError LogLevelT = iota // 0 - errors only
43+
LogLevelWarn // 1 - warnings and errors
44+
LogLevelInfo // 2 - info, warnings, and errors
45+
LogLevelDebug // 3 - debug, info, warnings, and errors
46+
)
47+
48+
// String returns the string representation of the log level
49+
func (l LogLevelT) String() string {
50+
switch l {
51+
case LogLevelError:
52+
return "ERROR"
53+
case LogLevelWarn:
54+
return "WARN"
55+
case LogLevelInfo:
56+
return "INFO"
57+
case LogLevelDebug:
58+
return "DEBUG"
59+
default:
60+
return "UNKNOWN"
61+
}
62+
}
63+
64+
// IsValid returns true if the log level is valid
65+
func (l LogLevelT) IsValid() bool {
66+
return l >= LogLevelError && l <= LogLevelDebug
67+
}
68+
69+
func (l LogLevelT) WarnOrAbove() bool {
70+
return l >= LogLevelWarn
71+
}
72+
73+
func (l LogLevelT) InfoOrAbove() bool {
74+
return l >= LogLevelInfo
75+
}
76+
77+
func (l LogLevelT) DebugOrAbove() bool {
78+
return l >= LogLevelDebug
79+
}

0 commit comments

Comments
 (0)