Skip to main content

relay_knowledge/storage/partitioned/
framework.rs

1//! Framework graph routing to the repository shard that owns the selected scope.
2
3use crate::{
4    domain::{FrameworkGraph, FrameworkGraphRequest},
5    storage::{FrameworkGraphStore, StorageFuture},
6};
7
8use super::{
9    PartitionedSqliteKnowledgeStore,
10    routing::{is_missing_code_scope_error, repository_store_for_selector},
11};
12
13impl FrameworkGraphStore for PartitionedSqliteKnowledgeStore {
14    fn search_framework_graph(
15        &self,
16        request: FrameworkGraphRequest,
17    ) -> StorageFuture<'_, FrameworkGraph> {
18        let this = self.clone();
19        Box::pin(async move {
20            if let Some(shard) = repository_store_for_selector(
21                &this.control,
22                &this.catalog,
23                request.repository.clone(),
24            )
25            .await?
26            {
27                return match shard.search_framework_graph(request.clone()).await {
28                    Ok(graph) => Ok(graph),
29                    Err(error) if is_missing_code_scope_error(&error) => {
30                        this.control.search_framework_graph(request).await
31                    }
32                    Err(error) => Err(error),
33                };
34            }
35            this.control.search_framework_graph(request).await
36        })
37    }
38
39    fn search_framework_graph_scope(
40        &self,
41        source_scope: String,
42        request: FrameworkGraphRequest,
43    ) -> StorageFuture<'_, FrameworkGraph> {
44        super::routing::search_framework_graph_scope(self.clone(), source_scope, request)
45    }
46}