2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-22 22:06:12 +08:00

feat: allow custom broker

This commit is contained in:
huangdong.106
2024-12-03 21:02:21 +08:00
parent 106c07adaa
commit 7986156ac4
7 changed files with 72 additions and 32 deletions

View File

@@ -12,7 +12,6 @@ import (
"time"
"github.com/hibiken/asynq/internal/base"
"github.com/redis/go-redis/v9"
)
var errRedisDown = errors.New("testutil: redis is down")
@@ -190,13 +189,13 @@ func (tb *TestBroker) ClearServerState(host string, pid int, serverID string) er
return tb.real.ClearServerState(host, pid, serverID)
}
func (tb *TestBroker) CancelationPubSub() (*redis.PubSub, error) {
func (tb *TestBroker) SubscribeCancellation() (base.CancellationSubscription, error) {
tb.mu.Lock()
defer tb.mu.Unlock()
if tb.sleeping {
return nil, errRedisDown
}
return tb.real.CancelationPubSub()
return tb.real.SubscribeCancellation()
}
func (tb *TestBroker) PublishCancelation(id string) error {