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

Commit

Permalink
fix bad naming for namespace header key (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma authored Sep 6, 2023
1 parent a2ee773 commit 125e7a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sqld/src/replication/replica/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Replicator {
fn make_request<T>(&self, msg: T) -> Request<T> {
let mut req = Request::new(msg);
req.metadata_mut().insert_bin(
"x-namespace",
NAMESPACE_METADATA_KEY,
BinaryMetadataValue::from_bytes(&self.namespace[..]),
);

Expand Down
6 changes: 3 additions & 3 deletions sqld/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -78,11 +78,11 @@ fn extract_namespace<T>(
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"))
}
}

0 comments on commit 125e7a1

Please sign in to comment.