Skip to content

Decouple PubSub from Redis in the Broker interface#1122

Open
halomanlodestar wants to merge 4 commits into
hibiken:masterfrom
halomanlodestar:kunal/pubsub
Open

Decouple PubSub from Redis in the Broker interface#1122
halomanlodestar wants to merge 4 commits into
hibiken:masterfrom
halomanlodestar:kunal/pubsub

Conversation

@halomanlodestar

Copy link
Copy Markdown

A sub part of #173

Summary

This change addresses the TODO on CancelationPubSub() in Broker interface at internal/base/base.go:726.
Removes the hard dependency on *redis.PubSub from the Broker interface, replacing it with a minimal PubSub interface. This is a prerequisite for supporting non-Redis broker implementations.

Motivation

CancelationPubSub() in the Broker interface previously returned *redis.PubSub directly, making it impossible to implement a compliant broker without Redis. This change abstracts that dependency behind an interface.

Changes

New base.PubSub interface

  • Defines a broker-agnostic PubSub interface with Channel() <-chan string, and Close
  • Broker.CancelationPubSub() now returns (PubSub, error) instead of (*redis.PubSub, error)

New RedisPubSub adapter

  • Wraps *redis.PubSub to implement base.PubSub
  • Channel() returns <-chan string (message payloads only), hiding Redis-specific message types from callers
  • Updated consumers

Testing

Existing TestCancelationPubSub updated to match the new <-chan string API (reads msg directly instead of msg.Payload).

@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.44%. Comparing base (f8d6677) to head (fbed329).
⚠️ Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
internal/rdb/rdb_pubsub.go 84.61% 2 Missing ⚠️
internal/testbroker/testbroker.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1122      +/-   ##
==========================================
+ Coverage   63.34%   63.44%   +0.10%     
==========================================
  Files          29       30       +1     
  Lines        4984     4998      +14     
==========================================
+ Hits         3157     3171      +14     
- Misses       1549     1550       +1     
+ Partials      278      277       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kamikazechaser

Copy link
Copy Markdown
Collaborator

This is out of scope. See #1138.

@kamikazechaser kamikazechaser added the pr-alternative-available There is a workaround this issue with minimal work label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-alternative-available There is a workaround this issue with minimal work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants