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

When scrims are created, change the order of db save and pub/sub call #42

Closed
n8kim1 opened this issue Nov 2, 2020 · 6 comments
Closed

Comments

@n8kim1
Copy link
Contributor

n8kim1 commented Nov 2, 2020

first send games to pub/sub, and then record them in db as “queued”. This would make “queued” more meaningful, and before “queued” we can give games a status of “created” or smth

create a scrim, save it in the db w status "pending". then send to pub/sub, and then record them in db as “queued”.
this prevents games being tossed onto the pubsub but not actually in the database. also, gives us more tools for debugging too

battlecode/battlecode20#338

@opheez
Copy link
Contributor

opheez commented Dec 28, 2020

is "pending" (what currently exists) what you meant by:

before “queued” we can give games a status of “created” or smth

or is "created" something different you had in mind?

also, by "changing the order", that isn't just moving the order of the pubsub call right? do we have to first wait for the pub to finish successfully first, and then update the db?

@n8kim1
Copy link
Contributor Author

n8kim1 commented Dec 28, 2020

@opheeelia remind me to think abt this (don't wanna leave on read)? also #39 might help clarify things (but also i haven't re-read that carefully yet either)

@n8kim1
Copy link
Contributor Author

n8kim1 commented Dec 28, 2020

At a high level:
User presses button -> backend creates an entry for a scrimmage in the db, gives it status of "pending" -> backend queues the scrimmage -> on successful queueing, backend gives the scrimmage a status of "queued"

yep - I think "pending" and "created" are synonymous here
I think the best solution is updating the db twice. At the very least, db save should happpen first, then pubsub call should happen (not the other way around), since the scrimmage server generally expects to find an entry in the db.

@n8kim1
Copy link
Contributor Author

n8kim1 commented Jan 2, 2021

new-and-improved submission process may be a good example (of save in db, add to pubsub, save in db again)

@n8kim1
Copy link
Contributor Author

n8kim1 commented Jan 4, 2021

@opheeelia i just remembered that "pending" means something else, related to autoaccept. a new "created" status seems like the way to go.

created --> (pending -->) queued

@n8kim1
Copy link
Contributor Author

n8kim1 commented Jan 5, 2021

merged to master!

@n8kim1 n8kim1 closed this as completed Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants