feat(queue): have the queue service use new storage service correctly
This commit is contained in:
parent
abd55ef419
commit
6624fc57fb
|
|
@ -7,7 +7,7 @@
|
||||||
* Usage: cargo run --bin enqueue_pending_ocr
|
* Usage: cargo run --bin enqueue_pending_ocr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
use tracing::{info, warn, error};
|
use tracing::{info, warn, error};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
@ -17,8 +17,7 @@ use readur::{
|
||||||
db::Database,
|
db::Database,
|
||||||
ocr::queue::OcrQueueService,
|
ocr::queue::OcrQueueService,
|
||||||
services::file_service::FileService,
|
services::file_service::FileService,
|
||||||
storage::factory::create_storage_backend,
|
storage::factory,
|
||||||
storage::StorageConfig,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
@ -34,24 +33,13 @@ async fn main() -> Result<()> {
|
||||||
// Connect to database
|
// Connect to database
|
||||||
let db = Database::new(&config.database_url).await?;
|
let db = Database::new(&config.database_url).await?;
|
||||||
|
|
||||||
// Create file service
|
// Create file service using factory pattern
|
||||||
let storage_config = if config.s3_enabled {
|
let storage_config = factory::storage_config_from_env(&config)
|
||||||
#[cfg(feature = "s3")]
|
.with_context(|| "Failed to create storage configuration from environment")?;
|
||||||
{
|
let file_service = std::sync::Arc::new(
|
||||||
StorageConfig::S3 {
|
FileService::from_config(storage_config, config.upload_path.clone()).await
|
||||||
s3_config: config.s3_config.as_ref().unwrap().clone(),
|
.with_context(|| "Failed to create file service with storage backend")?
|
||||||
fallback_path: Some(config.upload_path.clone()),
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(not(feature = "s3"))]
|
|
||||||
{
|
|
||||||
StorageConfig::Local { upload_path: config.upload_path.clone() }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
StorageConfig::Local { upload_path: config.upload_path.clone() }
|
|
||||||
};
|
|
||||||
let storage_backend = create_storage_backend(storage_config).await?;
|
|
||||||
let file_service = std::sync::Arc::new(FileService::with_storage(config.upload_path.clone(), storage_backend));
|
|
||||||
|
|
||||||
let queue_service = OcrQueueService::new(db.clone(), db.get_pool().clone(), 1, file_service);
|
let queue_service = OcrQueueService::new(db.clone(), db.get_pool().clone(), 1, file_service);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue