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

feat: adding component start(initialization) to the server start #447

Merged
merged 1 commit into from
Jul 14, 2024

Conversation

lev-starkware
Copy link
Contributor

@lev-starkware lev-starkware commented Jul 11, 2024

commit-id:77f186d4


This change is Reviewable

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 72.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 82.80%. Comparing base (7c08d83) to head (a35a991).

Files Patch % Lines
crates/mempool_infra/src/component_server.rs 71.42% 2 Missing and 4 partials ⚠️
crates/mempool_infra/src/component_runner.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #447      +/-   ##
==========================================
- Coverage   82.89%   82.80%   -0.10%     
==========================================
  Files          37       37              
  Lines        1719     1733      +14     
  Branches     1719     1733      +14     
==========================================
+ Hits         1425     1435      +10     
- Misses        217      219       +2     
- Partials       77       79       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/77f186d4 branch from 2a9c292 to 2385f67 Compare July 11, 2024 09:53
Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @lev-starkware)


crates/mempool_infra/src/component_runner.rs line 18 at r1 (raw file):

        Ok(())
    }
}

The naming here slightly confuses me: a runner has a start function; wouldn't it be clearer if the function's name would be run?

Code quote:

pub trait ComponentRunner {
    /// Start the component. By default do nothing.
    async fn start(&mut self) -> Result<(), ComponentStartError> {
        Ok(())
    }
}

crates/mempool_infra/tests/common/mod.rs line 4 at r1 (raw file):

use serde::{Deserialize, Serialize};
use starknet_mempool_infra::component_client::ClientResult;
use starknet_mempool_infra::component_runner::ComponentRunner;

Please add an empty line between the last use and the first type def.

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @lev-starkware)


crates/mempool_infra/src/component_server.rs line 66 at r1 (raw file):

                return;
            }
        }

Can we unify some of this logic with the impl in the empty server?

Code quote:

        match self.component.start().await {
            Ok(_) => info!("ComponentServer::start() completed."),
            Err(err) => {
                error!("ComponentServer::start() failed: {:?}", err);
                return;
            }
        }

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @lev-starkware)


crates/mempool_infra/src/component_runner.rs line 18 at r1 (raw file):

        Ok(())
    }
}

I'm also in favor of having better consistency with the ComponentServerStarter : here the start function returns Result, in the server starter it doesn't return anything.

Is there a way to address that (can be in a different pr)?

Code quote:

pub trait ComponentRunner {
    /// Start the component. By default do nothing.
    async fn start(&mut self) -> Result<(), ComponentStartError> {
        Ok(())
    }
}

@lev-starkware lev-starkware force-pushed the pr/lev-starkware/lev_dev/77f186d4 branch from 2385f67 to a35a991 Compare July 11, 2024 14:38
Copy link
Contributor Author

@lev-starkware lev-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @Itay-Tsabary-Starkware)


crates/mempool_infra/src/component_runner.rs line 18 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

I'm also in favor of having better consistency with the ComponentServerStarter : here the start function returns Result, in the server starter it doesn't return anything.

Is there a way to address that (can be in a different pr)?

I agree, but let's address it in a different PR.


crates/mempool_infra/src/component_runner.rs line 18 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

The naming here slightly confuses me: a runner has a start function; wouldn't it be clearer if the function's name would be run?

Changed to ComponentStarter.


crates/mempool_infra/tests/common/mod.rs line 4 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Please add an empty line between the last use and the first type def.

Done.

Copy link
Contributor Author

@lev-starkware lev-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 4 unresolved discussions (waiting on @Itay-Tsabary-Starkware)


crates/mempool_infra/src/component_server.rs line 66 at r1 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Can we unify some of this logic with the impl in the empty server?

Done.

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 5 files at r2.
Reviewable status: 2 of 5 files reviewed, 2 unresolved discussions (waiting on @lev-starkware)


crates/mempool_infra/src/component_server.rs line 73 at r2 (raw file):

}

pub async fn start_component<Component>(component: &mut Component) -> bool

Please return Result.

Code quote:

bool

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 5 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lev-starkware)

@lev-starkware lev-starkware merged commit 73bf292 into main Jul 14, 2024
24 checks passed
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