LCOV - code coverage report
Current view: top level - pageserver/client/src/mgmt_api - util.rs (source / functions) Coverage Total Hit
Test: 20b6afc7b7f34578dcaab2b3acdaecfe91cd8bf1.info Lines: 0.0 % 38 0
Test Date: 2024-11-25 17:48:16 Functions: 0.0 % 3 0

            Line data    Source code
       1              : //! Helpers to do common higher-level tasks with the [`Client`].
       2              : 
       3              : use std::sync::Arc;
       4              : 
       5              : use pageserver_api::shard::TenantShardId;
       6              : use tokio::task::JoinSet;
       7              : use utils::id::{TenantId, TenantTimelineId};
       8              : 
       9              : use super::Client;
      10              : 
      11              : /// Retrieve a list of all of the pageserver's timelines.
      12              : ///
      13              : /// Fails if there are sharded tenants present on the pageserver.
      14            0 : pub async fn get_pageserver_tenant_timelines_unsharded(
      15            0 :     api_client: &Arc<Client>,
      16            0 : ) -> anyhow::Result<Vec<TenantTimelineId>> {
      17            0 :     let mut timelines: Vec<TenantTimelineId> = Vec::new();
      18            0 :     let mut tenants: Vec<TenantId> = Vec::new();
      19            0 :     for ti in api_client.list_tenants().await? {
      20            0 :         if !ti.id.is_unsharded() {
      21            0 :             anyhow::bail!(
      22            0 :                 "only unsharded tenants are supported at this time: {}",
      23            0 :                 ti.id
      24            0 :             );
      25            0 :         }
      26            0 :         tenants.push(ti.id.tenant_id)
      27              :     }
      28            0 :     let mut js = JoinSet::new();
      29            0 :     for tenant_id in tenants {
      30            0 :         js.spawn({
      31            0 :             let mgmt_api_client = Arc::clone(api_client);
      32            0 :             async move {
      33            0 :                 (
      34            0 :                     tenant_id,
      35            0 :                     mgmt_api_client
      36            0 :                         .tenant_details(TenantShardId::unsharded(tenant_id))
      37            0 :                         .await
      38            0 :                         .unwrap(),
      39            0 :                 )
      40            0 :             }
      41            0 :         });
      42            0 :     }
      43            0 :     while let Some(res) = js.join_next().await {
      44            0 :         let (tenant_id, details) = res.unwrap();
      45            0 :         for timeline_id in details.timelines {
      46            0 :             timelines.push(TenantTimelineId {
      47            0 :                 tenant_id,
      48            0 :                 timeline_id,
      49            0 :             });
      50            0 :         }
      51              :     }
      52            0 :     Ok(timelines)
      53            0 : }
        

Generated by: LCOV version 2.1-beta