MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / refresh_providers

Function refresh_providers

crates/openshell-tui/src/lib.rs:1911–1989  ·  view source on GitHub ↗
(app: &mut App)

Source from the content-addressed store, hash-verified

1909}
1910
1911async 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 };

Callers 2

runFunction · 0.85
refresh_dataFunction · 0.85

Calls 6

provider_nameFunction · 0.85
lenMethod · 0.80
list_providersMethod · 0.45
getMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected