@@ -5,85 +5,38 @@ import (
5
5
)
6
6
7
7
// NotificationHandlerContext provides context information about where a push notification was received.
8
- // This interface allows handlers to make informed decisions based on the source of the notification
8
+ // This struct allows handlers to make informed decisions based on the source of the notification
9
9
// with strongly typed access to different client types using concrete types.
10
- type NotificationHandlerContext interface {
11
- // GetClient returns the Redis client instance that received the notification.
12
- // Returns nil if no client context is available.
10
+ type NotificationHandlerContext struct {
11
+ // Client is the Redis client instance that received the notification.
13
12
// It is interface to both allow for future expansion and to avoid
14
13
// circular dependencies. The developer is responsible for type assertion.
15
14
// It can be one of the following types:
15
+ // - *redis.baseClient
16
16
// - *redis.Client
17
17
// - *redis.ClusterClient
18
18
// - *redis.Conn
19
- GetClient () interface {}
19
+ Client interface {}
20
20
21
- // GetConnPool returns the connection pool from which the connection was obtained.
22
- // Returns nil if no connection pool context is available.
21
+ // ConnPool is the connection pool from which the connection was obtained.
23
22
// It is interface to both allow for future expansion and to avoid
24
23
// circular dependencies. The developer is responsible for type assertion.
25
24
// It can be one of the following types:
26
25
// - *pool.ConnPool
27
26
// - *pool.SingleConnPool
28
27
// - *pool.StickyConnPool
29
- GetConnPool () interface {}
28
+ ConnPool interface {}
30
29
31
- // GetPubSub returns the PubSub instance that received the notification.
32
- // Returns nil if this is not a PubSub connection.
30
+ // PubSub is the PubSub instance that received the notification.
33
31
// It is interface to both allow for future expansion and to avoid
34
32
// circular dependencies. The developer is responsible for type assertion.
35
33
// It can be one of the following types:
36
34
// - *redis.PubSub
37
- GetPubSub () interface {}
35
+ PubSub interface {}
38
36
39
- // GetConn returns the specific connection on which the notification was received.
40
- // Returns nil if no connection context is available.
41
- GetConn () * pool.Conn
37
+ // Conn is the specific connection on which the notification was received.
38
+ Conn * pool.Conn
42
39
43
- // IsBlocking returns true if the notification was received on a blocking connection.
44
- IsBlocking () bool
45
- }
46
-
47
- // pushNotificationHandlerContext is the concrete implementation of PushNotificationHandlerContext interface
48
- type pushNotificationHandlerContext struct {
49
- client interface {}
50
- connPool interface {}
51
- pubSub interface {}
52
- conn * pool.Conn
53
- isBlocking bool
54
- }
55
-
56
- // NewNotificationHandlerContext creates a new push.NotificationHandlerContext instance
57
- func NewNotificationHandlerContext (client , connPool , pubSub interface {}, conn * pool.Conn , isBlocking bool ) NotificationHandlerContext {
58
- return & pushNotificationHandlerContext {
59
- client : client ,
60
- connPool : connPool ,
61
- pubSub : pubSub ,
62
- conn : conn ,
63
- isBlocking : isBlocking ,
64
- }
65
- }
66
-
67
- // GetClient returns the Redis client instance that received the notification
68
- func (h * pushNotificationHandlerContext ) GetClient () interface {} {
69
- return h .client
70
- }
71
-
72
- // GetConnPool returns the connection pool from which the connection was obtained
73
- func (h * pushNotificationHandlerContext ) GetConnPool () interface {} {
74
- return h .connPool
75
- }
76
-
77
- func (h * pushNotificationHandlerContext ) GetPubSub () interface {} {
78
- return h .pubSub
79
- }
80
-
81
- // GetConn returns the specific connection on which the notification was received
82
- func (h * pushNotificationHandlerContext ) GetConn () * pool.Conn {
83
- return h .conn
84
- }
85
-
86
- // IsBlocking returns true if the notification was received on a blocking connection
87
- func (h * pushNotificationHandlerContext ) IsBlocking () bool {
88
- return h .isBlocking
40
+ // IsBlocking indicates if the notification was received on a blocking connection.
41
+ IsBlocking bool
89
42
}
0 commit comments