Skip to content

Commit

Permalink
Improve ProcessFunctionTimers example (Chapter 6)
Browse files Browse the repository at this point in the history
  • Loading branch information
fhueske committed Jul 24, 2019
1 parent b448e74 commit c188681
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ class TempIncreaseAlertFunction
// update last temperature
lastTemp.update(r.temperature)

val curTimerTimestamp = currentTimer.value();
if (prevTemp == 0.0 || r.temperature < prevTemp) {
val curTimerTimestamp = currentTimer.value()
if (prevTemp == 0.0) {
// first sensor reading for this key.
// we cannot compare it with a previous value.
}
else if (r.temperature < prevTemp) {
// temperature decreased. Delete current timer.
ctx.timerService().deleteProcessingTimeTimer(curTimerTimestamp)
currentTimer.clear()
Expand Down

0 comments on commit c188681

Please sign in to comment.