@Test public void priorPermitsAreReleasedIfARejectionEventuallyOccurs() { guardRail = builder.build(); when(backPressure.acquirePermit(2L, 22L)).thenReturn(null); when(backPressure2.acquirePermit(2L, 22L)).thenReturn(Rejected.CIRCUIT_OPEN); assertSame(Rejected.CIRCUIT_OPEN, guardRail.acquirePermits(2L, 22L)); InOrder inOrder = inOrder(backPressure); inOrder.verify(backPressure).acquirePermit(2L, 22L); inOrder.verify(backPressure).releasePermit(2L, 22L); }
public Rejected acquirePermits(long number) { return acquirePermits(number, clock.nanoTime()); }
GuardRail { public Rejected acquirePermits(long number) { return acquirePermits(number, clock.nanoTime()); } }
GuardRail { public Rejected acquirePermits(long number) { return acquirePermits(number, clock.nanoTime()); } private  GuardRail(GuardRailProperties<Result, Rejected> properties); }
GuardRail { public Rejected acquirePermits(long number) { return acquirePermits(number, clock.nanoTime()); } private  GuardRail(GuardRailProperties<Result, Rejected> properties); Rejected acquirePermits(long number); Rejected acquirePermits(long number, long nanoTime); void releasePermitsWithoutResult(long number); void releasePermitsWithoutResult(long number, long nanoTime); void releasePermits(ExecutionContext context, Result result); void releasePermits(ExecutionContext context, Result result, long nanoTime); void releasePermits(long number, Result result, long startNanos); void releasePermits(long number, Result result, long startNanos, long nanoTime); PrecipiceFunction<Result, ExecutionContext> releaseFunction(); String getName(); WritableCounts<Result> getResultCounts(); WritableCounts<Rejected> getRejectedCounts(); WritableLatency<Result> getResultLatency(); Map<String, BackPressure<Rejected>> getBackPressure(); Clock getClock(); static GuardRail<Result, Rejected> create(GuardRailProperties<Result, Rejected> properties); }
GuardRail { public Rejected acquirePermits(long number) { return acquirePermits(number, clock.nanoTime()); } private  GuardRail(GuardRailProperties<Result, Rejected> properties); Rejected acquirePermits(long number); Rejected acquirePermits(long number, long nanoTime); void releasePermitsWithoutResult(long number); void releasePermitsWithoutResult(long number, long nanoTime); void releasePermits(ExecutionContext context, Result result); void releasePermits(ExecutionContext context, Result result, long nanoTime); void releasePermits(long number, Result result, long startNanos); void releasePermits(long number, Result result, long startNanos, long nanoTime); PrecipiceFunction<Result, ExecutionContext> releaseFunction(); String getName(); WritableCounts<Result> getResultCounts(); WritableCounts<Rejected> getRejectedCounts(); WritableLatency<Result> getResultLatency(); Map<String, BackPressure<Rejected>> getBackPressure(); Clock getClock(); static GuardRail<Result, Rejected> create(GuardRailProperties<Result, Rejected> properties);  }