mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 06:13:14 +00:00
perf(protos): cache internode msgpack-only flag (#5191)
Cache the internode msgpack-only env gate after the first read so metadata RPC send paths avoid repeated environment parsing. Keep a reset hook for tests that intentionally change the env in-process. Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -1215,9 +1215,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
fn with_internode_msgpack_env<R>(vars: [(&'static str, Option<&'static str>); 2], f: impl FnOnce() -> R) -> R {
|
||||
temp_env::with_vars(vars, || {
|
||||
rustfs_protos::reset_internode_rpc_msgpack_only_cache();
|
||||
let result = f();
|
||||
rustfs_protos::reset_internode_rpc_msgpack_only_cache();
|
||||
result
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compat_response_json_keeps_json_when_msgpack_only_lacks_fleet_confirmation() {
|
||||
temp_env::with_vars(
|
||||
with_internode_msgpack_env(
|
||||
[
|
||||
(rustfs_config::ENV_INTERNODE_RPC_MSGPACK_ONLY, Some("true")),
|
||||
(rustfs_config::ENV_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED, None::<&str>),
|
||||
@@ -1237,7 +1246,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn compat_response_json_omits_json_only_after_fleet_confirmation() {
|
||||
temp_env::with_vars(
|
||||
with_internode_msgpack_env(
|
||||
[
|
||||
(rustfs_config::ENV_INTERNODE_RPC_MSGPACK_ONLY, Some("true")),
|
||||
(rustfs_config::ENV_INTERNODE_RPC_MSGPACK_ONLY_FLEET_CONFIRMED, Some("true")),
|
||||
|
||||
Reference in New Issue
Block a user