mirror of
https://github.com/bytedance/g3.git
synced 2026-05-19 07:54:33 +00:00
drop Arc in egress path json value
This commit is contained in:
parent
a542b94a53
commit
f4c4cc91c0
4 changed files with 10 additions and 16 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -585,9 +585,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
|||
|
||||
[[package]]
|
||||
name = "erased-serde"
|
||||
version = "0.3.29"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc978899517288e3ebbd1a3bfc1d9537dbb87eeab149e53ea490e63bcdff561a"
|
||||
checksum = "837c0466252947ada828b975e12daf82e18bb5444e4df87be6038d4469e2a3d2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
|
@ -2457,9 +2457,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quinn-proto"
|
||||
version = "0.10.3"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b83c2a964b8b68e6c9c616f09b735b436a78843704fa6979a076073e622f69dc"
|
||||
checksum = "e13f81c9a9d574310b8351f8666f5a93ac3b0069c45c28ad52c10291389a7cf9"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"rand",
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, Context};
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
|
|
@ -208,7 +206,7 @@ impl UserConfig {
|
|||
.parse_json(v)
|
||||
.context(format!("invalid user audit config value for key {k}")),
|
||||
"egress_path" => {
|
||||
self.egress_path_selection = EgressPathSelection::JsonValue(Arc::new(v.clone()));
|
||||
self.egress_path_selection = EgressPathSelection::JsonValue(v.clone());
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(anyhow!("invalid key {k}")),
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, Context};
|
||||
use yaml_rust::{yaml, Yaml};
|
||||
|
|
@ -210,7 +209,7 @@ impl UserConfig {
|
|||
if let Yaml::String(s) = v {
|
||||
let v = serde_json::Value::from_str(s)
|
||||
.map_err(|e| anyhow!("invalid json string value for key {k}: {e}"))?;
|
||||
self.egress_path_selection = EgressPathSelection::JsonValue(Arc::new(v));
|
||||
self.egress_path_selection = EgressPathSelection::JsonValue(v);
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!("invalid json string value for key {k}"))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(feature = "json")]
|
||||
use serde_json::Value;
|
||||
|
|
@ -26,7 +25,7 @@ pub enum EgressPathSelection {
|
|||
Default,
|
||||
Index(usize),
|
||||
#[cfg(feature = "json")]
|
||||
JsonValue(Arc<Value>),
|
||||
JsonValue(Value),
|
||||
}
|
||||
|
||||
impl EgressPathSelection {
|
||||
|
|
@ -51,11 +50,9 @@ impl EgressPathSelection {
|
|||
|
||||
#[cfg(feature = "json")]
|
||||
pub fn select_json_value_by_key(&self, key: &str) -> Option<&Value> {
|
||||
if let EgressPathSelection::JsonValue(v) = self {
|
||||
if let Value::Object(map) = v.as_ref() {
|
||||
if let Some(v) = map.get(key) {
|
||||
return Some(v);
|
||||
}
|
||||
if let EgressPathSelection::JsonValue(Value::Object(map)) = self {
|
||||
if let Some(v) = map.get(key) {
|
||||
return Some(v);
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue