-
Notifications
You must be signed in to change notification settings - Fork 174
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
Rexport types for servers #409
Conversation
jsonrpsee/Cargo.toml
Outdated
@@ -20,6 +20,6 @@ types = { path = "../types", version = "0.2.0", package = "jsonrpsee-types", opt | |||
|
|||
[features] | |||
client = ["http-client", "ws-client"] | |||
server = ["http-server", "ws-server", "utils"] | |||
server = ["http-server", "ws-server", "utils", "macros"] |
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 types should be sufficient here, no?
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.
"types" is sufficient, but I'm a bit concerned that this will become messy. I'd like to be able to look at lib.rs
and see at a glance where everything is coming from.
jsonrpsee/Cargo.toml
Outdated
@@ -20,6 +20,6 @@ types = { path = "../types", version = "0.2.0", package = "jsonrpsee-types", opt | |||
|
|||
[features] | |||
client = ["http-client", "ws-client"] |
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.
perhaps we should add types here too? however types are re-exported from the clients
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 we should re-export the types from the servers too inorder for the crates to be used as independent crates but the most common usage should be from the facade crate anyway.
Export types::* from façade when the "types" is active Export types::* from servers
http-server/src/lib.rs
Outdated
@@ -40,7 +40,7 @@ pub use access_control::{ | |||
hosts::{AllowHosts, Host}, | |||
AccessControl, AccessControlBuilder, | |||
}; | |||
pub use jsonrpsee_types::{Error, TEN_MB_SIZE_BYTES}; | |||
pub use jsonrpsee_types::*; |
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.
Wouldn't it make more sense to re-export types in namespace like: pub use jsonrpsee_types as types
?
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.
Yes I agree. I went ahead and did that so there's a lot more noise here now.
|
||
/// Procedural macros for JSON RPC implementations. | ||
#[cfg(feature = "macros")] | ||
pub use proc_macros; | ||
|
||
/// Common types used to implement JSON RPC server and client. | ||
#[cfg(feature = "macros")] | ||
#[cfg(any(feature = "types", feature = "macros"))] |
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.
👍
@@ -27,4 +27,4 @@ mod tokio; | |||
mod tests; | |||
|
|||
pub use client::{WsClient, WsClientBuilder}; | |||
pub use jsonrpsee_types::*; | |||
pub use jsonrpsee_types as types; |
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.
:+1
* Companion to paritytech/jsonrpsee#409 * Use master
Include the "macros" feature in the the "server" feature so users don't have to import "jsonrpsee-types" explicitly.
Also re-export the
SubscriptionSink
.This is possibly slightly contentious. I think it's fair to assume that people writing servers will want to use the "macros" feature (which implies "types"). The downside of this is that "macros" includes the client side macros and "types" also includes types used in clients more.
Alternative solutions would be
CallError
orSubscriptionSink
(downside: more cfg-fu)<insert-yours />
Fixes #407
Substrate "companion": https://github.com/paritytech/substrate/compare/dp-jsonrpsee-integration-2...dp-tweak-reexports?expand=1