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

Unit tests and cleanup for outgoing federation code #4733

Merged
merged 16 commits into from
May 27, 2024

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented May 22, 2024

No description provided.

tracing::warn!("task exited, restarting: {res:?}");
}
}
});
Copy link
Member Author

Choose a reason for hiding this comment

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

This loop here seems completely unnecessary as the send worker is already looping on its own.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the instance worker loop actually reliably looped it would have a return type of ! or (), but it returns a result. the reason this restart is necessary is that on internal errors, the function exits and the worker needs to be restarted

@@ -94,11 +94,15 @@ impl Instance {
.await
}

#[cfg(test)]
/// Only for use in tests
pub async fn delete_all(pool: &mut DbPool<'_>) -> Result<usize, Error> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to remove this because items marked as #[cfg(test)] are only available within the same crate.

}
}
info!("{ok_count} others up to date. {behind_count} instances behind.");
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this stuff into separate file without changes.

@Nutomic Nutomic changed the title Unit tests for outgoing federation Unit tests and cleanup for outgoing federation code May 23, 2024
@Nutomic Nutomic marked this pull request as ready for review May 23, 2024 14:59
Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Not my area of expertise, so it might be good for @phiresky to take a look.

crates/federate/src/stats.rs Outdated Show resolved Hide resolved
@dessalines dessalines merged commit af034f3 into main May 27, 2024
2 checks passed
for (instance_id, stat) in stats {
let domain = &instances
.iter()
.find(|i| &i.id == instance_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a pretty unnecessary O(n^2) that was added, this looped through ~5k things before, now it loops through 25 million things every time.

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.

5 participants