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

Rexport types for servers #409

Merged
merged 11 commits into from
Jul 12, 2021
Merged

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Jul 9, 2021

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

  • include the "types" feature in "server" instead (downside: you get both client and server types)
  • granularly re-export common types like CallError or SubscriptionSink (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

@dvdplm dvdplm self-assigned this Jul 9, 2021
@dvdplm dvdplm requested a review from maciejhirsz July 9, 2021 11:57
@@ -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"]
Copy link
Member

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?

Copy link
Contributor Author

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.

@@ -20,6 +20,6 @@ types = { path = "../types", version = "0.2.0", package = "jsonrpsee-types", opt

[features]
client = ["http-client", "ws-client"]
Copy link
Member

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

Copy link
Member

@niklasad1 niklasad1 left a 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
dvdplm added a commit to paritytech/substrate that referenced this pull request Jul 9, 2021
@dvdplm dvdplm marked this pull request as ready for review July 9, 2021 19:21
@dvdplm dvdplm requested a review from niklasad1 July 9, 2021 19:21
@@ -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::*;
Copy link
Contributor

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?

Copy link
Contributor Author

@dvdplm dvdplm Jul 10, 2021

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"))]
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

:+1

@dvdplm dvdplm merged commit 0592442 into master Jul 12, 2021
@dvdplm dvdplm deleted the dp-expose-more-types-in-facade-crate branch July 12, 2021 08:43
@dvdplm dvdplm restored the dp-expose-more-types-in-facade-crate branch July 12, 2021 08:59
dvdplm added a commit to paritytech/substrate that referenced this pull request Jul 12, 2021
@niklasad1 niklasad1 deleted the dp-expose-more-types-in-facade-crate branch August 5, 2022 08:19
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.

Access CallError without macros
3 participants