Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e11cf0
commit d2d8bec
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
framework/src/test/java/test/throttle/ThrottleTestApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package test.throttle; | ||
|
||
import me.insidezhou.southernquiet.FrameworkAutoConfiguration; | ||
import me.insidezhou.southernquiet.throttle.annotation.ThrottledSchedule; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@SpringBootApplication | ||
@ImportAutoConfiguration({FrameworkAutoConfiguration.class}) | ||
public class ThrottleTestApp { | ||
private final static Logger log = LoggerFactory.getLogger(ThrottleTestApp.class); | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ThrottleTestApp.class, args); | ||
} | ||
|
||
@Bean | ||
public ScheduledThrottleBean scheduledThrottleBean() { | ||
return new ScheduledThrottleBean(); | ||
} | ||
|
||
public static class ScheduledThrottleBean { | ||
private final long begin = System.currentTimeMillis(); | ||
|
||
@ThrottledSchedule(fixedRate = 10, threshold = 3, timeUnit = TimeUnit.SECONDS) | ||
public void scheduledThrottleMethod() { | ||
log.info("scheduledThrottleMethod working ...\tbegin={}, elapsed={}", begin, Duration.ofMillis(System.currentTimeMillis() - begin)); | ||
} | ||
} | ||
} |