This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
impl Debug for sc_service::Configuration #6400
Merged
+139
−59
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2dd4f9a
Initial commit
cecton fb31420
Make sc_service::Configuration derive Debug
cecton 563da0a
Replace task_executor fn's input by proper TaskExecutor type (cleaner)
cecton 7b0590e
impl From<Fn> for TaskExecutor
cecton d9e6275
Update client/cli/src/runner.rs
bkchr d53a1c2
Add some doc, examples and tests
cecton 5cb14a0
Replace Deref by fn spawn as suggested
cecton fc69a32
Merge commit ef2a6c1c047f7afc1587006ddadcf16edf29d402 (no conflict)
cecton 1a67120
Merge commit 41970e7ea56d59d45861d65490a329fe216df74e (conflicts)
cecton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replace Deref by fn spawn as suggested
- Loading branch information
commit 5cb14a0d6024b3a11ea9a3aad170cae4557ec93c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This basically makes the struct callable. I'm not sure if this is the best solution.
Arc<Fn(future)>from TaskExecutorAny advice on what would be the cleanest implementation?
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.
As all the
TaskExecutorhas to do is to spawn futures and be cloned, I think the best idea would be to hide the internals and just add a spawn method.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.
While
Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>, TaskType) + Send + Sync>is not the most the most elegant type, anyone who knows the Rust programming language can understand this type. If you put it in a newTaskExecutorstruct, now everyone has to go look at the definition of thisTaskExecutorto know how to use it.I know it's not much, but having so many typedefs and wrapping structs is in my opinion a major pain point in the Substrate code base as whole.
Uh oh!
There was an error while loading. Please reload this page.
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.
Oh well. My goal was not to wrap it, I just needed to implement Debug and there are only 3 possible ways:
I think the trade-off is fine here especially with the
Frombecause you can simply pass a closure and do.into(). I think it would be better if I document it better so anyone who bumps into this will easily know what to do.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.
(The other good point is that you don't need to import Arc and Pin, not even TaskExecutor, you just pass the closure and use
.into())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.
I think adding some documentation would indeed be a good idea :)
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.
done
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.
@expenses done (I just noticed your comment now)