(args: ReindexCacheArgs)
| 39 | } |
| 40 | |
| 41 | pub async fn reindex_cache(args: ReindexCacheArgs) -> Result<(), Report<GraphError>> { |
| 42 | let pool = PostgresStorePool::new( |
| 43 | &args.db_info, |
| 44 | &args.pool_config, |
| 45 | NoTls, |
| 46 | PostgresStoreSettings::default(), |
| 47 | ) |
| 48 | .await |
| 49 | .change_context(GraphError) |
| 50 | .map_err(|report| { |
| 51 | tracing::error!(error = ?report, "Failed to connect to database"); |
| 52 | report |
| 53 | })?; |
| 54 | |
| 55 | let mut store = pool |
| 56 | .acquire(None) |
| 57 | .await |
| 58 | .change_context(GraphError) |
| 59 | .map_err(|report| { |
| 60 | tracing::error!(error = ?report, "Failed to acquire database connection"); |
| 61 | report |
| 62 | })?; |
| 63 | |
| 64 | let mut did_something = false; |
| 65 | |
| 66 | if args.operations.data_types { |
| 67 | did_something = true; |
| 68 | store |
| 69 | .reindex_data_type_cache() |
| 70 | .await |
| 71 | .change_context(GraphError) |
| 72 | .map_err(|report| { |
| 73 | tracing::error!(error = ?report, "Failed to reindex data type cache"); |
| 74 | report |
| 75 | })?; |
| 76 | } |
| 77 | |
| 78 | if args.operations.entity_types { |
| 79 | did_something = true; |
| 80 | store |
| 81 | .reindex_entity_type_cache() |
| 82 | .await |
| 83 | .change_context(GraphError) |
| 84 | .map_err(|report| { |
| 85 | tracing::error!(error = ?report, "Failed to reindex entity type cache"); |
| 86 | report |
| 87 | })?; |
| 88 | } |
| 89 | |
| 90 | if args.operations.entities { |
| 91 | did_something = true; |
| 92 | store |
| 93 | .reindex_entity_cache() |
| 94 | .await |
| 95 | .change_context(GraphError) |
| 96 | .map_err(|report| { |
| 97 | tracing::error!(error = ?report, "Failed to reindex entities cache"); |
| 98 | report |
no test coverage detected