ox.scheduling

package ox.scheduling

Members list

Type members

Classlikes

enum Jitter

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class RepeatConfig[E, T](schedule: Schedule, shouldContinueOnResult: T => Boolean)

A config that defines how to repeat an operation.

A config that defines how to repeat an operation.

Schedule provides the interval between subsequent invocations, which guarantees that the next operation will start no sooner than the specified duration after the previous operations has started. If the previous operation takes longer than the interval, the next operation will start immediately after the previous one has finished.

It is a special case of ScheduledConfig with ScheduledConfig.sleepMode always set to SleepMode.StartToStart and a ScheduledConfig.afterAttempt callback which checks if the result was successful.

Type parameters

E

The error type of the operation. For operations returning a T or a Try[T], this is fixed to Throwable. For operations returning an Either[E, T], this can be any E.

T

The successful result type for the operation.

Value parameters

schedule

The schedule which determines the intervals between invocations and number of attempts to execute the operation.

shouldContinueOnResult

A function that determines whether to continue the loop after a success. The function receives the value that was emitted by the last invocation. Defaults to => true.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Schedule(intervals: () => LazyList[FiniteDuration], initialDelay: Option[FiniteDuration])

Describes a schedule according to which ox.resilience.retry, repeat and schedule will invoke operations. A schedule is essentially a list of intervals, which are used to determine how long to wait before subsequent invocations of the operation.

Describes a schedule according to which ox.resilience.retry, repeat and schedule will invoke operations. A schedule is essentially a list of intervals, which are used to determine how long to wait before subsequent invocations of the operation.

Implementation note: the intervals lazy-list is lazy-evaluated itself, to avoid memory leaks when a schedule is captured as a value and used multiple times. The intervals list is re-created on every usage, which isn't optimal, but due to the small size (and gradual evaluation) of the list, should not cause any performance issues.

Value parameters

initialDelay

The delay to wait before running the operation for the first time - if any.

intervals

The intervals to use for the schedule.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Schedule

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Schedule.type
enum ScheduleStop(val stop: Boolean)

Attributes

See also

ScheduleConfig.afterAttempt

Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ScheduleStop

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class ScheduledConfig[E, T](schedule: Schedule, afterAttempt: (Int, Either[E, T]) => ScheduleStop, sleepMode: SleepMode)

A config that defines how to schedule an operation.

A config that defines how to schedule an operation.

Type parameters

E

The error type of the operation. For operations returning a T or a Try[T], this is fixed to Throwable. For operations returning an Either[E, T], this can be any E.

T

The successful result type for the operation.

Value parameters

afterAttempt

A callback invoked after every attempt, with the current invocation number (starting from 1) and the result of the operation. Might decide to short-circuit further attempts, and stop the schedule. Schedule configuration (e.g. max number of attempts) takes precedence.

schedule

The schedule which determines the maximum number of invocations and the duration between subsequent invocations. See Schedule for more details.

sleepMode

The mode that specifies how to interpret the duration provided by the schedule. See SleepMode for more details.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
enum SleepMode

The mode that specifies how to interpret the duration provided by the schedule.

The mode that specifies how to interpret the duration provided by the schedule.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def repeat[T](config: RepeatConfig[Throwable, T])(operation: => T): T

Repeats an operation returning a direct result until it succeeds or the config decides to stop.

Repeats an operation returning a direct result until it succeeds or the config decides to stop.

repeat is a special case of scheduled with a given set of defaults.

Value parameters

config

The repeat config. Includes a Schedule which determines the intervals between invocations and number of repetitions of the operation.

operation

The operation to repeat.

Attributes

Returns

The result of the last invocation if the config decides to stop.

Throws
anything

The exception thrown by the last invocation if the config decides to stop.

See also
def repeat[T](schedule: Schedule)(operation: => T): T

Repeats an operation returning a direct result until it succeeds or the config decides to stop. Uses the default RepeatConfig, with the given Schedule.

Repeats an operation returning a direct result until it succeeds or the config decides to stop. Uses the default RepeatConfig, with the given Schedule.

repeat is a special case of scheduled with a given set of defaults.

Value parameters

operation

The operation to repeat.

schedule

The schedule which determines the intervals between invocations and number of attempts to execute the operation.

Attributes

Returns

The result of the last invocation if the config decides to stop.

Throws
anything

The exception thrown by the last invocation if the config decides to stop.

See also
def repeatEither[E, T](config: RepeatConfig[E, T])(operation: => Either[E, T]): Either[E, T]

Repeats an operation returning an scala.util.Either until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop.

Repeats an operation returning an scala.util.Either until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop.

repeatEither is a special case of scheduledEither with a given set of defaults.

Value parameters

config

The repeat config. Includes a Schedule which determines the intervals between invocations and number of repetitions of the operation.

operation

The operation to repeat.

Attributes

Returns

The result of the last invocation if the config decides to stop.

See also
def repeatEither[E, T](schedule: Schedule)(operation: => Either[E, T]): Either[E, T]

Repeats an operation returning an scala.util.Either until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop. Uses the default RepeatConfig, with the given Schedule.

Repeats an operation returning an scala.util.Either until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop. Uses the default RepeatConfig, with the given Schedule.

repeatEither is a special case of scheduledEither with a given set of defaults.

Value parameters

operation

The operation to repeat.

schedule

The schedule which determines the intervals between invocations and number of attempts to execute the operation.

Attributes

Returns

The result of the last invocation if the config decides to stop.

See also
def repeatWithErrorMode[E, F[_], T](em: ErrorMode[E, F])(config: RepeatConfig[E, T])(operation: => F[T]): F[T]

Repeats an operation using the given error mode until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop.

Repeats an operation using the given error mode until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop.

repeatWithErrorMode is a special case of scheduledWithErrorMode with a given set of defaults.

Value parameters

config

The repeat config. Includes a Schedule which determines the intervals between invocations and number of repetitions of the operation.

em

The error mode to use, which specifies when a result value is considered success, and when a failure.

operation

The operation to repeat.

Attributes

Returns

The result of the last invocation if the config decides to stop.

See also
def repeatWithErrorMode[E, F[_], T](em: ErrorMode[E, F])(schedule: Schedule)(operation: => F[T]): F[T]

Repeats an operation using the given error mode until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop. Uses the default RepeatConfig, with the given Schedule.

Repeats an operation using the given error mode until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the repeat loop. Uses the default RepeatConfig, with the given Schedule.

repeatWithErrorMode is a special case of scheduledWithErrorMode with a given set of defaults.

Value parameters

em

The error mode to use, which specifies when a result value is considered success, and when a failure.

operation

The operation to repeat.

schedule

The schedule which determines the intervals between invocations and number of attempts to execute the operation.

Attributes

Returns

The result of the last invocation if the config decides to stop.

See also
def scheduled[T](config: ScheduledConfig[Throwable, T])(operation: => T): T

Schedules an operation returning a direct result until it succeeds or the config decides to stop.

Schedules an operation returning a direct result until it succeeds or the config decides to stop.

Value parameters

config

The repeat config - see ScheduledConfig.

operation

The operation to schedule.

Attributes

Returns

The result of the last invocation if the config decides to stop.

Throws
anything

The exception thrown by the last invocation if the config decides to stop.

def scheduledEither[E, T](config: ScheduledConfig[E, T])(operation: => Either[E, T]): Either[E, T]

Schedules an operation returning an scala.util.Either until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the schedule loop.

Schedules an operation returning an scala.util.Either until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the schedule loop.

Value parameters

config

The schedule config - see ScheduledConfig.

operation

The operation to schedule.

Attributes

Returns

The result of the last invocation if the config decides to stop.

def scheduledWithErrorMode[E, F[_], T](em: ErrorMode[E, F])(config: ScheduledConfig[E, T])(operation: => F[T]): F[T]

Schedules an operation using the given error mode until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the schedule loop.

Schedules an operation using the given error mode until the config decides to stop. Note that any exceptions thrown by the operation aren't caught and effectively interrupt the schedule loop.

Value parameters

config

The schedule config - see ScheduledConfig.

em

The error mode to use, which specifies when a result value is considered success, and when a failure.

operation

The operation to schedule.

Attributes

Returns

The result of the last invocation if the config decides to stop.