File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed
src/main/java/is/swan/mcmarketapi/request/sorting Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change 22
33import java .util .concurrent .atomic .AtomicLong ;
44
5- public class Throttler {
6- enum RequestType {
7- READ , WRITE
8- }
9-
5+ import is .swan .mcmarketapi .request .Request .Method ;
6+
7+ public class Throttler {
108 private final AtomicLong readLastRetry = new AtomicLong (0 );
119 private final AtomicLong readLastRequest = new AtomicLong (System .currentTimeMillis ());
1210
1311 private final AtomicLong writeLastRetry = new AtomicLong (0 );
1412 private final AtomicLong writeLastRequest = new AtomicLong (System .currentTimeMillis ());
1513
16- public long stallFor (RequestType type ) {
14+ public long stallFor (Method method ) {
1715 long time = System .currentTimeMillis ();
1816
19- switch (type ) {
20- case READ :
21- return Throttler .stalForHelper (this .readLastRetry , this .readLastRequest , time );
22- case WRITE :
23- return Throttler .stalForHelper (this .writeLastRetry , this .writeLastRequest , time );
24- default :
25- return 0 ;
17+ if (method == Method .GET ) {
18+ return Throttler .stalForHelper (this .readLastRetry , this .readLastRequest , time );
19+ } else {
20+ return Throttler .stalForHelper (this .writeLastRetry , this .writeLastRequest , time );
2621 }
2722 }
2823
You can’t perform that action at this time.
0 commit comments