mirror of https://github.com/buster-so/buster.git
handlers lib
This commit is contained in:
parent
a59e9a26c2
commit
8fedcecd43
|
@ -31,10 +31,6 @@ All PRDs should be stored in the `/prds` directory with the following structure:
|
|||
- `fix_` for bug fixes
|
||||
- `refactor_` for code refactoring
|
||||
- `api_` for API changes
|
||||
Examples:
|
||||
- `feature_user_authentication.md`
|
||||
- `enhancement_query_performance.md`
|
||||
- `api_deployment_alignment.md`
|
||||
|
||||
## Using the Template
|
||||
|
||||
|
@ -112,8 +108,7 @@ The template [template.md](mdc:prds/template.md) provides comprehensive sections
|
|||
|
||||
## Example PRDs
|
||||
Reference these example PRDs for guidance:
|
||||
- @prds/completed/2024/api-deployment-alignment.md
|
||||
- @prds/completed/2024/feature-stored-values.md
|
||||
[template.md](mdc:prds/template.md)
|
||||
|
||||
## Checklist Before Submission
|
||||
- [ ] All template sections completed
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
[workspace]
|
||||
members = [
|
||||
".",
|
||||
"libs/handlers"
|
||||
]
|
||||
|
||||
# Define shared dependencies for all workspace members
|
||||
[workspace.dependencies]
|
||||
anyhow = "1.0.86"
|
||||
chrono = { version = "0.4.38", features = ["serde"] }
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
serde_json = { version = "1.0.117", features = ["preserve_order"] }
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
tracing = "0.1.40"
|
||||
uuid = { version = "1.8", features = ["serde", "v4"] }
|
||||
diesel = { version = "2", features = ["uuid", "chrono", "serde_json", "postgres"] }
|
||||
diesel-async = { version = "0.5.2", features = ["postgres", "bb8"] }
|
||||
|
||||
[package]
|
||||
name = "bi_api"
|
||||
version = "0.0.1"
|
||||
|
@ -7,21 +25,27 @@ default-run = "bi_api"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
# Use workspace dependencies
|
||||
anyhow = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
diesel = { workspace = true }
|
||||
diesel-async = { workspace = true }
|
||||
|
||||
# Local dependencies
|
||||
handlers = { path = "libs/handlers" }
|
||||
|
||||
# Other dependencies specific to the main app
|
||||
arrow = { version = "54.0.0", features = ["json"] }
|
||||
async-compression = { version = "0.4.11", features = ["tokio"] }
|
||||
axum = { version = "0.7.5", features = ["ws"] }
|
||||
base64 = "0.21"
|
||||
bb8-redis = "0.18.0"
|
||||
chrono = { version = "0.4.38", features = ["serde"] }
|
||||
cohere-rust = "0.6.0"
|
||||
diesel = { version = "2", features = [
|
||||
"uuid",
|
||||
"chrono",
|
||||
"serde_json",
|
||||
"postgres",
|
||||
] }
|
||||
diesel-async = { version = "0.5.2", features = ["postgres", "bb8"] }
|
||||
dotenv = "0.15.0"
|
||||
futures = "0.3.30"
|
||||
gcp-bigquery-client = "0.24.1"
|
||||
|
@ -40,8 +64,6 @@ regex = "1.10.6"
|
|||
reqwest = { version = "0.12.4", features = ["json", "stream"] }
|
||||
resend-rs = "0.10.0"
|
||||
sentry = { version = "0.35.0", features = ["tokio", "sentry-tracing"] }
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
serde_json = { version = "1.0.117", features = ["preserve_order"] }
|
||||
serde_urlencoded = "0.7.1"
|
||||
snowflake-api = "0.11.0"
|
||||
sqlparser = { version = "0.53.0", features = ["visitor"] }
|
||||
|
@ -65,7 +87,6 @@ tiberius = { version = "0.12.2", default-features = false, features = [
|
|||
"sql-browser-tokio",
|
||||
] }
|
||||
tiktoken-rs = "0.6.0"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
tokio-stream = "0.1.15"
|
||||
tokio-util = { version = "0.7.11", features = ["compat"] }
|
||||
tower-http = { version = "0.6.2", features = [
|
||||
|
@ -73,10 +94,8 @@ tower-http = { version = "0.6.2", features = [
|
|||
"trace",
|
||||
"compression-gzip",
|
||||
] }
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
url = "2.5.1"
|
||||
uuid = { version = "1.8", features = ["serde", "v4"] }
|
||||
rustls = { version = "0.23", features = ["ring"] }
|
||||
rustls-native-certs = "0.8"
|
||||
tokio-postgres-rustls = "0.13"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
name = "handlers"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
# Use workspace dependencies
|
||||
anyhow = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
diesel = { workspace = true }
|
||||
diesel-async = { workspace = true }
|
||||
|
||||
# Add any handler-specific dependencies here
|
|
@ -0,0 +1,5 @@
|
|||
pub mod messages;
|
||||
pub mod threads;
|
||||
|
||||
// Re-export commonly used types and functions
|
||||
pub use threads::types as thread_types;
|
|
@ -0,0 +1,5 @@
|
|||
pub mod operations;
|
||||
pub mod types;
|
||||
|
||||
// Re-export commonly used items
|
||||
pub use types::{ThreadRequest, ThreadResponse};
|
|
@ -0,0 +1,37 @@
|
|||
use anyhow::Result;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::threads::types::{ThreadRequest, ThreadResponse};
|
||||
|
||||
/// Creates a new thread based on the provided request
|
||||
pub async fn create_thread(request: ThreadRequest) -> Result<ThreadResponse> {
|
||||
// This is a placeholder implementation
|
||||
// You'll need to implement the actual database operations
|
||||
let now = chrono::Utc::now();
|
||||
|
||||
Ok(ThreadResponse {
|
||||
id: Uuid::new_v4(),
|
||||
title: request.title,
|
||||
organization_id: request.organization_id,
|
||||
created_by: request.created_by,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_thread() {
|
||||
let request = ThreadRequest {
|
||||
title: "Test Thread".to_string(),
|
||||
organization_id: Uuid::new_v4(),
|
||||
created_by: Uuid::new_v4(),
|
||||
};
|
||||
|
||||
let result = create_thread(request).await;
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ThreadRequest {
|
||||
pub title: String,
|
||||
pub organization_id: Uuid,
|
||||
pub created_by: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ThreadResponse {
|
||||
pub id: Uuid,
|
||||
pub title: String,
|
||||
pub organization_id: Uuid,
|
||||
pub created_by: Uuid,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
// Add more thread-related types as needed
|
Loading…
Reference in New Issue