relay_knowledge/storage/contracts/code/
task.rs1use crate::domain::{CodeIndexPublicationFence, CodeIndexTaskQueueStatus, CodeIndexTaskRecord};
2
3use super::super::{StorageError, StorageFuture};
4use super::{
5 CODE_INDEX_TASK_LEASE_RECOVERY_UNAVAILABLE, CODE_INDEX_TASK_LEASE_RENEWAL_UNAVAILABLE,
6 CodeIndexPublicationTarget, CodeIndexTaskClaimRequest, CodeIndexTaskCompletion,
7 CodeIndexTaskFailure, CodeIndexTaskLeaseRecord, CodeIndexTaskLeaseRecovery,
8 CodeIndexTaskLeaseRenewal, CodeIndexTaskSeed,
9};
10
11pub trait CodeIndexTaskStore: Send + Sync {
13 fn queue_code_index_task(
14 &self,
15 task: CodeIndexTaskSeed,
16 ) -> StorageFuture<'_, CodeIndexTaskRecord>;
17
18 fn claim_code_index_task(
19 &self,
20 request: CodeIndexTaskClaimRequest,
21 ) -> StorageFuture<'_, Option<CodeIndexTaskRecord>>;
22
23 fn recover_code_index_task_leases(
24 &self,
25 _now_ms: u64,
26 _max_attempts: u32,
27 ) -> StorageFuture<'_, ()> {
28 Box::pin(async {
29 Err(StorageError::InvalidInput(
30 CODE_INDEX_TASK_LEASE_RECOVERY_UNAVAILABLE.to_owned(),
31 ))
32 })
33 }
34
35 fn running_code_index_task_leases(&self) -> StorageFuture<'_, Vec<CodeIndexTaskLeaseRecord>> {
36 Box::pin(async {
37 Err(StorageError::InvalidInput(
38 "code index task lease inspection is unavailable".to_owned(),
39 ))
40 })
41 }
42
43 fn recover_code_index_task_leases_by_task(
44 &self,
45 _request: CodeIndexTaskLeaseRecovery,
46 ) -> StorageFuture<'_, usize> {
47 Box::pin(async {
48 Err(StorageError::InvalidInput(
49 CODE_INDEX_TASK_LEASE_RECOVERY_UNAVAILABLE.to_owned(),
50 ))
51 })
52 }
53
54 fn reset_code_index_tasks(
55 &self,
56 _repository_id: String,
57 _now_ms: u64,
58 ) -> StorageFuture<'_, Vec<CodeIndexTaskRecord>> {
59 Box::pin(async {
60 Err(StorageError::InvalidInput(
61 "code index task reset is unavailable".to_owned(),
62 ))
63 })
64 }
65
66 fn renew_code_index_task_lease(
67 &self,
68 _request: CodeIndexTaskLeaseRenewal,
69 ) -> StorageFuture<'_, CodeIndexTaskRecord> {
70 Box::pin(async {
71 Err(StorageError::InvalidInput(
72 CODE_INDEX_TASK_LEASE_RENEWAL_UNAVAILABLE.to_owned(),
73 ))
74 })
75 }
76
77 fn complete_code_index_task(
78 &self,
79 request: CodeIndexTaskCompletion,
80 ) -> StorageFuture<'_, CodeIndexTaskRecord>;
81
82 fn run_code_index_post_maintenance(
83 &self,
84 repository_id: String,
85 source_scope: String,
86 ) -> StorageFuture<'_, ()> {
87 Box::pin(async move {
88 Err(StorageError::InvalidInput(format!(
89 "post-index maintenance for repository '{repository_id}' scope '{source_scope}' is unavailable"
90 )))
91 })
92 }
93
94 fn code_index_publication_receipt(
95 &self,
96 task_id: String,
97 _repository_id: String,
98 _source_scope: String,
99 _now_ms: u64,
100 ) -> StorageFuture<'_, bool> {
101 Box::pin(async move {
102 Err(StorageError::InvalidInput(format!(
103 "code index publication receipt for task '{task_id}' is unavailable"
104 )))
105 })
106 }
107
108 fn reconcile_code_index_publication_with_fence(
109 &self,
110 target: CodeIndexPublicationTarget,
111 _fence: CodeIndexPublicationFence,
112 ) -> StorageFuture<'_, bool> {
113 Box::pin(async move {
114 Err(StorageError::InvalidInput(format!(
115 "code index publication reconciliation for task '{}' is unavailable",
116 target.task_id
117 )))
118 })
119 }
120
121 fn fail_code_index_task(
122 &self,
123 request: CodeIndexTaskFailure,
124 ) -> StorageFuture<'_, CodeIndexTaskRecord>;
125
126 fn code_index_task(&self, task_id: String) -> StorageFuture<'_, Option<CodeIndexTaskRecord>>;
127
128 fn active_code_index_task(
129 &self,
130 repository_id: String,
131 ) -> StorageFuture<'_, Option<CodeIndexTaskRecord>>;
132
133 fn code_index_task_queue_status(&self) -> StorageFuture<'_, CodeIndexTaskQueueStatus> {
134 Box::pin(async {
135 Err(StorageError::InvalidInput(
136 "code index task queue status is unavailable".to_owned(),
137 ))
138 })
139 }
140}