Skip to content

Commit 2e025b2

Browse files
committed
support to change background color. Set default qps to 100.
1 parent fb211b0 commit 2e025b2

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

mse-simple-demo/gateway/src/main/java/com/alibabacloud/mse/demo/DemoController.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
public class DemoController {
2020

2121

22-
@Value("${demo.qps:10}")
22+
@Value("${demo.qps:100}")
2323
private int qps;
2424

25+
@Value("${background.color:white}")
26+
private String backgroundColor;
27+
2528
private static final ScheduledExecutorService FLOW_EXECUTOR = Executors.newScheduledThreadPool(2,
2629
new ThreadFactory() {
30+
31+
@Override
2732
public Thread newThread(Runnable r) {
2833
Thread thread = new Thread(r);
2934
thread.setDaemon(true);
@@ -32,13 +37,15 @@ public Thread newThread(Runnable r) {
3237
}
3338
});
3439

35-
@GetMapping("/demo")
40+
@GetMapping("/")
3641
public String index(Model model) {
42+
model.addAttribute("backgroundColor", backgroundColor);
3743
return "index";
3844
}
3945

4046
@PostConstruct
4147
private void flow() {
48+
4249
FLOW_EXECUTOR.scheduleAtFixedRate(new Runnable() {
4350
@Override
4451
public void run() {
@@ -52,12 +59,15 @@ public void run() {
5259
}
5360
}, 100, 1000000 / qps, TimeUnit.MICROSECONDS);
5461

62+
63+
5564
FLOW_EXECUTOR.scheduleAtFixedRate(new Runnable() {
5665
@Override
5766
public void run() {
5867

5968
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
60-
HttpGet httpGet = new HttpGet("http://localhost:20000/A/a?name=xiaoming");
69+
HttpGet httpGet = new HttpGet("http://localhost:20000/A/a");
70+
httpGet.addHeader("x-mse-tag", "gray");
6171
httpClient.execute(httpGet);
6272

6373
} catch (Exception ignore) {

mse-simple-demo/gateway/src/main/java/com/alibabacloud/mse/demo/ZuulApplication.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
import org.springframework.boot.autoconfigure.SpringBootApplication;
2121
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
2222

23-
/**
24-
* @author <a href="mailto:[email protected]">Jim</a>
25-
*/
2623
@SpringBootApplication
2724
@EnableZuulProxy
2825
public class ZuulApplication {

mse-simple-demo/gateway/src/main/resources/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
2-
<html>
2+
<html xmlns:th="http://www.w3.org/1999/xhtml">
33
<head>
44
<meta http-equiv="content-type" content="text/html; charset=utf-8">
55
<title></title>
66
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
77
</head>
8-
<body>
8+
<body th:style="${'background-color:' + backgroundColor }">
99
<div style="margin: 30px auto 0 30px;">
1010
<div id="inputSection">
1111
<label>请输入网址:</label>

0 commit comments

Comments
 (0)