Class Bulkhead.SemaphoreBulkhead

java.lang.Object
cloud.opencode.base.cache.protection.Bulkhead.SemaphoreBulkhead
All Implemented Interfaces:
Bulkhead
Enclosing interface:
Bulkhead

public static final class Bulkhead.SemaphoreBulkhead extends Object implements Bulkhead
Semaphore-based bulkhead implementation 基于信号量的舱壁实现
Since:
JDK 25, opencode-base-cache V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • execute

      public <T> T execute(Supplier<T> supplier)
      Description copied from interface: Bulkhead
      Execute operation with bulkhead protection 在舱壁保护下执行操作
      Specified by:
      execute in interface Bulkhead
      Type Parameters:
      T - result type | 结果类型
      Parameters:
      supplier - the operation | 操作
      Returns:
      result | 结果
    • executeAsync

      public <T> CompletableFuture<T> executeAsync(Supplier<T> supplier)
      Description copied from interface: Bulkhead
      Execute operation asynchronously 异步执行操作
      Specified by:
      executeAsync in interface Bulkhead
      Type Parameters:
      T - result type | 结果类型
      Parameters:
      supplier - the operation | 操作
      Returns:
      future containing result | 包含结果的 Future
    • name

      public String name()
      Description copied from interface: Bulkhead
      Get bulkhead name 获取舱壁名称
      Specified by:
      name in interface Bulkhead
      Returns:
      name | 名称
    • getMetrics

      public Bulkhead.Metrics getMetrics()
      Description copied from interface: Bulkhead
      Get current metrics 获取当前指标
      Specified by:
      getMetrics in interface Bulkhead
      Returns:
      metrics | 指标
    • close

      public void close()
      Description copied from interface: Bulkhead
      Close bulkhead and release resources 关闭舱壁并释放资源
      Specified by:
      close in interface Bulkhead
    • tryAcquire

      public boolean tryAcquire()
      Description copied from interface: Bulkhead
      Try to acquire a permit from the bulkhead 尝试从舱壁获取许可
      Specified by:
      tryAcquire in interface Bulkhead
      Returns:
      true if permit acquired | 获取许可返回 true
    • release

      public void release()
      Description copied from interface: Bulkhead
      Release a permit back to the bulkhead 释放许可回到舱壁
      Specified by:
      release in interface Bulkhead