risingwave_meta_service/
system_params_service.rs1use async_trait::async_trait;
16use risingwave_common::system_param::LICENSE_KEY_KEY;
17use risingwave_meta::controller::system_param::SystemParamsControllerRef;
18use risingwave_pb::meta::system_params_service_server::SystemParamsService;
19use risingwave_pb::meta::{
20 GetSystemParamsRequest, GetSystemParamsResponse, SetSystemParamRequest, SetSystemParamResponse,
21};
22use tonic::{Request, Response, Status};
23
24pub struct SystemParamsServiceImpl {
25 system_params_manager: SystemParamsControllerRef,
26
27 managed_license_key: bool,
29}
30
31impl SystemParamsServiceImpl {
32 pub fn new(
33 system_params_manager: SystemParamsControllerRef,
34 managed_license_key: bool,
35 ) -> Self {
36 Self {
37 system_params_manager,
38 managed_license_key,
39 }
40 }
41}
42
43#[async_trait]
44impl SystemParamsService for SystemParamsServiceImpl {
45 async fn get_system_params(
46 &self,
47 _request: Request<GetSystemParamsRequest>,
48 ) -> Result<Response<GetSystemParamsResponse>, Status> {
49 let params = self.system_params_manager.get_pb_params().await;
50
51 Ok(Response::new(GetSystemParamsResponse {
52 params: Some(params),
53 }))
54 }
55
56 async fn set_system_param(
57 &self,
58 request: Request<SetSystemParamRequest>,
59 ) -> Result<Response<SetSystemParamResponse>, Status> {
60 let req = request.into_inner();
61
62 if self.managed_license_key && req.param == LICENSE_KEY_KEY {
65 return Err(Status::permission_denied(
66 "cannot alter license key manually when \
67 argument `--license-key-path` (or env var `RW_LICENSE_KEY_PATH`) is set, \
68 please update the license key file instead",
69 ));
70 }
71
72 let params = self
73 .system_params_manager
74 .set_param(&req.param, req.value)
75 .await?;
76
77 Ok(Response::new(SetSystemParamResponse {
78 params: Some(params),
79 }))
80 }
81}