-
Notifications
You must be signed in to change notification settings - Fork 21
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
chore: add create client macro #1874
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1874 +/- ##
==========================================
- Coverage 40.10% 5.50% -34.60%
==========================================
Files 26 261 +235
Lines 1895 30326 +28431
Branches 1895 30326 +28431
==========================================
+ Hits 760 1670 +910
- Misses 1100 28601 +27501
- Partials 35 55 +20 ☔ View full report in Codecov by Sentry. |
aa7198a
to
8f06ee0
Compare
There was a problem hiding this 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 1 files reviewed, 8 unresolved discussions (waiting on @nadin-Starkware)
crates/sequencer_node/src/clients.rs
line 44 at r1 (raw file):
/// This macro simplifies the creation of a client by evaluating the execution mode /// and conditionally constructing the client only if the mode is enabled (either /// LocalExecutionWithRemoteDisabled or LocalExecutionWithRemoteEnabled).
Let's make this more concise: wydt about
A macro for creating a component client, determined by the component's execution mode. Returns a local client if the component is run locally, otherwise `None`.
Later when adding the remote client we can modify this doc to detail the remote client option as well.
Code quote:
/// A macro to create a shared client based on the component's execution mode.
///
/// This macro simplifies the creation of a client by evaluating the execution mode
/// and conditionally constructing the client only if the mode is enabled (either
/// LocalExecutionWithRemoteDisabled or LocalExecutionWithRemoteEnabled).
crates/sequencer_node/src/clients.rs
line 49 at r1 (raw file):
/// /// * $execution_mode - A reference to the execution mode to evaluate, expected to be of type /// ComponentExecutionMode.
A reference to the component's execution mode, i.e., type &ComponentExecutionMode
Code quote:
/// * $execution_mode - A reference to the execution mode to evaluate, expected to be of type
/// ComponentExecutionMode.
crates/sequencer_node/src/clients.rs
line 50 at r1 (raw file):
/// * $execution_mode - A reference to the execution mode to evaluate, expected to be of type /// ComponentExecutionMode. /// * $client_type - The type of the client to create, such as LocalBatcherClient.
The client type to create, e.g., LocalBatcherClient. The client type should have a function $client_type::new(tx : $channel_expr).
Code quote:
The type of the client to create, such as LocalBatcherClient.
crates/sequencer_node/src/clients.rs
line 51 at r1 (raw file):
/// ComponentExecutionMode. /// * $client_type - The type of the client to create, such as LocalBatcherClient. /// * $channel_expr - An expression to retrieve the channel required for the client, e.g.,
Sender side for the client.
Code quote:
An expression to retrieve the channel required for the client
crates/sequencer_node/src/clients.rs
line 52 at r1 (raw file):
/// * $client_type - The type of the client to create, such as LocalBatcherClient. /// * $channel_expr - An expression to retrieve the channel required for the client, e.g., /// channels.take_batcher_tx().
Let's make this the 2nd arguement (i.e., replace the order with client type), so we can better describe what client type is.
Code quote:
/// * $channel_expr - An expression to retrieve the channel required for the client, e.g.,
/// channels.take_batcher_tx().
crates/sequencer_node/src/clients.rs
line 57 at r1 (raw file):
/// /// An `Option<Arc<dyn ClientType>>` containing the client if the execution mode is enabled, /// or None if the execution mode is Disabled.
Be more explicit regarding the enabled
option, as Disabled
is an actual enum variant whereas enabled
isn't.
Code quote:
/// An `Option<Arc<dyn ClientType>>` containing the client if the execution mode is enabled,
/// or None if the execution mode is Disabled.
crates/sequencer_node/src/clients.rs
line 74 at r1 (raw file):
/// None => println!("Client not created because the execution mode is disabled."), /// } /// ```
Can you make this example compile/pass?
I.e., drop the ignore
Code quote:
/// ```rust,ignore
/// // Assuming ComponentExecutionMode and channels are defined, and LocalBatcherClient
/// // has a new method that accepts a channel.
/// let batcher_client: Option<SharedBatcherClient> = create_client!(
/// &config.components.batcher.execution_mode,
/// LocalBatcherClient,
/// channels.take_batcher_tx()
/// );
///
/// match batcher_client {
/// Some(client) => println!("Client created: {:?}", client),
/// None => println!("Client not created because the execution mode is disabled."),
/// }
/// ```
crates/sequencer_node/src/clients.rs
line 91 at r1 (raw file):
channels: &mut SequencerNodeCommunication, ) -> SequencerNodeClients { let batcher_client: Option<SharedBatcherClient> = create_client!(
Are these type annotations required?
Code quote:
Option<SharedBatcherClient>
There was a problem hiding this 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 1 files reviewed, 8 unresolved discussions (waiting on @nadin-Starkware)
crates/sequencer_node/src/clients.rs
line 110 at r1 (raw file):
&config.components.mempool_p2p.execution_mode, LocalMempoolP2pPropagatorClient, channels.take_mempool_p2p_propagator_tx()
Not for this pr:
When'll have the remote clients, they will also need the channel_tx, so we'd have to switch from using take
to clone
. FYI.
Code quote:
channels.take_mempool_p2p_propagator_tx()
8504010
to
3bd557a
Compare
8f06ee0
to
3d62d7b
Compare
There was a problem hiding this 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 1 files reviewed, 8 unresolved discussions (waiting on @Itay-Tsabary-Starkware)
crates/sequencer_node/src/clients.rs
line 44 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Let's make this more concise: wydt about
A macro for creating a component client, determined by the component's execution mode. Returns a local client if the component is run locally, otherwise `None`.
Later when adding the remote client we can modify this doc to detail the remote client option as well.
Done.
crates/sequencer_node/src/clients.rs
line 49 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
A reference to the component's execution mode, i.e., type
&ComponentExecutionMode
Done.
crates/sequencer_node/src/clients.rs
line 50 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
The client type to create, e.g., LocalBatcherClient. The client type should have a function $client_type::new(tx : $channel_expr).
Done.
crates/sequencer_node/src/clients.rs
line 51 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Sender side for the client.
Done.
crates/sequencer_node/src/clients.rs
line 52 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Let's make this the 2nd arguement (i.e., replace the order with client type), so we can better describe what client type is.
Done.
crates/sequencer_node/src/clients.rs
line 57 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Be more explicit regarding the
enabled
option, asDisabled
is an actual enum variant whereasenabled
isn't.
Done.
crates/sequencer_node/src/clients.rs
line 74 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Can you make this example compile/pass?
I.e., drop theignore
No, I get not found in this scope on the macro.
crates/sequencer_node/src/clients.rs
line 91 at r1 (raw file):
Previously, Itay-Tsabary-Starkware wrote…
Are these type annotations required?
The type annotation is necessary because it tells Rust to treat LocalComponentClient<BatcherRequest, BatcherResponse> as the trait object BatcherClient. This annotation triggers a coercion from Arc to Arc, which Rust wouldn’t do automatically without the annotation, resulting in a type mismatch.
3d62d7b
to
b2c2341
Compare
Artifacts upload triggered. View details here |
Benchmark movements: |
a7631f4
to
3c496da
Compare
commit-id:73967fda
3c496da
to
8a6d6c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @nadin-Starkware)
✓ Commit merged in pull request #1909 |
Stack: