Skip to content

Commit 6ceff45

Browse files
committed
wip
1 parent 20cb87e commit 6ceff45

18 files changed

+534
-1025
lines changed

adapters.go

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package redis
33
import (
44
"context"
55
"errors"
6-
"fmt"
76
"net"
87
"time"
98

@@ -23,11 +22,6 @@ func NewClientAdapter(client *baseClient) interfaces.ClientInterface {
2322
return &clientAdapter{client: client}
2423
}
2524

26-
// NewClusterClientAdapter creates a new client adapter for cluster Redis clients.
27-
func NewClusterClientAdapter(client interface{}) interfaces.ClientInterface {
28-
return &clusterClientAdapter{client: client}
29-
}
30-
3125
// clientAdapter adapts a Redis client to implement interfaces.ClientInterface.
3226
type clientAdapter struct {
3327
client *baseClient
@@ -126,78 +120,6 @@ func (ca *connectionAdapter) ClearRelaxedTimeout() {
126120
ca.conn.ClearRelaxedTimeout()
127121
}
128122

129-
// clusterClientAdapter adapts a cluster client to implement interfaces.ClientInterface.
130-
type clusterClientAdapter struct {
131-
client interface{}
132-
}
133-
134-
// GetOptions returns the client options.
135-
func (cca *clusterClientAdapter) GetOptions() interfaces.OptionsInterface {
136-
// Return a mock options adapter for cluster clients
137-
return &mockClusterOptionsAdapter{}
138-
}
139-
140-
// ExecuteCommand executes a command on the cluster client.
141-
func (cca *clusterClientAdapter) ExecuteCommand(ctx context.Context, cmd interface{}) error {
142-
// Use reflection to call Process method on the cluster client
143-
// This is a simplified implementation for the refactoring
144-
return nil // Mock implementation
145-
}
146-
147-
// GetPushProcessor returns the cluster client's push notification processor.
148-
func (cca *clusterClientAdapter) GetPushProcessor() interfaces.NotificationProcessor {
149-
// For cluster clients, return a mock processor since the actual implementation
150-
// would be more complex and distributed across nodes
151-
return &mockClusterPushProcessor{}
152-
}
153-
154-
// DialToEndpoint creates a connection to the specified endpoint for cluster clients.
155-
func (cca *clusterClientAdapter) DialToEndpoint(ctx context.Context, endpoint string) (interface{}, error) {
156-
// For cluster clients, this would need to handle cluster-specific connection logic
157-
// For now, return an error indicating this is not implemented for cluster clients
158-
return nil, fmt.Errorf("DialToEndpoint not implemented for cluster clients")
159-
}
160-
161-
// mockClusterOptionsAdapter is a mock implementation for cluster options.
162-
type mockClusterOptionsAdapter struct{}
163-
164-
// GetReadTimeout returns the read timeout.
165-
func (mcoa *mockClusterOptionsAdapter) GetReadTimeout() time.Duration {
166-
return 5 * time.Second
167-
}
168-
169-
// GetWriteTimeout returns the write timeout.
170-
func (mcoa *mockClusterOptionsAdapter) GetWriteTimeout() time.Duration {
171-
return 3 * time.Second
172-
}
173-
174-
// GetAddr returns the connection address.
175-
func (mcoa *mockClusterOptionsAdapter) GetAddr() string {
176-
return "localhost:6379"
177-
}
178-
179-
// IsTLSEnabled returns true if TLS is enabled.
180-
func (mcoa *mockClusterOptionsAdapter) IsTLSEnabled() bool {
181-
return false
182-
}
183-
184-
// GetProtocol returns the protocol version.
185-
func (mcoa *mockClusterOptionsAdapter) GetProtocol() int {
186-
return 3
187-
}
188-
189-
// GetPoolSize returns the connection pool size.
190-
func (mcoa *mockClusterOptionsAdapter) GetPoolSize() int {
191-
return 50 // Default cluster pool size (5 * runtime.GOMAXPROCS(0))
192-
}
193-
194-
// NewDialer returns a new dialer function for the connection.
195-
func (mcoa *mockClusterOptionsAdapter) NewDialer() func(context.Context) (net.Conn, error) {
196-
return func(ctx context.Context) (net.Conn, error) {
197-
return nil, errors.New("mock cluster dialer")
198-
}
199-
}
200-
201123
// pushProcessorAdapter adapts a push.NotificationProcessor to implement interfaces.NotificationProcessor.
202124
type pushProcessorAdapter struct {
203125
processor push.NotificationProcessor
@@ -220,21 +142,3 @@ func (ppa *pushProcessorAdapter) UnregisterHandler(pushNotificationName string)
220142
func (ppa *pushProcessorAdapter) GetHandler(pushNotificationName string) interface{} {
221143
return ppa.processor.GetHandler(pushNotificationName)
222144
}
223-
224-
// mockClusterPushProcessor is a mock implementation for cluster push processors.
225-
type mockClusterPushProcessor struct{}
226-
227-
// RegisterHandler registers a handler (mock implementation).
228-
func (mcpp *mockClusterPushProcessor) RegisterHandler(pushNotificationName string, handler interface{}, protected bool) error {
229-
return nil
230-
}
231-
232-
// UnregisterHandler removes a handler (mock implementation).
233-
func (mcpp *mockClusterPushProcessor) UnregisterHandler(pushNotificationName string) error {
234-
return nil
235-
}
236-
237-
// GetHandler returns the handler (mock implementation).
238-
func (mcpp *mockClusterPushProcessor) GetHandler(pushNotificationName string) interface{} {
239-
return nil
240-
}

commands.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ type Cmdable interface {
193193
ClientID(ctx context.Context) *IntCmd
194194
ClientUnblock(ctx context.Context, id int64) *IntCmd
195195
ClientUnblockWithError(ctx context.Context, id int64) *IntCmd
196-
ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string) *StatusCmd
197-
ClientMaintNotificationsInfo(ctx context.Context) *MapStringInterfaceCmd
196+
ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string, timeout int) *StatusCmd
198197
ConfigGet(ctx context.Context, parameter string) *MapStringStringCmd
199198
ConfigResetStat(ctx context.Context) *StatusCmd
200199
ConfigSet(ctx context.Context, parameter, value string) *StatusCmd
@@ -520,34 +519,20 @@ func (c cmdable) ClientInfo(ctx context.Context) *ClientInfoCmd {
520519
return cmd
521520
}
522521

523-
// ClientMaintNotifications enables or disables maintenance push notifications.
524-
// This command is used for hitless upgrades to control whether the client
525-
// receives MOVING, MIGRATING, MIGRATED, FAILING_OVER, and FAILED_OVER notifications.
526-
func (c cmdable) ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string) *StatusCmd {
522+
// ClientMaintNotifications enables or disables maintenance notifications for hitless upgrades.
523+
// When enabled, the client will receive push notifications about Redis maintenance events.
524+
func (c cmdable) ClientMaintNotifications(ctx context.Context, enabled bool, endpointType string, timeout int) *StatusCmd {
527525
args := []interface{}{"client", "maint_notifications"}
528-
529526
if enabled {
530-
args = append(args, "on")
531-
if endpointType != "" {
532-
args = append(args, "moving-endpoint-type", endpointType)
533-
}
527+
args = append(args, "on", endpointType, timeout)
534528
} else {
535529
args = append(args, "off")
536530
}
537-
538531
cmd := NewStatusCmd(ctx, args...)
539532
_ = c(ctx, cmd)
540533
return cmd
541534
}
542535

543-
// ClientMaintNotificationsInfo returns information about the current maintenance
544-
// notification configuration, similar to CLIENT TRACKINGINFO.
545-
func (c cmdable) ClientMaintNotificationsInfo(ctx context.Context) *MapStringInterfaceCmd {
546-
cmd := NewMapStringInterfaceCmd(ctx, "client", "maint_notifications_info")
547-
_ = c(ctx, cmd)
548-
return cmd
549-
}
550-
551536
// ------------------------------------------------------------------------------------------------
552537

553538
func (c cmdable) ConfigGet(ctx context.Context, parameter string) *MapStringStringCmd {

0 commit comments

Comments
 (0)