Class Bulkhead.SemaphoreBulkhead
java.lang.Object
cloud.opencode.base.cache.protection.Bulkhead.SemaphoreBulkhead
- All Implemented Interfaces:
Bulkhead
- Enclosing interface:
Bulkhead
Semaphore-based bulkhead implementation
基于信号量的舱壁实现
- Since:
- JDK 25, opencode-base-cache V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Nested Class Summary
Nested classes/interfaces inherited from interface Bulkhead
Bulkhead.BulkheadFullException, Bulkhead.Metrics, Bulkhead.SemaphoreBuilder, Bulkhead.SemaphoreBulkhead, Bulkhead.ThreadPoolBuilder, Bulkhead.ThreadPoolBulkhead -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close bulkhead and release resources 关闭舱壁并释放资源<T> TExecute operation with bulkhead protection 在舱壁保护下执行操作<T> CompletableFuture<T> executeAsync(Supplier<T> supplier) Execute operation asynchronously 异步执行操作Get current metrics 获取当前指标name()Get bulkhead name 获取舱壁名称voidrelease()Release a permit back to the bulkhead 释放许可回到舱壁booleanTry to acquire a permit from the bulkhead 尝试从舱壁获取许可
-
Method Details
-
execute
-
executeAsync
Description copied from interface:BulkheadExecute operation asynchronously 异步执行操作- Specified by:
executeAsyncin interfaceBulkhead- Type Parameters:
T- result type | 结果类型- Parameters:
supplier- the operation | 操作- Returns:
- future containing result | 包含结果的 Future
-
name
-
getMetrics
Description copied from interface:BulkheadGet current metrics 获取当前指标- Specified by:
getMetricsin interfaceBulkhead- Returns:
- metrics | 指标
-
close
-
tryAcquire
public boolean tryAcquire()Description copied from interface:BulkheadTry to acquire a permit from the bulkhead 尝试从舱壁获取许可- Specified by:
tryAcquirein interfaceBulkhead- Returns:
- true if permit acquired | 获取许可返回 true
-
release
-