Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshlong/ae16d649f44cbcf4d509493ac1e15132 to your computer and use it in GitHub Desktop.
Save joshlong/ae16d649f44cbcf4d509493ac1e15132 to your computer and use it in GitHub Desktop.
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestClient;
import java.util.Map;
// test with
// hey -n 60 -c 20 http://localhost:8080/go
@Controller
@ResponseBody
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
Map.of("spring.threads.virtual.enabled", Boolean.toString(true),
"server.tomcat.threads.max", Integer.toString(16))
.forEach(System::setProperty);
SpringApplication.run(DemoApplication.class, args);
}
private final RestClient restClient;
DemoApplication(RestClient.Builder b) {
this.restClient = b.build();
}
@GetMapping("/go")
String go() {
return restClient
.get()
.uri("https://httpbin.org/delay/4")
.retrieve()
.body(String.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment