[GH-ISSUE #624] [FEATURE REQUEST] Pause queue for duration #2329

Open
opened 2026-03-15 20:06:59 +03:00 by kerem · 1 comment
Owner

Originally created by @sainak on GitHub (Mar 6, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/624

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
I ran into a use case where I want the queue to be unpaused after some defined time, but currently there is no inbuilt method to set pause timeout, so we need to manually set a timer to unpause a queue after n seconds.

Describe the solution you'd like
In the current implementation, we are always setting the expiration time to 0
github.com/hibiken/asynq@cc777ebdaa/internal/rdb/inspect.go (L1974)
I would suggest having a PauseForDuration method exposed to the inspector that would set the pause key for the given duration

Describe alternatives you've considered

func PauseQueueForDuration(i *asynq.Inspector, q string, n time.Duration) (err error) {
	if err = i.PauseQueue(q); err != nil {
		return
	}
	time.AfterFunc(n, func() {
		if err := i.UnpauseQueue(q); err != nil {
			log.Printf("failed to unpause queue: %s: %s", q, err)
		}
	})
	return
}

Originally created by @sainak on GitHub (Mar 6, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/624 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** I ran into a use case where I want the queue to be unpaused after some defined time, but currently there is no inbuilt method to set pause timeout, so we need to manually set a timer to unpause a queue after n seconds. **Describe the solution you'd like** In the current implementation, we are always setting the expiration time to 0 https://github.com/hibiken/asynq/blob/cc777ebdaa62b69bd6e985fa97117b854e7d1cd6/internal/rdb/inspect.go#L1974 I would suggest having a `PauseForDuration` method exposed to the inspector that would set the pause key for the given duration **Describe alternatives you've considered** ```go func PauseQueueForDuration(i *asynq.Inspector, q string, n time.Duration) (err error) { if err = i.PauseQueue(q); err != nil { return } time.AfterFunc(n, func() { if err := i.UnpauseQueue(q); err != nil { log.Printf("failed to unpause queue: %s: %s", q, err) } }) return } ```
Author
Owner

@ajatprabha commented on GitHub (Mar 14, 2023):

If this use-case is also similar where queue must be paused for sometime and then resume.
This issue and #590 might be good candidates to be picked up together.

I wanted to achieve this to mitigate load on upstream calls in case of large downtime.

<!-- gh-comment-id:1467586458 --> @ajatprabha commented on GitHub (Mar 14, 2023): If this use-case is also similar where queue must be paused for sometime and then resume. This issue and #590 might be good candidates to be picked up together. I wanted to achieve this to mitigate load on upstream calls in case of large downtime.
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#2329
No description provided.