ConsecutiveFailureBreaker

class ConsecutiveFailureBreaker constructor(val maxConsecutiveFailures: Int = DEFAULT_MAX_CONSECUTIVE_FAILURES)

Stops calling a service once maxConsecutiveFailures calls in a row have failed.

A re-embed makes one embedding call per proposition. When the embedding service is down, every call fails, and each one waits out its own timeout and retries before the next starts, so trying them all can take a very long time. With this, one bad proposition is still skipped and the run continues, but a run of failures means the service is down: the remaining propositions are not attempted, and the caller reports them as such.

Not thread-safe; use one per run.

Constructors

Link copied to clipboard
constructor(maxConsecutiveFailures: Int = DEFAULT_MAX_CONSECUTIVE_FAILURES)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Whether the limit has been reached, so no more calls are made.

Functions

Link copied to clipboard
fun <T> attempt(call: () -> T): <Error class: unknown class><T>?

Run call and return its result, or null without running it once tripped. An Exception is returned as a failure and counts towards the limit; a success resets the count. An Error propagates.