public class Throttling extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> com.google.common.util.concurrent.ListenableFuture<T> |
asyncSupplyWithThrottling(ThrottlingKey throttlingKey,
Supplier<com.google.common.util.concurrent.ListenableFuture<T>> result) |
static <T> com.google.common.util.concurrent.ListenableFuture<T> |
asyncSupplyWithThrottling(ThrottlingKey throttlingKey,
Supplier<com.google.common.util.concurrent.ListenableFuture<T>> result,
Supplier<T> onThrottledResult) |
int |
getCurrentConcurrency() |
ThrottlingKey |
getThrottlingKey() |
int |
leave()
离开限流方法
|
static Throttling |
of(ThrottlingKey throttlingKey)
获取指定Throttling
|
static <T,X extends Throwable> |
supplyWithThrottling(ThrottlingKey throttlingKey,
ThrowableSupplier<? extends T,X> result) |
static <T,X extends Throwable> |
supplyWithThrottling(ThrottlingKey throttlingKey,
ThrowableSupplier<? extends T,X> result,
Supplier<? extends T> onThrottledResult) |
boolean |
tryEnter()
尝试进入一个限流方法
|
public static <T,X extends Throwable> T supplyWithThrottling(ThrottlingKey throttlingKey, ThrowableSupplier<? extends T,X> result) throws X extends Throwable
X extends Throwablepublic static <T,X extends Throwable> T supplyWithThrottling(ThrottlingKey throttlingKey, ThrowableSupplier<? extends T,X> result, Supplier<? extends T> onThrottledResult) throws X extends Throwable
X extends Throwablepublic static <T> com.google.common.util.concurrent.ListenableFuture<T> asyncSupplyWithThrottling(ThrottlingKey throttlingKey, Supplier<com.google.common.util.concurrent.ListenableFuture<T>> result)
public static <T> com.google.common.util.concurrent.ListenableFuture<T> asyncSupplyWithThrottling(ThrottlingKey throttlingKey, Supplier<com.google.common.util.concurrent.ListenableFuture<T>> result, Supplier<T> onThrottledResult)
public ThrottlingKey getThrottlingKey()
public int getCurrentConcurrency()
public static Throttling of(ThrottlingKey throttlingKey)
public boolean tryEnter()
true表示进入成功, false表示超过限流了public int leave()
Copyright © 2023 wuyushuo. All rights reserved.