mirror of
https://github.com/hibiken/asynq.git
synced 2025-09-19 21:27:42 +08:00
Inspector support Go context
This commit is contained in:
@@ -749,7 +749,7 @@ type Broker interface {
|
||||
|
||||
// Cancelation related methods
|
||||
CancelationPubSub() (*redis.PubSub, error) // TODO: Need to decouple from redis to support other brokers
|
||||
PublishCancelation(id string) error
|
||||
PublishCancelation(ctx context.Context, id string) error
|
||||
|
||||
WriteResult(qname, id string, data []byte) (n int, err error)
|
||||
}
|
||||
|
@@ -1459,13 +1459,7 @@ func (r *RDB) CancelationPubSub() (*redis.PubSub, error) {
|
||||
|
||||
// PublishCancelation publish cancelation message to all subscribers.
|
||||
// The message is the ID for the task to be canceled.
|
||||
func (r *RDB) PublishCancelation(id string) error {
|
||||
return r.PublishCancelationContext(context.Background(), id)
|
||||
}
|
||||
|
||||
// PublishCancelationContext publish cancelation message to all subscribers.
|
||||
// The message is the ID for the task to be canceled.
|
||||
func (r *RDB) PublishCancelationContext(ctx context.Context, id string) error {
|
||||
func (r *RDB) PublishCancelation(ctx context.Context, id string) error {
|
||||
var op errors.Op = "rdb.PublishCancelation"
|
||||
if err := r.client.Publish(ctx, base.CancelChannel, id).Err(); err != nil {
|
||||
return errors.E(op, errors.Unknown, fmt.Sprintf("redis pubsub publish error: %v", err))
|
||||
|
@@ -3053,7 +3053,7 @@ func TestCancelationPubSub(t *testing.T) {
|
||||
publish := []string{"one", "two", "three"}
|
||||
|
||||
for _, msg := range publish {
|
||||
r.PublishCancelation(msg)
|
||||
r.PublishCancelation(context.Background(), msg)
|
||||
}
|
||||
|
||||
// allow for message to reach subscribers.
|
||||
|
@@ -199,13 +199,13 @@ func (tb *TestBroker) CancelationPubSub() (*redis.PubSub, error) {
|
||||
return tb.real.CancelationPubSub()
|
||||
}
|
||||
|
||||
func (tb *TestBroker) PublishCancelation(id string) error {
|
||||
func (tb *TestBroker) PublishCancelation(ctx context.Context, id string) error {
|
||||
tb.mu.Lock()
|
||||
defer tb.mu.Unlock()
|
||||
if tb.sleeping {
|
||||
return errRedisDown
|
||||
}
|
||||
return tb.real.PublishCancelation(id)
|
||||
return tb.real.PublishCancelation(ctx, id)
|
||||
}
|
||||
|
||||
func (tb *TestBroker) WriteResult(qname, id string, data []byte) (int, error) {
|
||||
|
Reference in New Issue
Block a user