(app: &mut App)
| 1909 | } |
| 1910 | |
| 1911 | async fn refresh_providers(app: &mut App) { |
| 1912 | let profiles = if app.providers_v2_enabled { |
| 1913 | let req = openshell_core::proto::ListProviderProfilesRequest { |
| 1914 | limit: 100, |
| 1915 | offset: 0, |
| 1916 | }; |
| 1917 | match tokio::time::timeout( |
| 1918 | Duration::from_secs(5), |
| 1919 | app.client.list_provider_profiles(req), |
| 1920 | ) |
| 1921 | .await |
| 1922 | { |
| 1923 | Ok(Ok(resp)) => resp |
| 1924 | .into_inner() |
| 1925 | .profiles |
| 1926 | .into_iter() |
| 1927 | .map(|profile| (profile.id.clone(), profile)) |
| 1928 | .collect::<HashMap<_, _>>(), |
| 1929 | Ok(Err(e)) => { |
| 1930 | tracing::warn!("failed to list provider profiles: {}", e.message()); |
| 1931 | HashMap::new() |
| 1932 | } |
| 1933 | Err(_) => { |
| 1934 | tracing::warn!("list provider profiles timed out"); |
| 1935 | HashMap::new() |
| 1936 | } |
| 1937 | } |
| 1938 | } else { |
| 1939 | HashMap::new() |
| 1940 | }; |
| 1941 | |
| 1942 | let req = openshell_core::proto::ListProvidersRequest { |
| 1943 | limit: 100, |
| 1944 | offset: 0, |
| 1945 | }; |
| 1946 | let result = tokio::time::timeout(Duration::from_secs(5), app.client.list_providers(req)).await; |
| 1947 | match result { |
| 1948 | Ok(Err(e)) => { |
| 1949 | tracing::warn!("failed to list providers: {}", e.message()); |
| 1950 | } |
| 1951 | Err(_) => { |
| 1952 | tracing::warn!("list providers timed out"); |
| 1953 | } |
| 1954 | Ok(Ok(resp)) => { |
| 1955 | let providers = resp.into_inner().providers; |
| 1956 | app.provider_count = providers.len(); |
| 1957 | app.provider_entries = if app.providers_v2_enabled { |
| 1958 | providers |
| 1959 | .iter() |
| 1960 | .cloned() |
| 1961 | .map(|provider| app::ProviderV2Entry { |
| 1962 | profile: profiles.get(&provider.r#type).cloned(), |
| 1963 | provider, |
| 1964 | }) |
| 1965 | .collect() |
| 1966 | } else { |
| 1967 | Vec::new() |
| 1968 | }; |
no test coverage detected