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 2
2
3
3
import java .util .concurrent .atomic .AtomicLong ;
4
4
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 {
10
8
private final AtomicLong readLastRetry = new AtomicLong (0 );
11
9
private final AtomicLong readLastRequest = new AtomicLong (System .currentTimeMillis ());
12
10
13
11
private final AtomicLong writeLastRetry = new AtomicLong (0 );
14
12
private final AtomicLong writeLastRequest = new AtomicLong (System .currentTimeMillis ());
15
13
16
- public long stallFor (RequestType type ) {
14
+ public long stallFor (Method method ) {
17
15
long time = System .currentTimeMillis ();
18
16
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 );
26
21
}
27
22
}
28
23
You can’t perform that action at this time.
0 commit comments