-
Notifications
You must be signed in to change notification settings - Fork 33
[$150] Automatic status updates #54
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
Comments
Contest https://www.topcoder.com/challenges/30158837 has been created for this ticket. |
@imcaizheng open for pickup. |
Contest https://www.topcoder.com/challenges/30158837 has been updated - it has been assigned to aaron2017. |
As a quick solution, we could handle the first requirement inside Creating another taas processor like The solution could be broken into two steps:
...
const events = require('events')
const eventEmitter = new events.EventEmitter()
...
async function postEvent (topic, payload) {
...
// emit event locally after the message is sent to BUS API
// the payload contains all the info we need about the data created/updated
eventEmitter.emit('bus_event_sent', payload)
}
...
module.exports = {
eventEmitter
}
Eventually all the requirements are implemented outside the services. The services remain clear. Moreover, we could migrate the functionality mentioned on #42 to the event handlers as well. @maxceem Could we implement the requirements like that? How would you think about it? |
Thank you for considering readability @imcaizheng. Decoupling logic is indeed very needed here. Though there is one kind of edge cases that would be good to avoid. We have to make sure that this logic for automatic status updates is done during the request, not asynchronously after the request. Otherwise, there would be some time when we have inconsistent data. For example, imagine we have a Job and we are creating a new resourceBooking for it:
Quick googling tells that this we cannot wait for EventEmitter event to complete https://stackoverflow.com/questions/10053073/nodejs-wait-for-callback-to-finish-on-event-emit. There is some workaround mentioned in this article, but not sure if this would work for our case https://www.derpturkey.com/event-emitter-to-promise/ @imcaizheng what do you think about such edge cases? |
@maxceem Even if we try to update the Job's status during the request, the job status would still be updated asynchronously after request via IMO, The edge case is unavoidable unless we merge |
Yeah, agree on that @imcaizheng. Ok, let's go with the way you've suggested with EventEmmiter. We would keep an eye on this if this brings any issues in real usage. It would be also nice to add some good debugging logs there, to make it easier to debug what is going on in case of issues. Also, please, move there the previously implemented logic as well #42. I would adjust the price for this ticket taking into account efforts for creating a common code apart from the status logic. |
@maxceem There is no EDIT for the first requirement, by default a resource booking is created, its status is |
PR created #79 |
Nice catch. I would confirm this first with PM.
agree |
@imcaizheng I've got clarification from PM. Can we add a possible value |
@maxceem PR is updated to use the |
As per Will update, we don't have to cancel ResourceBokings on Job canceling, so I've removed that 076cc8a |
Payment task has been updated: https://software.topcoder.com/review/actions/ViewProjectDetails?pid=30158837 |
Uh oh!
There was an error while loading. Please reload this page.
When we add/update any
ResourceBooking
we have to check if the correspondingJob
hasnumPositions === length(ResourceBooking with status === "assigned")
. And if so, then update the status of theJob
toassigned
.If we change
Job
status tocancelled
. Then we should change the status of all(updated: don't change status for ResourceBookings)ResourceBooking
andJodCandidate
related to this job tocancelled
.The text was updated successfully, but these errors were encountered: