-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(v2): PoC of a version of taskbroker that uses Postgres #508
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
Conversation
Rewrite the taskbroker to use Postgres. This is just a PoC so the code isn't properly cleaned up yet.
markstory
left a comment
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.
Looking good. 👏
| impl Display for InflightActivationStatus { | ||
| fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { | ||
| write!(f, "{:?}", self) | ||
| } | ||
| } | ||
|
|
||
| impl FromStr for InflightActivationStatus { |
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.
I wonder why we didn't need to implement this with sqlite. 🤔
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.
I think the SQLite driver automatically converts it to String.
| pub pg_url: String, | ||
|
|
||
| /// The name of the postgres database to use for the inflight activation store. | ||
| pub pg_database_name: String, |
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.
You should be able to combine these, and include the database name into the url.
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.
I separated it because technically I interact with 2 databases: default, to create the DB, and then the actual DB to create the table.
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.
Right, because you can't connect to a database that doesn't exist, and you need to create the db initially.
|
|
||
| Ok(result) | ||
| pub async fn db_size(&self) -> Result<i64, Error> { | ||
| // TODO: Implement this |
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.
I suspect that the size of the DB won't be relevant with postgres.
| query_builder.push(format!( | ||
| "UPDATE inflight_taskactivations | ||
| SET | ||
| processing_deadline = now() + (processing_deadline_duration * interval '1 second') + (interval '{grace_period} seconds'), |
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.
We could add processing_deadline_duration and grace_period so that we only make one interval in the query 🤷
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.
I guess. Not too worried about it at the moment.
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.
Fair enough. This won't be the tall pole in the tent.
Rewrite the taskbroker to use Postgres. This is just a PoC so the code isn't properly cleaned up yet.