Support marking RPC methods as #[deprecated]#59
Conversation
Compile-time warnings for proxy callers, server-side logging on dispatch, and an rpc.deprecatedMethods introspection endpoint.
5637420 to
8f68ef1
Compare
|
|
||
| #[nimiq_jsonrpc_derive::service(rename_all = "camelCase")] | ||
| #[allow(dead_code)] | ||
| impl TestService { |
There was a problem hiding this comment.
Your deprecation implementation only works for inherent impls:
impl TestService {}
But not for trait impls
impl ConsensusInterface for ConsensusDispatcher {} (an example we use downstream for core-rs-ablatross). This is because Rust rejects #[deprecated] on trait-method impls I believe.
|
|
||
| /// Extracts the optional `note` from a `#[deprecated]` attribute in any of its supported forms: | ||
| /// `#[deprecated]`, `#[deprecated = "..."]`, or `#[deprecated(note = "...", since = "...")]`. | ||
| fn parse_deprecation(attr: &Attribute) -> Deprecation { |
There was a problem hiding this comment.
#[deprecated(since = "1.0", note = "use foo")] would create a server log without the actual note. Because the since key is not consumed, a syn error is swallowed by the let _ = and the loop never reaches the note.
So now it would depend on the order you write note and since.
| } | ||
|
|
||
| #[::async_trait::async_trait] | ||
| #[allow(deprecated)] |
There was a problem hiding this comment.
A downstream crate with #![deny(deprecated)] or deny(warnings)) now would suddenly fail to compile?
| // Built-in introspection methods (the `rpc.` prefix is reserved by the JSON-RPC spec for | ||
| // these kinds of system extensions). They let any client discover which methods exist and, | ||
| // in particular, which ones are deprecated, so the client can report deprecated usage. | ||
| if request.method == "rpc.methods" || request.method == "rpc.deprecatedMethods" { |
Compile-time warnings for proxy callers, server-side logging on dispatch, and an rpc.deprecatedMethods introspection endpoint.