Skip to content

Commit

Permalink
补充遗漏的文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
InsideZhou committed May 13, 2020
1 parent 2e11cf0 commit d2d8bec
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions framework/src/test/java/test/throttle/ThrottleTestApp.java
@@ -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));
}
}
}

0 comments on commit d2d8bec

Please sign in to comment.