1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-20 22:42:59 +03:00
Commit Graph

129 Commits

Author SHA1 Message Date
9a7a5c853b fix: add nil reader check in ProcessPendingNotifications to prevent panic
- Add nil check for proto.Reader parameter in both PushNotificationProcessor and VoidPushNotificationProcessor
- Prevent segmentation violation when ProcessPendingNotifications is called with nil reader
- Return early with nil error when reader is nil (graceful handling)
- Fix panic in TestProcessPendingNotificationsEdgeCases test

This addresses the runtime panic that occurred when rd.Buffered() was called on a nil reader,
ensuring robust error handling in edge cases where the reader might not be properly initialized.
2025-06-27 15:05:16 +03:00
be9b6dd6a0 refactor: remove unnecessary enabled field and IsEnabled/SetEnabled methods
- Remove enabled field from PushNotificationProcessor struct
- Remove IsEnabled() and SetEnabled() methods from processor interface
- Remove enabled parameter from NewPushNotificationProcessor()
- Update all interfaces in pool package to remove IsEnabled requirement
- Simplify processor logic - if processor exists, it works
- VoidPushNotificationProcessor handles disabled case by discarding notifications
- Update all tests to use simplified interface without enable/disable logic

Benefits:
- Simpler, cleaner interface with less complexity
- No unnecessary state management for enabled/disabled
- VoidPushNotificationProcessor pattern handles disabled case elegantly
- Reduced cognitive overhead - processors just work when set
- Eliminates redundant enabled checks throughout codebase
- More predictable behavior - set processor = it works
2025-06-27 01:36:38 +03:00
fdfcf94300 feat: add VoidPushNotificationProcessor for disabled push notifications
- Add VoidPushNotificationProcessor that reads and discards push notifications
- Create PushNotificationProcessorInterface for consistent behavior
- Always provide a processor (real or void) instead of nil
- VoidPushNotificationProcessor properly cleans RESP3 push notifications from buffer
- Remove all nil checks throughout codebase for cleaner, safer code
- Update tests to expect VoidPushNotificationProcessor when disabled

Benefits:
- Eliminates nil pointer risks throughout the codebase
- Follows null object pattern for safer operation
- Properly handles RESP3 push notifications even when disabled
- Consistent interface regardless of push notification settings
- Cleaner code without defensive nil checks everywhere
2025-06-27 01:36:35 +03:00
b02eed63b2 feat: add general push notification system
- Add PushNotificationRegistry for managing notification handlers
- Add PushNotificationProcessor for processing RESP3 push notifications
- Add client methods for registering push notification handlers
- Add PubSub integration for handling generic push notifications
- Add comprehensive test suite with 100% coverage
- Add push notification demo example

This system allows handling any arbitrary RESP3 push notification
with registered handlers, not just specific notification types.
2025-06-27 01:36:08 +03:00
bb8d508481 fix: PubSub isn't concurrency-safe (#3360) 2025-04-29 09:39:26 +03:00
0cfcd1a61d update pubsub.go (#3329) 2025-04-03 16:10:31 +03:00
26e0c49acf Update pubsub.go (#3042)
Change context.Background() to ctx
2024-07-05 10:27:44 +08:00
6960bcc08d chore: fix some comments (#2967)
Signed-off-by: kindknow <iturf@sina.com>
Co-authored-by: Monkey <golang@88.com>
2024-04-14 01:15:23 +08:00
e053f7eaf3 update PubSub.Channel documentation (#2761)
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-10-30 14:35:02 +02:00
97b491aace chore: update import path 2023-01-23 08:48:54 +02:00
331e40dc6c fix: reset pubsub state when unsubscribing from all channels 2022-10-14 15:15:06 +03:00
58f7149e38 feat: add ContextTimeoutEnabled to respect context timeouts and deadlines 2022-10-11 10:22:42 +03:00
baa48a4415 feat(pubsub): support sharded pub/sub 2022-08-04 00:05:22 +08:00
a18fad5bd3 chore: v9 2022-06-04 17:42:06 +03:00
c98c5f0eeb fix: update ChannelWithSubscriptions to accept options 2022-06-04 16:20:10 +03:00
98bb99ddc2 Fix Redis Cluster issue during roll outs of new nodes with same addr (#1914)
* fix: recycle connections in some Redis Cluster scenarios

This issue was surfaced in a Cloud Provider solution that used for
rolling out new nodes using the same address (hostname) of the nodes
that will be replaced in a Redis Cluster, while the former ones once
depromoted as Slaves would continue in service during some mintues
for redirecting traffic.

The solution basically identifies when the connection could be stale
since a MOVED response will be returned using the same address (hostname)
that is being used by the connection. At that moment we consider the
connection as no longer usable forcing to recycle the connection.
2021-10-04 13:10:42 +03:00
b94bde306e Fix/pubsub ping mutex (#1878)
* Fix PubSub.Ping to hold the lock

* Fix PubSub.Ping to hold the lock

* add write cmd data-race test

Signed-off-by: monkey92t <golang@88.com>

Co-authored-by: monkey92t <golang@88.com>
2021-09-03 17:57:34 +08:00
37f5a2b1cd Update changelog 2021-05-26 15:12:25 +03:00
8e8510431d Improve pubsub (#1764)
* Improve pubsub

Signed-off-by: monkey92t <golang@88.com>

* Extract code to channel struct and tweak API

* Move chanSendTimeout to channel

* Cleanup health check

* Add WithChannelSendTimeout and tweak comments

* clear notes

Signed-off-by: monkey92t <golang@88.com>

Co-authored-by: Vladimir Mihailenco <vladimir.webdev@gmail.com>
2021-05-26 11:25:18 +08:00
a2410beb43 upgrade golangci-lint to v1.39.0
Signed-off-by: monkey <golang@88.com>
2021-04-08 14:44:31 +08:00
02a9c81ef1 Fix golangci-lint check 2021-03-23 11:02:29 +02:00
76f1e50d50 Do not use retry backoff in PubSub 2020-09-17 12:54:48 +03:00
8a25ceadae Merge pull request #1448 from rueian/pubsub-message-payload-slice
Support string array in pubsub message payload
2020-09-08 18:02:19 +03:00
c357d18624 Faster renew the subscription 2020-09-05 10:56:09 +03:00
f5f73f8033 Support string array in pubsub message payload 2020-08-21 17:29:37 +08:00
8a3f304b25 Log with context to associate all log by traceID (#1413)
* Log with context to associate all log by traceID
2020-07-18 09:04:36 +03:00
4440575966 Merge branch 'v8' 2020-05-21 10:16:44 +03:00
eecd319ee3 Fix nil type assertion 2020-05-21 09:11:00 +03:00
3dcb844106 Bump major version 2020-05-19 08:52:38 +03:00
f5593121e0 Add ctx as first arg 2020-05-19 08:52:38 +03:00
7247939b32 Fix "redis: discarding bad PubSub connection" stuck state (#1162)
* Reset healthy on reconnect
2019-09-30 11:24:53 +03:00
7779accbea Use semantic import versioning 2019-08-08 14:29:44 +03:00
4e9cea8876 Add proper SingleConnPool implementation 2019-08-03 17:31:28 +03:00
f3ce3362a0 Add golangci-lint 2019-07-25 14:36:50 +03:00
11ef80b162 Change PubSub.Channel 2019-07-09 10:25:27 +03:00
3bdf64784a Cleanup 2019-06-17 12:32:40 +03:00
5460bc10f2 Use Context.Deadline to set net.Conn deadline 2019-06-08 15:02:51 +03:00
af59960088 Typo error in comments 2019-04-08 20:06:31 +08:00
b6fdeca648 Add PubSub.ChannelSize 2019-03-12 12:48:32 +02:00
21913a8304 pubsub: drop a message when the channel is full 2019-03-12 12:40:08 +02:00
daf101bd79 Fix nil ping error 2018-10-09 10:52:30 +03:00
6a768df38b . 2018-10-01 11:38:21 +03:00
0197108027 Use bufio.Writer 2018-08-17 14:14:02 +03:00
5146fb0c57 Cleanup buffers manipulation 2018-08-15 11:53:15 +03:00
7c26d1ceb6 Pass cn.Rd where possible 2018-08-15 09:38:58 +03:00
e3b56f7641 pubsub: fix ping logic 2018-08-07 16:48:32 +03:00
316917d99f pubsub: log an error on reconnect 2018-08-07 10:33:07 +03:00
96d1b85009 Cleanups 2018-08-06 13:59:15 +03:00
b576fe91a1 Use single read and write buffer where possible 2018-08-04 13:09:22 +03:00
7e6413d467 Better allowTimeout in PubSub 2018-07-30 13:57:04 +03:00