Class ClaimOptions

java.lang.Object
lol.trq.alts.account.ClaimOptions

public final class ClaimOptions extends Object
How a scheduled name claim paces itself around its target instant.

A final class rather than a record since 1.0.0, so a later setting is an addition and not a break: start from defaults() or of(Duration, Duration, Duration, int, TimeSource), and derive a copy with withTimeSource(TimeSource). Two options are equal when every setting is.

Since:
0.11.0
  • Method Details

    • defaults

      public static ClaimOptions defaults()
      Returns sensible defaults: begin 300 ms early, try for 10 s, 8 ms between a worker's attempts, three chains, system clock.
      Returns:
      the default options
      Since:
      0.11.0
    • of

      public static ClaimOptions of(Duration leadTime, Duration window, Duration attemptSpacing, int concurrency, TimeSource timeSource)
      Creates options with every setting given.
      Parameters:
      leadTime - how far before the target to begin firing; null or negative is zero
      window - how long to keep trying after the target before giving up; null, zero or negative is ten seconds
      attemptSpacing - the least gap between two attempts on one worker; null or negative is zero
      concurrency - how many attempt chains run in parallel; at least 1
      timeSource - the clock the schedule reads, or null for the system clock
      Returns:
      the options
      Throws:
      IllegalArgumentException - if concurrency is below 1
      Since:
      1.0.0
    • leadTime

      public Duration leadTime()
      Returns how far before the target to begin firing, absorbing clock skew and request latency.
      Returns:
      the lead time, never negative
      Since:
      0.11.0
    • window

      public Duration window()
      Returns how long to keep trying after the target before giving up.
      Returns:
      the window, always positive
      Since:
      0.11.0
    • attemptSpacing

      public Duration attemptSpacing()
      Returns the least gap between two attempts on one worker.
      Returns:
      the spacing, never negative
      Since:
      0.11.0
    • concurrency

      public int concurrency()
      Returns how many attempt chains run in parallel.
      Returns:
      the concurrency, at least 1
      Since:
      0.11.0
    • timeSource

      public TimeSource timeSource()
      Returns the clock the schedule reads, for correcting OS drift.
      Returns:
      the time source, never null
      Since:
      0.11.0
    • withTimeSource

      public ClaimOptions withTimeSource(TimeSource value)
      Returns a copy reading the given time source.
      Parameters:
      value - the time source
      Returns:
      a copy with the time source replaced
      Since:
      0.11.0
    • equals

      public boolean equals(Object o)
      Returns whether o holds the same settings; the time sources compare by their own equality.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare
      Returns:
      true when every setting is equal
      Since:
      0.11.0
    • hashCode

      public int hashCode()
      Returns a hash over every setting, consistent with equals(Object).
      Overrides:
      hashCode in class Object
      Returns:
      the hash
      Since:
      0.11.0
    • toString

      public String toString()
      Returns every setting, in the form the record printed them.
      Overrides:
      toString in class Object
      Returns:
      a description
      Since:
      0.11.0