This commit is contained in:
Krishan Mistry 2023-08-30 14:32:54 +01:00
Родитель c250a67a9e
Коммит 2951b13853
5 изменённых файлов: 25 добавлений и 64 удалений

Просмотреть файл

@ -6,18 +6,18 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
uuid = {version = "1", features = ["v4", "serde"]}
serde = { version = "1", features = ["serde_derive"] }
serde_json = "1"
url = "2"
azure-kusto-data = {path = "../azure-kusto-data"}
anyhow = "1.0.72"
tokio = { version = "1", features = ["full"] }
# Azure SDK for Rust crates versions should be kept in sync
azure_core = "0.14"
azure_storage = "0.14"
azure_storage_blobs = "0.14"
azure_storage_queues = "0.14"
azure_core = "0.13"
azure_storage = "0.13"
azure_storage_blobs = "0.13"
azure_storage_queues = "0.13"
anyhow = "1"
chrono = { version = "0.4", features = ["serde"] }
rand = "0.8"
serde = { version = "1", features = ["serde_derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
url = "2"
uuid = {version = "1", features = ["v4", "serde"]}

Просмотреть файл

@ -2,7 +2,7 @@ use serde::Serialize;
/// All data formats supported by Kusto
/// Default is [DataFormat::CSV]
#[derive(Serialize, Clone, Debug, Default)]
#[derive(Serialize, Clone, Debug, Default, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum DataFormat {
ApacheAvro,
@ -24,3 +24,14 @@ pub enum DataFormat {
TXT,
W3CLOGFILE,
}
// Unit tests
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn data_format_default() {
assert_eq!(DataFormat::default(), DataFormat::CSV);
}
}

Просмотреть файл

@ -5,4 +5,3 @@ pub(crate) mod ingestion_blob_info;
pub mod ingestion_properties;
pub mod queued_ingest;
pub(crate) mod resource_manager;
pub(crate) mod result;

Просмотреть файл

@ -10,7 +10,6 @@ use crate::descriptors::BlobDescriptor;
use crate::ingestion_blob_info::QueuedIngestionMessage;
use crate::ingestion_properties::IngestionProperties;
use crate::resource_manager::ResourceManager;
use crate::result::{IngestionResult, IngestionStatus};
/// Client for ingesting data into Kusto using the queued flavour of ingestion
#[derive(Clone)]
@ -43,7 +42,7 @@ impl QueuedIngestClient {
&self,
blob_descriptor: BlobDescriptor,
ingestion_properties: IngestionProperties,
) -> Result<IngestionResult> {
) -> Result<()> {
// The queues returned here should ideally be the storage queue client from azure-storage-queue
// As such, it may be better for ResourceManager to return a struct that contains the storage queue client
let ingestion_queues = self
@ -76,12 +75,6 @@ impl QueuedIngestClient {
let _resp = queue_client.put_message(message).await?;
// println!("resp: {:#?}\n", resp);
Ok(IngestionResult {
status: IngestionStatus::Queued,
database: ingestion_properties.database_name,
table: ingestion_properties.table_name,
source_id: blob_descriptor.source_id,
blob_uri: Some(blob_descriptor.uri()),
})
Ok(())
}
}

Просмотреть файл

@ -1,42 +0,0 @@
use uuid::Uuid;
#[derive(Debug)]
pub enum IngestionStatus {
// The ingestion was queued.
Queued,
// The ingestion was successfully streamed
Success,
}
// The result of an ingestion.
#[derive(Debug)]
pub struct IngestionResult {
// Will be `Queued` if the ingestion is queued, or `Success` if the ingestion is streaming and successful.
pub status: IngestionStatus,
// The name of the database where the ingestion was performed.
pub database: String,
// The name of the table where the ingestion was performed.
pub table: String,
// The source id of the ingestion.
pub source_id: Uuid,
// The blob uri of the ingestion, if exists.
pub blob_uri: Option<String>,
}
impl IngestionResult {
pub fn new(
status: IngestionStatus,
database: &str,
table: &str,
source_id: Uuid,
blob_uri: Option<String>,
) -> Self {
Self {
status,
database: database.to_owned(),
table: table.to_owned(),
source_id,
blob_uri,
}
}
}