risingwave_frontend/expr/function_impl/
rw_actor_vnodes.rs1use std::sync::Arc;
16
17use risingwave_common::types::JsonbVal;
18use risingwave_expr::{ExprError, Result, capture_context, function};
19use serde_json::json;
20
21use super::context::META_CLIENT;
22use crate::meta_client::FrontendMetaClient;
23
24#[function("rw_actor_vnodes(int4) -> jsonb", volatile)]
25async fn rw_actor_vnodes(actor_id: i32) -> Result<JsonbVal> {
26 rw_actor_vnodes_impl_captured(actor_id).await
27}
28
29#[capture_context(META_CLIENT)]
30async fn rw_actor_vnodes_impl(
31 meta_client: &Arc<dyn FrontendMetaClient>,
32 actor_id: i32,
33) -> Result<JsonbVal> {
34 let vnode_indices = meta_client
35 .get_actor_vnodes((actor_id as u32).into())
36 .await
37 .map_err(|e| ExprError::Internal(e.into()))?;
38
39 Ok(json!(vnode_indices).into())
40}