Skip to content

Commit 0a23242

Browse files
committed
feat: 补充 Nacos operator switches API mock接口,
1 parent c10f1d9 commit 0a23242

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/openapi/naming/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use crate::openapi::naming::catalog::query_opt_service_list;
33
use crate::openapi::naming::instance::{
44
beat_instance, del_instance, get_instance, get_instance_list, update_instance,
55
};
6-
use crate::openapi::naming::operator::mock_operator_metrics;
6+
use crate::openapi::naming::operator::{
7+
mock_get_switches, mock_operator_metrics, mock_put_switches,
8+
};
79
use crate::openapi::naming::service::{
810
query_service, query_service_list, query_subscribers_list, remove_service, update_service,
911
};
@@ -59,6 +61,14 @@ pub fn naming_v1_route(config: &mut ServiceConfig) {
5961
web::resource("/subscribers").route(web::get().to(query_subscribers_list)),
6062
),
6163
)
62-
.service(scope("/nacos/v1/ns/operator").service(mock_operator_metrics))
64+
.service(
65+
scope("/nacos/v1/ns/operator")
66+
.service(
67+
web::resource("switches")
68+
.route(web::get().to(mock_get_switches))
69+
.route(web::put().to(mock_put_switches)),
70+
)
71+
.service(mock_operator_metrics),
72+
)
6373
.service(scope("/nacos/v1/ns/catalog").service(query_opt_service_list));
6474
}

src/openapi/naming/operator.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use actix_web::{get, web, Responder, Scope};
1+
use actix_web::{get, web, HttpResponse, Responder, Scope};
22

33
pub(super) fn service() -> Scope {
44
web::scope("/operator").service(mock_operator_metrics)
@@ -8,3 +8,13 @@ pub(super) fn service() -> Scope {
88
pub(crate) async fn mock_operator_metrics() -> impl Responder {
99
"{\"status\":\"UP\"}"
1010
}
11+
12+
pub(crate) async fn mock_get_switches() -> impl Responder {
13+
let mock_body: &str ="{\"masters\":null,\"adWeightMap\":{},\"defaultPushCacheMillis\":10000,\"clientBeatInterval\":5000,\"defaultCacheMillis\":3000,\"distroThreshold\":0.7,\"healthCheckEnabled\":true,\"autoChangeHealthCheckEnabled\":true,\"distroEnabled\":true,\"enableStandalone\":true,\"pushEnabled\":true,\"checkTimes\":3,\"httpHealthParams\":{\"max\":5000,\"min\":500,\"factor\":0.85},\"tcpHealthParams\":{\"max\":5000,\"min\":1000,\"factor\":0.75},\"mysqlHealthParams\":{\"max\":3000,\"min\":2000,\"factor\":0.65},\"incrementalList\":[],\"serverStatusSynchronizationPeriodMillis\":2000,\"serviceStatusSynchronizationPeriodMillis\":5000,\"disableAddIP\":false,\"sendBeatOnly\":false,\"lightBeatEnabled\":true,\"limitedUrlMap\":{},\"distroServerExpiredMillis\":10000,\"pushGoVersion\":\"0.1.0\",\"pushJavaVersion\":\"0.1.0\",\"pushPythonVersion\":\"0.4.3\",\"pushCVersion\":\"1.0.12\",\"pushCSharpVersion\":\"0.9.0\",\"enableAuthentication\":false,\"overriddenServerStatus\":null,\"defaultInstanceEphemeral\":true,\"healthCheckWhiteList\":[],\"checksum\":null,\"name\":\"R-NACOS\"}";
14+
HttpResponse::Ok()
15+
.content_type("application/json")
16+
.body(mock_body)
17+
}
18+
pub(crate) async fn mock_put_switches() -> impl Responder {
19+
HttpResponse::Ok().body("ok")
20+
}

0 commit comments

Comments
 (0)