Skip to content

Use #[tokio::main] attribute instead of Runtime::new() - #351

Merged
CGodiksen merged 7 commits into
mainfrom
dev/remove-runtime
Sep 28, 2025
Merged

Use #[tokio::main] attribute instead of Runtime::new()#351
CGodiksen merged 7 commits into
mainfrom
dev/remove-runtime

Conversation

@CGodiksen

Copy link
Copy Markdown
Collaborator

This PR removes the top-level Tokio runtime created with Runtime::new() and instead uses the #[tokio::main] attribute in both modelardb_server and modelardb_manager.

It was also attempted to remove the use of thread::Builder::new().spawn() when creating the threads in the storage engine but it was not possible to find a solution that did not block the thread or cause problems with the async runtime.

It might be possible if we used async Tokio channels instead of crossbeam_channel since the current channels are blocking but that would require a larger change to the structure of the storage engine.

@CGodiksen CGodiksen self-assigned this Sep 24, 2025
@CGodiksen
CGodiksen requested a review from Copilot September 24, 2025 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the Tokio runtime usage by replacing manually created Runtime instances with the #[tokio::main] attribute in both modelardb_server and modelardb_manager. This change simplifies the async runtime management and eliminates the need to pass runtime instances between functions.

  • Replaces manual Runtime::new() creation with #[tokio::main] attribute
  • Converts synchronous main functions to async and removes runtime.block_on() calls
  • Updates function signatures to be async where the runtime parameter was removed

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/modelardb_server/src/main.rs Converts main function to async with #[tokio::main] and removes manual runtime creation
crates/modelardb_server/src/context.rs Removes runtime parameter from Context::try_new()
crates/modelardb_server/src/storage/mod.rs Moves runtime creation inside StorageEngine::try_new() instead of receiving it as parameter
crates/modelardb_server/src/remote.rs Makes start_apache_arrow_flight_server() async and removes runtime parameter
crates/modelardb_server/src/storage/uncompressed_data_manager.rs Removes runtime parameter from test context creation
crates/modelardb_server/src/configuration.rs Removes runtime parameter from test storage engine creation
crates/modelardb_manager/src/main.rs Converts main function to async with #[tokio::main] and removes manual runtime creation
crates/modelardb_manager/src/remote.rs Makes start_apache_arrow_flight_server() async and removes runtime parameter

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread crates/modelardb_server/src/storage/mod.rs Outdated
@CGodiksen
CGodiksen merged commit 9b10d0f into main Sep 28, 2025
4 checks passed
@CGodiksen
CGodiksen deleted the dev/remove-runtime branch September 28, 2025 12:40
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.

4 participants