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

Rewrite the backend in Rust? #49

Open
sestrella opened this issue Apr 18, 2024 · 1 comment · May be fixed by #50
Open

Rewrite the backend in Rust? #49

sestrella opened this issue Apr 18, 2024 · 1 comment · May be fixed by #50

Comments

@sestrella
Copy link
Contributor

First and foremost, I'd like to thank everyone who contributed to this project, which has been an excellent contribution to the Nix ecosystem. Inspired by @domenkozar work on devenv, I want to propose rewriting the backend in Rust. While some of the primary contributors may already be familiar with this language, I would want to summarize and highlight some of the features that this project would benefit the most from:

  • Fearless concurrency - Rust maintains memory safety, which is particularly beneficial in the context of concurrent programming because it prevents the majority of typical issues such as data races. More specifically, the publish endpoint may benefit from these because tasks like inserting a new record and indexing could be done concurrently.
  • Error handling - Rust distinguishes between recoverable and unrecoverable errors, making it easier to reason about all the possible edge cases of functions, as errors are part of the type signature Result<T, E> and need to be handled explicitly.

After some little research, I found that there are Rust clients for all of the services the application relies on:

  • Open Search - There is an official client.
  • GitHub - While there are a few alternatives here, it is also possible to call the GitHub API directly using a simple HTTP client like hyper or reqwest, which is quite similar to what current Python code does.
  • PostgreSQL - While there are a few native libraries to communicate directly with PostgreSQL, there are also database-agnostic options like SQLx that check queries at compile time.

Regarding web frameworks, axum appears to be one of the most popular based on overall performance. Before getting into more technical details, I wanted to get some feedback about this proposal, as I understand that rewriting a piece of software in a new language always involves some risk and has an impact on maintainers. Nonetheless, I'd like to put this on the table in order to start a conversation and, hopefully, answer all of the questions that arise.

Note: If this proposal gets approved, I would be pleased to submit a PR.

@domenkozar
Copy link
Member

That sounds good to me, I'd happily accept the PR.

Using hyper/sqlx/axum sounds like a good choice.

@sestrella sestrella linked a pull request Apr 21, 2024 that will close this issue
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 a pull request may close this issue.

2 participants