feat: Introduce smart-features Cargo feature to conditionally compile smart note functionalities and their dependencies.

This commit is contained in:
2025-12-26 00:48:03 +01:00
parent c8276ac306
commit c2a324b368
12 changed files with 144 additions and 60 deletions

View File

@@ -1,10 +1,13 @@
#[cfg(feature = "smart-features")]
use notes_infra::factory::{EmbeddingProvider, VectorProvider};
#[derive(Debug, Clone)]
pub struct Config {
pub broker_url: String,
pub database_url: String,
#[cfg(feature = "smart-features")]
pub embedding_provider: EmbeddingProvider,
#[cfg(feature = "smart-features")]
pub vector_provider: VectorProvider,
}
@@ -13,7 +16,9 @@ impl Default for Config {
Self {
broker_url: "nats://localhost:4222".to_string(),
database_url: "sqlite::memory:".to_string(),
#[cfg(feature = "smart-features")]
embedding_provider: EmbeddingProvider::FastEmbed,
#[cfg(feature = "smart-features")]
vector_provider: VectorProvider::Qdrant {
url: "http://localhost:6334".to_string(),
collection: "notes".to_string(),
@@ -26,6 +31,7 @@ impl Config {
pub fn from_env() -> Self {
let _ = dotenvy::dotenv();
#[cfg(feature = "smart-features")]
let embedding_provider = match std::env::var("EMBEDDING_PROVIDER")
.unwrap_or_default()
.as_str()
@@ -33,6 +39,7 @@ impl Config {
_ => EmbeddingProvider::FastEmbed,
};
#[cfg(feature = "smart-features")]
let vector_provider = match std::env::var("VECTOR_PROVIDER")
.unwrap_or_default()
.as_str()
@@ -48,7 +55,9 @@ impl Config {
Self {
broker_url: std::env::var("BROKER_URL").unwrap_or("nats://localhost:4222".to_string()),
database_url: std::env::var("DATABASE_URL").unwrap_or("sqlite::memory:".to_string()),
#[cfg(feature = "smart-features")]
embedding_provider,
#[cfg(feature = "smart-features")]
vector_provider,
}
}