Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 125e7a1

Browse files
authored
fix bad naming for namespace header key (#656)
1 parent a2ee773 commit 125e7a1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sqld/src/replication/replica/replicator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::rpc::replication_log::rpc::{
2020
replication_log_client::ReplicationLogClient, HelloRequest, LogOffset,
2121
};
2222
use crate::rpc::replication_log::NEED_SNAPSHOT_ERROR_MSG;
23-
use crate::rpc::NAMESPACE_DOESNT_EXIST;
23+
use crate::rpc::{NAMESPACE_DOESNT_EXIST, NAMESPACE_METADATA_KEY};
2424
use crate::ResetOp;
2525

2626
use super::hook::{Frames, InjectorHookCtx};
@@ -129,7 +129,7 @@ impl Replicator {
129129
fn make_request<T>(&self, msg: T) -> Request<T> {
130130
let mut req = Request::new(msg);
131131
req.metadata_mut().insert_bin(
132-
"x-namespace",
132+
NAMESPACE_METADATA_KEY,
133133
BinaryMetadataValue::from_bytes(&self.namespace[..]),
134134
);
135135

sqld/src/rpc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub mod replication_log_proxy;
2121

2222
/// A tonic error code to signify that a namespace doesn't exist.
2323
pub const NAMESPACE_DOESNT_EXIST: &str = "NAMESPACE_DOESNT_EXIST";
24-
pub(crate) const NAMESPACE_METADATA_KEY: &str = "x-namespace";
24+
pub(crate) const NAMESPACE_METADATA_KEY: &str = "x-namespace-bin";
2525

2626
#[allow(clippy::too_many_arguments)]
2727
pub async fn run_rpc_server(
@@ -78,11 +78,11 @@ fn extract_namespace<T>(
7878
return Ok(Bytes::from_static(DEFAULT_NAMESPACE_NAME.as_bytes()));
7979
}
8080

81-
if let Some(namespace) = req.metadata().get_bin("x-namespace") {
81+
if let Some(namespace) = req.metadata().get_bin(NAMESPACE_METADATA_KEY) {
8282
namespace
8383
.to_bytes()
8484
.map_err(|_| Status::invalid_argument("Metadata can't be converted into Bytes"))
8585
} else {
86-
Err(Status::invalid_argument("Missing x-namespace metadata"))
86+
Err(Status::invalid_argument("Missing x-namespace-bin metadata"))
8787
}
8888
}

0 commit comments

Comments
 (0)