[GH-ISSUE #488] [FEATURE REQUEST] RDB and Inspector support Go contexts #221

Open
opened 2026-03-02 05:19:44 +03:00 by kerem · 1 comment
Owner

Originally created by @xuyang2 on GitHub (Jun 13, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/488

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
Is it acceptable to add a ctx context.Context parameter to some RDB and Inspector methods, for deadline, cancellation and observability(otel).

Describe the solution you'd like

Take Inspector.Queues() for example:

// QueuesContext returns a list of all queue names.
func (i *Inspector) QueuesContext(ctx context.Context) ([]string, error) {
	return i.rdb.AllQueuesContext(ctx)
}

// Queues returns a list of all queue names.
func (i *Inspector) Queues() ([]string, error) {
	return i.QueuesContext(context.Background())
}
// AllQueuesContext returns a list of all queue names.
func (r *RDB) AllQueuesContext(ctx context.Context) ([]string, error) {
	return r.client.SMembers(ctx, base.AllQueues).Result()
}

// AllQueues returns a list of all queue names.
func (r *RDB) AllQueues() ([]string, error) {
	return r.AllQueuesContext(context.Background())
}

I can make a PR if this is acceptable.

Originally created by @xuyang2 on GitHub (Jun 13, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/488 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** Is it acceptable to add a `ctx context.Context` parameter to some `RDB` and `Inspector` methods, for deadline, cancellation and observability(otel). **Describe the solution you'd like** Take `Inspector.Queues()` for example: ```Go // QueuesContext returns a list of all queue names. func (i *Inspector) QueuesContext(ctx context.Context) ([]string, error) { return i.rdb.AllQueuesContext(ctx) } // Queues returns a list of all queue names. func (i *Inspector) Queues() ([]string, error) { return i.QueuesContext(context.Background()) } ``` ```Go // AllQueuesContext returns a list of all queue names. func (r *RDB) AllQueuesContext(ctx context.Context) ([]string, error) { return r.client.SMembers(ctx, base.AllQueues).Result() } // AllQueues returns a list of all queue names. func (r *RDB) AllQueues() ([]string, error) { return r.AllQueuesContext(context.Background()) } ``` I can make a PR if this is acceptable.
Author
Owner

@hibiken commented on GitHub (Jun 18, 2022):

@xuyang2 Yes I think it makes sense to support context for all inspector operations. Please feel free to create a PR!

<!-- gh-comment-id:1159550337 --> @hibiken commented on GitHub (Jun 18, 2022): @xuyang2 Yes I think it makes sense to support context for all inspector operations. Please feel free to create a PR!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#221
No description provided.