From 125e7a10524983d362a4f741116d3658abce0409 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Wed, 6 Sep 2023 11:28:54 +0200 Subject: [PATCH] fix bad naming for namespace header key (#656) --- sqld/src/replication/replica/replicator.rs | 4 ++-- sqld/src/rpc/mod.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sqld/src/replication/replica/replicator.rs b/sqld/src/replication/replica/replicator.rs index f6f06679..3c320a7d 100644 --- a/sqld/src/replication/replica/replicator.rs +++ b/sqld/src/replication/replica/replicator.rs @@ -20,7 +20,7 @@ use crate::rpc::replication_log::rpc::{ replication_log_client::ReplicationLogClient, HelloRequest, LogOffset, }; use crate::rpc::replication_log::NEED_SNAPSHOT_ERROR_MSG; -use crate::rpc::NAMESPACE_DOESNT_EXIST; +use crate::rpc::{NAMESPACE_DOESNT_EXIST, NAMESPACE_METADATA_KEY}; use crate::ResetOp; use super::hook::{Frames, InjectorHookCtx}; @@ -129,7 +129,7 @@ impl Replicator { fn make_request(&self, msg: T) -> Request { let mut req = Request::new(msg); req.metadata_mut().insert_bin( - "x-namespace", + NAMESPACE_METADATA_KEY, BinaryMetadataValue::from_bytes(&self.namespace[..]), ); diff --git a/sqld/src/rpc/mod.rs b/sqld/src/rpc/mod.rs index 2011db64..a13301da 100644 --- a/sqld/src/rpc/mod.rs +++ b/sqld/src/rpc/mod.rs @@ -21,7 +21,7 @@ pub mod replication_log_proxy; /// A tonic error code to signify that a namespace doesn't exist. pub const NAMESPACE_DOESNT_EXIST: &str = "NAMESPACE_DOESNT_EXIST"; -pub(crate) const NAMESPACE_METADATA_KEY: &str = "x-namespace"; +pub(crate) const NAMESPACE_METADATA_KEY: &str = "x-namespace-bin"; #[allow(clippy::too_many_arguments)] pub async fn run_rpc_server( @@ -78,11 +78,11 @@ fn extract_namespace( return Ok(Bytes::from_static(DEFAULT_NAMESPACE_NAME.as_bytes())); } - if let Some(namespace) = req.metadata().get_bin("x-namespace") { + if let Some(namespace) = req.metadata().get_bin(NAMESPACE_METADATA_KEY) { namespace .to_bytes() .map_err(|_| Status::invalid_argument("Metadata can't be converted into Bytes")) } else { - Err(Status::invalid_argument("Missing x-namespace metadata")) + Err(Status::invalid_argument("Missing x-namespace-bin metadata")) } }