haste_repository/
failed_indexing.rs1use crate::types::FHIRMethod;
2use haste_fhir_operation_error::OperationOutcomeError;
3use haste_jwt::{ProjectId, TenantId, VersionId};
4use sqlx::types::time::OffsetDateTime;
5
6#[derive(Clone, Debug)]
10pub struct FailedIndexRecord {
11 pub tenant: TenantId,
12 pub project: ProjectId,
13 pub version_id: VersionId,
14 pub resource_type: String,
15 pub fhir_method: FHIRMethod,
16 pub error_message: String,
17}
18
19#[derive(sqlx::FromRow, Clone, Debug)]
23pub struct FailedIndexEntry {
24 pub id: String,
25 pub version_id: String,
26 pub resource_type: String,
27 pub fhir_method: FHIRMethod,
28 pub sequence: i64,
31 pub attempt_count: i32,
32 pub error_message: String,
33 pub first_failed_at: OffsetDateTime,
34 pub last_failed_at: OffsetDateTime,
35 pub resolved_at: Option<OffsetDateTime>,
36}
37
38pub trait FailedIndexingProvider {
39 fn record_failures(
43 &self,
44 failures: &[FailedIndexRecord],
45 ) -> impl std::future::Future<Output = Result<(), OperationOutcomeError>> + Send;
46
47 fn search(
50 &self,
51 tenant: &TenantId,
52 project: &ProjectId,
53 ) -> impl std::future::Future<Output = Result<Vec<FailedIndexEntry>, OperationOutcomeError>> + Send;
54}