• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4113913291

pending completion
4113913291

Pull #821

github

GitHub
Merge a8cca3f0b into 8f74ec17e
Pull Request #821: refactor: Make `LmdbRoCache` and `LmdbRwCache` `Send` and `Sync`

869 of 869 new or added lines in 45 files covered. (100.0%)

23486 of 37503 relevant lines covered (62.62%)

36806.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.24
/dozer-api/src/rest/api_generator.rs
1
use actix_web::web::ReqData;
2
use actix_web::{web, HttpResponse};
3
use dozer_cache::cache::expression::{default_limit_for_query, QueryExpression};
4
use dozer_types::log::info;
5

6
use super::super::api_helper::ApiHelper;
7
use crate::grpc::health_grpc::health_check_response::ServingStatus;
8
use crate::{auth::Access, errors::ApiError, PipelineDetails};
9
use dozer_cache::errors::CacheError;
10
use dozer_types::serde_json;
11
use dozer_types::serde_json::{json, Value};
12

13
/// Generated function to return openapi.yaml documentation.
14
pub async fn generate_oapi(
×
15
    access: Option<ReqData<Access>>,
×
16
    pipeline_details: ReqData<PipelineDetails>,
×
17
) -> Result<HttpResponse, ApiError> {
×
18
    let helper = ApiHelper::new(&pipeline_details, access.map(|a| a.into_inner()))?;
×
19

20
    helper
×
21
        .generate_oapi3()
×
22
        .map(|result| HttpResponse::Ok().json(result))
×
23
}
×
24

25
// Generated Get function to return a single record in JSON format
26
pub async fn get(
1✔
27
    access: Option<ReqData<Access>>,
1✔
28
    pipeline_details: ReqData<PipelineDetails>,
1✔
29
    path: web::Path<String>,
1✔
30
) -> Result<HttpResponse, ApiError> {
1✔
31
    let helper = ApiHelper::new(&pipeline_details, access.map(|a| a.into_inner()))?;
1✔
32
    let key = path.as_str();
1✔
33
    helper
1✔
34
        .get_record(key)
1✔
35
        .map(|map| HttpResponse::Ok().json(map))
1✔
36
        .map_err(ApiError::NotFound)
1✔
37
}
1✔
38

39
// Generated list function for multiple records with a default query expression
40
pub async fn list(
3✔
41
    access: Option<ReqData<Access>>,
3✔
42
    pipeline_details: ReqData<PipelineDetails>,
3✔
43
) -> Result<HttpResponse, ApiError> {
3✔
44
    let helper = ApiHelper::new(&pipeline_details, access.map(|a| a.into_inner()))?;
3✔
45
    let exp = QueryExpression::new(None, vec![], Some(50), 0);
3✔
46
    match helper
3✔
47
        .get_records_map(exp)
3✔
48
        .map(|maps| HttpResponse::Ok().json(maps))
3✔
49
    {
50
        Ok(res) => Ok(res),
3✔
51
        Err(e) => match e {
×
52
            CacheError::Query(_) => {
53
                let res: Vec<String> = vec![];
×
54
                info!("No records found.");
×
55
                Ok(HttpResponse::Ok().json(res))
×
56
            }
57
            _ => Err(ApiError::InternalError(Box::new(e))),
×
58
        },
59
    }
60
}
3✔
61

62
// Generated get function for health check
63
pub async fn health_route() -> Result<HttpResponse, ApiError> {
×
64
    let status = ServingStatus::Serving;
×
65
    let resp = json!({ "status": status.as_str_name() }).to_string();
×
66
    Ok(HttpResponse::Ok().body(resp))
×
67
}
×
68

69
pub async fn count(
5✔
70
    access: Option<ReqData<Access>>,
5✔
71
    pipeline_details: ReqData<PipelineDetails>,
5✔
72
    query_info: Option<web::Json<Value>>,
5✔
73
) -> Result<HttpResponse, ApiError> {
5✔
74
    let query_expression = match query_info {
5✔
75
        Some(query_info) => serde_json::from_value::<QueryExpression>(query_info.0)
4✔
76
            .map_err(ApiError::map_deserialization_error)?,
4✔
77
        None => QueryExpression::with_no_limit(),
1✔
78
    };
79

80
    let helper = ApiHelper::new(&pipeline_details, access.map(|a| a.into_inner()))?;
5✔
81
    helper
5✔
82
        .get_records_count(query_expression)
5✔
83
        .map(|count| HttpResponse::Ok().json(count))
5✔
84
        .map_err(|e| match e {
5✔
85
            CacheError::QueryValidation(e) => ApiError::InvalidQuery(e),
×
86
            CacheError::Type(e) => ApiError::TypeError(e),
×
87
            CacheError::Internal(e) => ApiError::InternalError(e),
×
88
            e => ApiError::InternalError(Box::new(e)),
×
89
        })
5✔
90
}
5✔
91

92
// Generated query function for multiple records
93
pub async fn query(
5✔
94
    access: Option<ReqData<Access>>,
5✔
95
    pipeline_details: ReqData<PipelineDetails>,
5✔
96
    query_info: Option<web::Json<Value>>,
5✔
97
) -> Result<HttpResponse, ApiError> {
5✔
98
    let mut query_expression = match query_info {
5✔
99
        Some(query_info) => serde_json::from_value::<QueryExpression>(query_info.0)
4✔
100
            .map_err(ApiError::map_deserialization_error)?,
4✔
101
        None => QueryExpression::with_default_limit(),
1✔
102
    };
103
    if query_expression.limit.is_none() {
5✔
104
        query_expression.limit = Some(default_limit_for_query());
3✔
105
    }
3✔
106
    let helper = ApiHelper::new(&pipeline_details, access.map(|a| a.into_inner()))?;
5✔
107
    helper
5✔
108
        .get_records_map(query_expression)
5✔
109
        .map(|maps| HttpResponse::Ok().json(maps))
5✔
110
        .map_err(|e| match e {
5✔
111
            CacheError::QueryValidation(e) => ApiError::InvalidQuery(e),
×
112
            CacheError::Type(e) => ApiError::TypeError(e),
×
113
            CacheError::Internal(e) => ApiError::InternalError(e),
×
114
            e => ApiError::InternalError(Box::new(e)),
×
115
        })
5✔
116
}
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc