Skip to content

Commit

Permalink
Reversed the "no repeat decision", let them keep kicking us in the fa…
Browse files Browse the repository at this point in the history
…ce (#271)
  • Loading branch information
climategadgets committed Oct 8, 2023
1 parent fe42f97 commit d74dade
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Flux<Signal<Double, Void>> guarded(Flux<Signal<Double, Void>> in, SensorConfig c
return in;
}

return new TimeoutGuard<Double, Void>(t).compute(in);
return new TimeoutGuard<Double, Void>(t, true).compute(in);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public final Flux<Signal<T, P>> getFlux(A address) {

logger.info("getFlux: {}", address);

return new TimeoutGuard<T, P>(timeout)
return new TimeoutGuard<T, P>(timeout, true)
.compute(Flux.concat(
checkPresence(address),
getSensorsFlux()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Flux<Signal<Double, Void>> getFlux(String address) {
.map(i -> pollInterval)
.flatMap(timeout -> run(command, timeout));

return new TimeoutGuard<Double, Void>(pollInterval.multipliedBy(3))
return new TimeoutGuard<Double, Void>(pollInterval.multipliedBy(3), true)
.compute(commandFlux)
.share();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ public class TimeoutGuard<T, P> implements SignalProcessor<T, T, P> {

private final Thread guardThread;

/**
* Create a non-repeating instance.
*
* This is the preferred way of dealing with timeouts, generating extra traffic is counterproductive
* and may mask design problems.
*
* @param timeout Timeout to observe.
*/
public TimeoutGuard(Duration timeout) {
this(timeout, false);
}

/**
* Create an instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void init() {
@Test
void nodelay() {

var guard = new TimeoutGuard<Integer, Void>(timeout);
var guard = new TimeoutGuard<Integer, Void>(timeout, true);

var source = Flux.range(0, 3).map(v -> new Signal<>(Instant.now(), v, (Void) null));
var guarded = guard
Expand Down

0 comments on commit d74dade

Please sign in to comment.