Update RDB.RemoveQueue with specific error types

This commit is contained in:
Ken Hibino
2021-05-09 06:48:44 -07:00
parent 95a6942b4e
commit 3db8eff01b
3 changed files with 68 additions and 15 deletions

View File

@@ -182,6 +182,21 @@ func IsQueueNotFound(err error) bool {
return As(err, &target)
}
// QueueNotEmptyError indicates that the given queue is not empty.
type QueueNotEmptyError struct {
Queue string // queue name
}
func (e *QueueNotEmptyError) Error() string {
return fmt.Sprintf("queue %q is not empty", e.Queue)
}
// IsQueueNotEmpty reports whether any error in err's chain is of type QueueNotEmptyError.
func IsQueueNotEmpty(err error) bool {
var target *QueueNotEmptyError
return As(err, &target)
}
// TaskAlreadyArchivedError indicates that the task in question is already archived.
type TaskAlreadyArchivedError struct {
Queue string // queue name