Skip to content

Commit

Permalink
bugfix: convert metainfo from http style to rpc style (#16)
Browse files Browse the repository at this point in the history
In previous codes, metainfo does not have a uniform style, and it
cannot work properly between different types of service.

We agree to use following rules:

- For RPC, use uppercase letters and `_` as separators when
  transmitting
- For HTTP, use lowercase letters and `-` as separators when
  transmitting
- For both protocols, use RPC style (uppercase with `_`) for storing
  keys of metainfo.

To implement this more elegantly, we defined a trait `Converter` and
use it for converting the key names between transmitting format and
storing format.

Signed-off-by: Yu Li <[email protected]>
  • Loading branch information
yukiiiteru authored Jun 19, 2024
1 parent 50ed98b commit ed502ea
Show file tree
Hide file tree
Showing 6 changed files with 504 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "metainfo"
version = "0.7.10"
version = "0.7.11"
authors = ["Volo Team <[email protected]>"]
edition = "2021"
description = "Transmissing metainfo across components."
Expand Down
4 changes: 2 additions & 2 deletions src/backward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ pub trait Backward {
fn set_backward_transient<K: Into<FastStr>, V: Into<FastStr>>(&mut self, key: K, value: V);
fn set_backward_downstream<K: Into<FastStr>, V: Into<FastStr>>(&mut self, key: K, value: V);

fn strip_rpc_prefix_and_set_backward_downstream<K: Into<FastStr>, V: Into<FastStr>>(
fn strip_rpc_prefix_and_set_backward_downstream<K: AsRef<str>, V: Into<FastStr>>(
&mut self,
key: K,
value: V,
);

fn strip_http_prefix_and_set_backward_downstream<K: Into<FastStr>, V: Into<FastStr>>(
fn strip_http_prefix_and_set_backward_downstream<K: AsRef<str>, V: Into<FastStr>>(
&mut self,
key: K,
value: V,
Expand Down
Loading

0 comments on commit ed502ea

Please sign in to comment.