Record Class TailOptions

java.lang.Object
java.lang.Record
codes.grow.packages.betterstack.logging.TailOptions
Record Components:
start - first record time (empty = now)
interval - polling interval for services that poll (default 1 s)
onError - receives errors; tailing continues

public record TailOptions(Optional<Instant> start, Duration interval, Consumer<Throwable> onError) extends Record
  • Field Details

    • DEFAULT_INTERVAL

      public static final Duration DEFAULT_INTERVAL
      The interval used when none is given. explicitInterval() tells this default apart from an interval the caller chose, so a service can apply its own default (passing this constant itself counts as unset).
  • Constructor Details

    • TailOptions

      public TailOptions(Optional<Instant> start, Duration interval, Consumer<Throwable> onError)
      Fills defaults for null values.
      Parameters:
      start - first record time
      interval - polling interval
      onError - error callback
  • Method Details

    • defaults

      public static TailOptions defaults()
      Defaults: from now, 1 s interval, errors ignored.
      Returns:
      defaults
    • withOnError

      public TailOptions withOnError(Consumer<Throwable> callback)
      Copy with an error callback.
      Parameters:
      callback - error callback
      Returns:
      options
    • explicitInterval

      public Optional<Duration> explicitInterval()
      Returns the interval the caller set, or empty when it was left unset (the record then holds DEFAULT_INTERVAL).
      Returns:
      the explicit interval, if any
    • intervalOr

      public Duration intervalOr(Duration serviceDefault)
      Returns the caller's interval, or serviceDefault when it was left unset.
      Parameters:
      serviceDefault - the service's own default interval
      Returns:
      the interval to use
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • start

      public Optional<Instant> start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • interval

      public Duration interval()
      Returns the value of the interval record component.
      Returns:
      the value of the interval record component
    • onError

      public Consumer<Throwable> onError()
      Returns the value of the onError record component.
      Returns:
      the value of the onError record component