dakera_client/lib.rs
1//! Dakera Rust Client SDK
2//!
3//! A high-level Rust client for interacting with Dakera AI Agent Memory Platform.
4//!
5//! # Quick Start (HTTP)
6//!
7//! ```rust,no_run
8//! use dakera_client::{DakeraClient, UpsertRequest, QueryRequest};
9//!
10//! #[tokio::main]
11//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
12//! // Create a client
13//! let client = DakeraClient::new("http://localhost:3000")?;
14//!
15//! // Check health
16//! let health = client.health().await?;
17//! println!("Server healthy: {}", health.healthy);
18//!
19//! // Upsert vectors
20//! let request = UpsertRequest {
21//! vectors: vec![
22//! dakera_client::Vector {
23//! id: "vec1".to_string(),
24//! values: vec![0.1, 0.2, 0.3, 0.4],
25//! metadata: None,
26//! },
27//! ],
28//! };
29//! client.upsert("my-namespace", request).await?;
30//!
31//! // Query for similar vectors
32//! let query = QueryRequest {
33//! vector: vec![0.1, 0.2, 0.3, 0.4],
34//! top_k: 10,
35//! filter: None,
36//! include_metadata: true,
37//! include_vectors: false,
38//! distance_metric: Default::default(),
39//! consistency: Default::default(),
40//! staleness_config: None,
41//! };
42//! let results = client.query("my-namespace", query).await?;
43//!
44//! for match_ in results.matches {
45//! println!("ID: {}, Score: {}", match_.id, match_.score);
46//! }
47//!
48//! Ok(())
49//! }
50//! ```
51//!
52//! # gRPC Client with Connection Pooling
53//!
54//! Enable the `grpc` feature for high-performance gRPC communication:
55//!
56//! ```rust,ignore
57//! use dakera_client::grpc::{GrpcClient, GrpcClientConfig, GrpcConnectionPool};
58//!
59//! #[tokio::main]
60//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
61//! // Single client with HTTP/2 multiplexing
62//! let config = GrpcClientConfig::default()
63//! .with_endpoint("http://localhost:50051")
64//! .with_concurrency_limit(100);
65//! let client = GrpcClient::connect(config).await?;
66//!
67//! // Or use a connection pool for even higher throughput
68//! let pool = GrpcConnectionPool::new(GrpcClientConfig::default(), 4).await?;
69//! let client = pool.get();
70//!
71//! Ok(())
72//! }
73//! ```
74
75pub mod admin;
76pub mod agents;
77pub mod analytics;
78#[cfg(feature = "http-client")]
79mod client;
80mod error;
81pub mod events;
82pub mod keys;
83pub mod knowledge;
84pub mod memory;
85mod types;
86
87// gRPC client with connection pooling
88#[cfg(feature = "grpc")]
89mod grpc_client;
90#[cfg(feature = "grpc")]
91mod grpc_proto;
92
93pub use events::{DakeraEvent, MemoryEvent, OpStatus, VectorMutationOp};
94
95pub use admin::{
96 BackupInfo, BackupListResponse, CacheStats, ClusterStatus, CreateBackupRequest,
97 CreateBackupResponse, IndexStats, IndexStatsResponse, NodeInfo, NodeListResponse, QuotaConfig,
98 QuotaListResponse, QuotaStatus, RestoreBackupRequest, RestoreBackupResponse, RuntimeConfig,
99 SlowQueryListResponse,
100};
101pub use agents::{AgentStats, AgentSummary};
102pub use analytics::{AnalyticsOverview, LatencyAnalytics, StorageAnalytics, ThroughputAnalytics};
103#[cfg(feature = "http-client")]
104pub use client::{DakeraClient, DakeraClientBuilder};
105pub use error::{ClientError, Result};
106pub use keys::{
107 ApiKeyUsageResponse, CreateKeyRequest, CreateKeyResponse, KeyInfo, ListKeysResponse,
108 RotateKeyResponse,
109};
110pub use knowledge::{
111 AgentNetworkEdge, AgentNetworkInfo, AgentNetworkNode, AgentNetworkStats,
112 CrossAgentNetworkRequest, CrossAgentNetworkResponse, DeduplicateRequest, DeduplicateResponse,
113 FullKnowledgeGraphRequest, KnowledgeEdge, KnowledgeGraphRequest, KnowledgeGraphResponse,
114 KnowledgeNode, SummarizeRequest, SummarizeResponse,
115};
116pub use types::*;
117
118// gRPC exports
119#[cfg(feature = "grpc")]
120pub mod grpc {
121 //! gRPC client with connection pooling for high-performance scenarios.
122 pub use crate::grpc_client::{GrpcClient, GrpcClientConfig, GrpcConnectionPool, PoolStats};
123 pub use crate::grpc_proto::*;
124}
125
126// Re-export reqwest for CLI and other consumers
127#[cfg(feature = "http-client")]
128pub use reqwest;