refactor: db_name -> namespace
Renames all "database name" references to "namespace".pull/24376/head
parent
885c831aff
commit
7badf37250
|
@ -14,7 +14,7 @@ use super::{DmlError, DmlHandler};
|
|||
#[derive(Debug, Clone)]
|
||||
pub enum MockDmlHandlerCall {
|
||||
Dispatch {
|
||||
db_name: String,
|
||||
namespace: String,
|
||||
batches: HashMap<String, MutableBatch>,
|
||||
payload_stats: PayloadStatistics,
|
||||
body_len: usize,
|
||||
|
@ -63,7 +63,7 @@ macro_rules! record_and_return {
|
|||
impl DmlHandler for Arc<MockDmlHandler> {
|
||||
async fn write<'a>(
|
||||
&'a self,
|
||||
db_name: DatabaseName<'_>,
|
||||
namespace: DatabaseName<'_>,
|
||||
batches: HashMap<String, MutableBatch>,
|
||||
payload_stats: PayloadStatistics,
|
||||
body_len: usize,
|
||||
|
@ -72,7 +72,7 @@ impl DmlHandler for Arc<MockDmlHandler> {
|
|||
record_and_return!(
|
||||
self,
|
||||
MockDmlHandlerCall::Dispatch {
|
||||
db_name: db_name.into(),
|
||||
namespace: namespace.into(),
|
||||
batches,
|
||||
payload_stats,
|
||||
body_len,
|
||||
|
|
|
@ -19,13 +19,13 @@ pub struct NopDmlHandler;
|
|||
impl DmlHandler for NopDmlHandler {
|
||||
async fn write<'a>(
|
||||
&'a self,
|
||||
db_name: DatabaseName<'_>,
|
||||
namespace: DatabaseName<'_>,
|
||||
batches: HashMap<String, MutableBatch>,
|
||||
_payload_stats: PayloadStatistics,
|
||||
_body_len: usize,
|
||||
_span_ctx: Option<SpanContext>,
|
||||
) -> Result<(), DmlError> {
|
||||
info!(%db_name, ?batches, "dropping write operation");
|
||||
info!(%namespace, ?batches, "dropping write operation");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,10 @@ pub enum DmlError {
|
|||
/// An abstract handler of [`DmlOperation`] requests.
|
||||
#[async_trait]
|
||||
pub trait DmlHandler: Debug + Send + Sync {
|
||||
/// Write `batches` to `db_name`.
|
||||
/// Write `batches` to `namespace`.
|
||||
async fn write<'a>(
|
||||
&'a self,
|
||||
db_name: DatabaseName<'_>,
|
||||
namespace: DatabaseName<'_>,
|
||||
batches: HashMap<String, MutableBatch>,
|
||||
payload_stats: PayloadStatistics,
|
||||
body_len: usize,
|
||||
|
|
|
@ -171,10 +171,10 @@ where
|
|||
let span_ctx: Option<SpanContext> = req.extensions().get().cloned();
|
||||
|
||||
let account = OrgBucketInfo::try_from(&req)?;
|
||||
let db_name = org_and_bucket_to_database(&account.org, &account.bucket)
|
||||
let namespace = org_and_bucket_to_database(&account.org, &account.bucket)
|
||||
.map_err(OrgBucketError::MappingFail)?;
|
||||
|
||||
trace!(org=%account.org, bucket=%account.bucket, db_name=%db_name, "processing write request");
|
||||
trace!(org=%account.org, bucket=%account.bucket, %namespace, "processing write request");
|
||||
|
||||
// Read the HTTP body and convert it to a str.
|
||||
let body = self.read_body(req).await?;
|
||||
|
@ -194,7 +194,7 @@ where
|
|||
};
|
||||
|
||||
self.dml_handler
|
||||
.write(db_name, batches, stats, body.len(), span_ctx)
|
||||
.write(namespace, batches, stats, body.len(), span_ctx)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
@ -274,7 +274,7 @@ mod tests {
|
|||
use std::{io::Write, iter, sync::Arc};
|
||||
|
||||
use assert_matches::assert_matches;
|
||||
|
||||
|
||||
use flate2::{write::GzEncoder, Compression};
|
||||
use hyper::header::HeaderValue;
|
||||
|
||||
|
@ -359,8 +359,8 @@ mod tests {
|
|||
assert_eq!(calls.len(), 1);
|
||||
|
||||
// Validate the write op
|
||||
assert_matches!(&calls[0], MockDmlHandlerCall::Dispatch{ db_name, body_len, .. } => {
|
||||
assert_eq!(db_name, $want_write_db);
|
||||
assert_matches!(&calls[0], MockDmlHandlerCall::Dispatch{ namespace, body_len, .. } => {
|
||||
assert_eq!(namespace, $want_write_db);
|
||||
assert_eq!(*body_len, want_body_len);
|
||||
})
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue