Skip to content

Conversation

@evanh
Copy link
Member

@evanh evanh commented Nov 4, 2025

Rewrite the taskbroker to use Postgres. This is just a PoC so the code isn't properly cleaned up yet.

Rewrite the taskbroker to use Postgres. This is just a PoC so the code isn't properly cleaned up
yet.
@evanh evanh requested a review from a team as a code owner November 4, 2025 21:18
Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. 👏

Comment on lines +30 to +36
impl Display for InflightActivationStatus {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, "{:?}", self)
}
}

impl FromStr for InflightActivationStatus {
Copy link
Member

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. 🤔

Copy link
Member Author

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.

Comment on lines +125 to +128
pub pg_url: String,

/// The name of the postgres database to use for the inflight activation store.
pub pg_database_name: String,
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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
Copy link
Member

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'),
Copy link
Member

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 🤷

Copy link
Member Author

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.

Copy link
Member

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.

@evanh evanh closed this Nov 10, 2025
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.

3 participants