mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-27 11:51:37 +01:00
refactoring to surrealdb
This commit is contained in:
@@ -60,11 +60,11 @@ pub async fn get_file_handler(
|
||||
// Parse UUID
|
||||
let uuid = Uuid::parse_str(&uuid_str).map_err(|_| FileError::InvalidUuid(uuid_str.clone()))?;
|
||||
|
||||
// Initialize RedisClient
|
||||
let redis_client = RedisClient::new("redis://127.0.0.1/");
|
||||
// Initialize the database client
|
||||
let db_client = SurrealDbClient::new().await.map_err(|e| FileError::PersistError(e.to_string())).unwrap();
|
||||
|
||||
// Retrieve FileInfo
|
||||
let file_info = FileInfo::get(uuid, &redis_client).await?;
|
||||
let file_info = FileInfo::get_by_uuid(uuid, &db_client).await?;
|
||||
|
||||
// Prepare the response JSON
|
||||
let response = json!({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
use axum::{http::StatusCode, response::IntoResponse, Extension, Json};
|
||||
use tracing::{error, info};
|
||||
use crate::{models::ingress_content::{create_ingress_objects, IngressInput}, rabbitmq::publisher::RabbitMQProducer, redis::client::RedisClient};
|
||||
use crate::{models::{file_info::FileError, ingress_content::{create_ingress_objects, IngressInput}}, rabbitmq::publisher::RabbitMQProducer, redis::client::RedisClient, surrealdb::SurrealDbClient};
|
||||
|
||||
pub async fn ingress_handler(
|
||||
Extension(producer): Extension<Arc<RabbitMQProducer>>,
|
||||
@@ -9,9 +9,10 @@ pub async fn ingress_handler(
|
||||
) -> impl IntoResponse {
|
||||
info!("Received input: {:?}", input);
|
||||
|
||||
let db_client = SurrealDbClient::new().await.map_err(|e| FileError::PersistError(e.to_string())).unwrap();
|
||||
let redis_client = RedisClient::new("redis://127.0.0.1/");
|
||||
|
||||
match create_ingress_objects(input, &redis_client).await {
|
||||
match create_ingress_objects(input, &db_client).await {
|
||||
Ok(objects) => {
|
||||
for object in objects {
|
||||
match producer.publish(&object).await {
|
||||
|
||||
Reference in New Issue
Block a user