Please implement a method that can fetch and return the temperature of one certain county in China. Here are the specific features:
- The method signature is
public Optional<Integer> getTemperature(String province, String city, String county)
. - If the location is invalid, return reasonable value.
- Add reasonable retry mechanism, cause there might be connection exception when calling the weather API.
- The method need block invocation if the TPS(transactions per second) is more than 100.
- commons(major): common utils and tools, contains the okhttp retry mechanism implements.
- service(major): Main implements service.
- test(major): Junit test module, contains commons and service test.
- endpoint: Controller module with one simple rest api, but no test.
- model: Data entities module.
- server: Boot Entrance.
server->com.temperature->DemoApplication
Just run the RetryTest & TPSLimitedServiceTest to check the JunitTest result or coverage.