-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node-framework): New wiring interface (#2384)
## What ❔⚠️ No nitpick territory! This PR touches _a lot of code_, and many places there may be improved for sure. Let's focus on fundamentals only. You are free to leave nitpick comments, but please don't block the review on them only. I may or may not fix nitpicks, though will try depending on complexity and capacity, most likely in follow-up PRs. This PR introduces a new interface for `WiringLayer`. Instead of giving direct access to the `ServiceContext`, it now has to define `Input` and `Output` types, which will be fetched from/inserted to the context correspondingly. `WiringLayer::Input` has to implement `FromContext` trait. This trait has implementations for `()`, `T: Resource`, `Option<T: Resource>` , and can be derived. `WiringLayer::Output` has to implement `IntoContext`, which has the same basic implementations, and also has a derive macro. With this approach, all the inputs and outputs can be easily seen for the layer, so that we don't need to worry about docs getting outdated, and also it saves quite some boilerplate when using the framework. Besides, small changes were made where necessary, e.g.: - Consensus layer was split into two, for main and external node. - TxSink layer was split into two, for DB and proxy sinks. - A lot of "wrapper" tasks were removed. - Some convenience impls (e.g. impl `From <WrappedType> to <ResourceType>`). - Shutdown hook was made into a separate entity that implements `IntoContext`. ## Why ❔ Finalization of the framework design. ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`.
- Loading branch information
Showing
82 changed files
with
2,266 additions
and
1,827 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.