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

@@ -17,7 +17,6 @@ import (
"github.com/hibiken/asynq/internal/errors"
pb "github.com/hibiken/asynq/internal/proto"
"github.com/hibiken/asynq/internal/timeutil"
"github.com/redis/go-redis/v9"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -718,8 +717,14 @@ type Broker interface {
ClearServerState(host string, pid int, serverID string) error
// Cancelation related methods
CancelationPubSub() (*redis.PubSub, error) // TODO: Need to decouple from redis to support other brokers
SubscribeCancellation() (CancellationSubscription, error)
PublishCancelation(id string) error
WriteResult(qname, id string, data []byte) (n int, err error)
}
// CancellationSubscription is a subscription to cancellation messages.
type CancellationSubscription interface {
Channel() <-chan string // returns a channel to receive the id of tasks to be cancelled.
Close() error // closes the subscription.
}