"vllm/vscode:/vscode.git/clone" did not exist on "5e5a7eb16f121f05e19c8bdf88247744ab9d1b83"
instances.rs 1.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

//! Instance management functions for the distributed runtime.
//!
//! This module provides functionality to list and manage instances across
//! the entire distributed system, complementing the component-specific
//! instance listing in `component.rs`.

10
11
use std::sync::Arc;

12
13
use crate::component::Instance;
use crate::discovery::{Discovery, DiscoveryQuery};
14

15
16
17
18
19
20
21
22
23
24
25
26
pub async fn list_all_instances(
    discovery_client: Arc<dyn Discovery>,
) -> anyhow::Result<Vec<Instance>> {
    let discovery_instances = discovery_client.list(DiscoveryQuery::AllEndpoints).await?;

    let mut instances: Vec<Instance> = discovery_instances
        .into_iter()
        .filter_map(|di| match di {
            crate::discovery::DiscoveryInstance::Endpoint(instance) => Some(instance),
            _ => None, // Ignore all other variants (ModelCard, etc.)
        })
        .collect();
27

28
    instances.sort();
29
30
31

    Ok(instances)
}