Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Risingwavelabs Risingwave Cluster API

From Leeroopedia


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

dashboard/lib/api/cluster.ts

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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment