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
Rework TaskManager task locking APIs #11530
Conversation
⯅ @fluid-example/bundle-size-tests: +15.8 KB
Baseline commit: fe10534 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting! :-D
Co-authored-by: Matt Rakow <ChumpChief@users.noreply.github.com>
|
@scottn12 , really like the additional thinking and direction here. I don't think I fully get the nuances of the new API. Some questions to help clarify:
|
|
@skylerjokiel, I'd be happy to help clarify!
Assigned means that you are the client who currently has the task lock and is allowed to execute a specific task with the guarantee that no other client is also executing the task. Being subscribed to a task means that you will always be trying to obtain the task lock whenever possible (by entering the queue).
This is something I am currently saving for my next PR. If you take a look at the internal design doc (linked in description), you will see a
Currently neither API can really mark a task as complete (see above). I made this a separate API for scenarios where we will want to have clients continuously attempt to volunteer for a task whenever it's possible, such as ongoing and asynchronous tasks. In cases like these, we can avoid calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little more feedback, mostly interested in the abandon() method
Co-authored-by: Matt Rakow <ChumpChief@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work -- looks good to me! :)
|
Hello @sonalivdeshpande! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Description
This PR reworks
TaskManager.lockTask()tovolunteerForTask()and introducesTaskManager.subscribeToTask().volunteerForTask()This API largely remains unchanged from
lockTask(). One major difference is that the return type was changed formPromise<void>toPromise<boolean>. This was done to prepare for the API eventually returnfalsein certain circumstances, mainly if the task has already been completed (see internal design doc linked below).The main motivation behind the rename was to be more similar to
subscribeToTask()and to emphasize that there is no guarantee that this API will ever obtain the task lock.subscribeToTask()This API is similar to
volunteerForTask()with a few key differences. First, this API will continuously try to lock the given task. If the lock is lost due to losing connection, then we will automatically try to re-enter the queue upon reconnection. This is ideal for ongoing or asynchrounous tasks that do not have a definitive end. Second, this API does not have a return value, since calling this API once can result in the task lock being assigned and lost multiple times. To effectively use this API, the caller must rely on listening to theassignedandlostevents to determine if the task lock is assigned to the client.subscribed()This API simply returns a boolean to indicate if the client is currently subscribed to a given task.
haveTaskLock()/assignedTask()This PR also renames
haveTaskLock()toassignedTask(). This was done to be more consistent with theassignedevent, as well as the new APIs. There are no functional changes to this API.Clicker Demo
This PR also updates the clicker demo to demonstrate a case where
subscribeToTask()is useful and how someone may implement it in their application. The previous iteration of clicker demo would always try obtaining the task lock no matter what. If the lock was lost the client would simply re-enter the queue if possible. This is a good opportunity to demonstratesubscribeToTask()and the coding patterns associated with it.Reviewer Guidance
Would appreciate feedback on:
Other information or known dependencies
MSFT Internal Design Doc
AB#1466