Implementation:Risingwavelabs Risingwave Cluster API: Difference between revisions
Auto-imported from implementations/Risingwavelabs_Risingwave_Cluster_API.md |
Sync from local file |
||
| Line 142: | Line 142: | ||
== Related Pages == | == Related Pages == | ||
* [[Risingwavelabs_Risingwave_Dashboard_API_Client]] - The underlying HTTP client used by all cluster API functions | * [[Implementation:Risingwavelabs_Risingwave_Dashboard_API_Client]] - The underlying HTTP client used by all cluster API functions | ||
* [[Risingwavelabs_Risingwave_Cluster_Page]] - The dashboard page that consumes these cluster API functions | * [[Implementation:Risingwavelabs_Risingwave_Cluster_Page]] - The dashboard page that consumes these cluster API functions | ||
* [[Risingwavelabs_Risingwave_Await_Tree_Page]] - Uses <code>getClusterInfoComputeNode</code> to populate the compute node selector | * [[Implementation:Risingwavelabs_Risingwave_Await_Tree_Page]] - Uses <code>getClusterInfoComputeNode</code> to populate the compute node selector | ||
* [[Risingwavelabs_Risingwave_UseFetch_Hook]] - The React hook commonly used to call these functions from components | * [[Implementation:Risingwavelabs_Risingwave_UseFetch_Hook]] - The React hook commonly used to call these functions from components | ||
[[Category:Implementations]] | [[Category:Implementations]] | ||
[[Category:Implementations]] | [[Category:Implementations]] | ||
Latest revision as of 10:50, 27 September 2026
| Property | Value |
|---|---|
| Module | Cluster API Functions |
| File | dashboard/lib/api/cluster.ts
|
| Language | TypeScript |
| Lines | 58 |
| Type | API Function Module |
| Dependencies | api.ts, proto/gen/common (WorkerNode) |
Overview
cluster.ts provides API functions for fetching cluster topology information, including worker nodes by type and the cluster version. The module exports functions that call the /clusters/{type} endpoint with numeric type codes (1=Frontend, 2=ComputeNode, 4=Compactor) and deserialize responses into WorkerNode protobuf objects. The getClusterInfoProfileWorkers function aggregates all worker types using Promise.all. This module powers the Cluster Overview page and heap profiling page in the dashboard, providing visibility into the distributed cluster topology.
Code Reference
Source Location
Signature
export async function getClusterMetrics(): Promise<any>
export async function getClusterInfoFrontend(): Promise<WorkerNode[]>
export async function getClusterInfoComputeNode(): Promise<WorkerNode[]>
export async function getClusterInfoCompactor(): Promise<WorkerNode[]>
export async function getClusterInfoProfileWorkers(): Promise<WorkerNode[]>
export async function getClusterVersion(): Promise<any>
Import
import {
getClusterMetrics,
getClusterInfoFrontend,
getClusterInfoComputeNode,
getClusterInfoCompactor,
getClusterInfoProfileWorkers,
getClusterVersion,
} from "../lib/api/cluster"
I/O Contract
Worker Node Type Codes
| Function | API Path | Type Code | Description |
|---|---|---|---|
getClusterInfoFrontend |
/clusters/1 |
1 | Fetches all frontend worker nodes |
getClusterInfoComputeNode |
/clusters/2 |
2 | Fetches all compute worker nodes |
getClusterInfoCompactor |
/clusters/4 |
4 | Fetches all compactor worker nodes |
getClusterMetrics
| Parameter | Type | Description |
|---|---|---|
| (none) | Fetches from /metrics/cluster
| |
| Returns | Promise<any> |
Raw cluster metrics response (CPU and memory data) |
getClusterInfoProfileWorkers
| Parameter | Type | Description |
|---|---|---|
| (none) | Fetches all three worker types concurrently | |
| Returns | Promise<WorkerNode[]> |
Combined array of compute, frontend, and compactor nodes |
getClusterVersion
| Parameter | Type | Description |
|---|---|---|
| (none) | Fetches from /version
| |
| Returns | Promise<any> |
The cluster version string |
Usage Examples
Fetching Cluster Nodes
import { getClusterInfoFrontend, getClusterInfoComputeNode } from "../lib/api/cluster"
const frontends = await getClusterInfoFrontend()
const computeNodes = await getClusterInfoComputeNode()
frontends.forEach((node) => {
console.log(`Frontend #${node.id}: ${node.host?.host}:${node.host?.port}`)
})
Aggregating All Workers
import { getClusterInfoProfileWorkers } from "../lib/api/cluster"
// Fetches compute, frontend, and compactor nodes concurrently
const allWorkers = await getClusterInfoProfileWorkers()
// Returns: [...computeNodes, ...frontendNodes, ...compactorNodes]
Used in useFetch Hook
import useFetch from "../lib/api/fetch"
import { getClusterInfoComputeNode } from "../lib/api/cluster"
// In a React component:
const { response: computeNodes } = useFetch(getClusterInfoComputeNode)
Related Pages
- Implementation:Risingwavelabs_Risingwave_Dashboard_API_Client - The underlying HTTP client used by all cluster API functions
- Implementation:Risingwavelabs_Risingwave_Cluster_Page - The dashboard page that consumes these cluster API functions
- Implementation:Risingwavelabs_Risingwave_Await_Tree_Page - Uses
getClusterInfoComputeNodeto populate the compute node selector - Implementation:Risingwavelabs_Risingwave_UseFetch_Hook - The React hook commonly used to call these functions from components