Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of xqueue/locks #17

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

ochaton
Copy link
Member

@ochaton ochaton commented Jan 16, 2022

Needs to be carefully reviewed

This commit adds new feature to xqueue - `lockable`.
User may specify a `lock` field in fields map when doing
xqueue.upgrade(). If specified xqueue checks that there is an additional
index with fields (lock, status, ...). This index is used by put(),
ack(), bury() and kill() methods in order to determine if current task
should be locked or unlocked.
This feature allows to process tasks only in a strict order or in other
words, doesn't allow workers to take a task when another task by lock
field is already being processed.

Notable additions:
* put(): When putting a task additional 1-3 queries are done to find if
  there is any other task in the queue with statuses L, T or R. If there
  is at least one task, then current task's status will be set to L
  rather than R.
* ack(), kill(), bury(): In these methods after successful status change
  of task xqueue will try to find a task with L status within `lock`
  index and wake it up, transferring to an R state.

This `lockable` feature currently cannot be used alongside with ttl or delayed features.
@ochaton ochaton requested a review from Mons January 16, 2022 14:44
@ochaton ochaton self-assigned this Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants