Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backoff when caught up #44

Open
sirocchj opened this issue Jan 21, 2020 · 2 comments
Open

Backoff when caught up #44

sirocchj opened this issue Jan 21, 2020 · 2 comments
Labels
enhancement New feature or request workaround available There's a way around this issue and it's documented in the issue itself or in code

Comments

@sirocchj
Copy link
Member

Tamer is designed to always go as fast as possible. Sometimes it may be desirable to slow down, e.g. once we caught up with the "initial load".. We could use a scheduler controlled in the Setup and returned by it so to slow this down, when needed

@sirocchj
Copy link
Member Author

sirocchj commented Dec 2, 2020

Alternatively, we could slow down in Setup by deciding for example that when time (wall-clock) is within 1m of last timestamp fetched (to allow 1m skew) we sleep (w/o blocking). Something like

  private[this] implicit final class InstantOps(private val instant: Instant) extends AnyVal {
    def plusDuration(duration: Duration): Instant  = instant.plusMillis(duration.toMillis)
    def minusDuration(duration: Duration): Instant = instant.minusMillis(duration.toMillis)

    def orOneMinuteAgo: URIO[Clock, Instant] = UIO(Instant.now.minusSeconds(60)).flatMap {
      case oneMinuteAgo if oneMinuteAgo.isBefore(instant) =>
        val timeDifferenceMillis = instant.toEpochMilli - oneMinuteAgo.toEpochMilli
        val durationToSleep      = zio.duration.Duration(timeDifferenceMillis, TimeUnit.MILLISECONDS)
        ZIO.sleep(durationToSleep) *> orOneMinuteAgo
      case _ => UIO(instant)
    }
  }

in place of

private[this] implicit final class InstantOps(private val instant: Instant) extends AnyVal {
def plus5Minutes: Instant = instant.plus(5, MINUTES)
def minus60Days: Instant = instant.minus(60, DAYS)
def orNow: UIO[Instant] =
UIO(Instant.now).map {
case now if instant.isAfter(now) => now
case _ => instant
}
}

@sirocchj sirocchj added wontfix This will not be worked on enhancement New feature or request workaround available There's a way around this issue and it's documented in the issue itself or in code and removed wontfix This will not be worked on labels Dec 5, 2020
@sirocchj
Copy link
Member Author

I'm keeping this around as I believe the delaying of the publication of the next state should be handled by Tamer, not the frontend.

The reason for this is - as things stand - both the commit of the current offset (that got processed fully) and the publication of the new state (that we want to delay) are delayed.

It's a workaround, but not a great one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request workaround available There's a way around this issue and it's documented in the issue itself or in code
Projects
None yet
Development

No branches or pull requests

1 participant