Class BulkOptions

java.lang.Object
lol.trq.alts.bulk.BulkOptions

public final class BulkOptions extends Object
How a bulk run should pace itself.

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(int, Duration, int, Duration, boolean), and derive copies with the withX methods. Two options are equal when every setting is.

Since:
0.9.0
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns how many entries may be in flight at once.
    Returns the defaults: four at a time, a quarter second apart, two retries growing from two seconds, stopping if the service says to slow down.
    boolean
    Returns whether o holds the same settings.
    int
    Returns a hash over every setting, consistent with equals(Object).
    int
    Returns how many times a retryable failure is retried, beyond the first attempt.
    Returns the least time between two entries starting.
    of(int concurrency, Duration minSpacing, int maxRetries, Duration retryBaseDelay, boolean stopOnRateLimit)
    Creates options with every pacing setting given and no route tag.
    Returns the delay a retry grows from when the service asked for nothing specific.
    Returns the route tag an import's sign-ins carry, on every request, to the proxy provider; see withRouteTag(String).
    boolean
    Returns whether a rate limit ends the run rather than being waited out; a limit counts whether or not the service said how long to wait.
    Returns every setting, in the form the record printed them.
    withConcurrency(int value)
    Returns a copy running the given number of entries at once.
    Returns a copy that keeps going through a rate limit, waiting each one out: for as long as the service asked, or on a growing delay when it named no wait.
    Returns a copy whose import signs every credential in through AltLoginService.routed(tag): every request of every entry, on every hop, reaches the proxy provider with tag as its NetworkScope.routeTag().

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • defaults

      public static BulkOptions defaults()
      Returns the defaults: four at a time, a quarter second apart, two retries growing from two seconds, stopping if the service says to slow down.

      They are deliberately unambitious. The failure this pacing exists to avoid is a source address earning a longer ban, and the cost of being slower than necessary is a sweep that takes another minute.

      Returns:
      the default options
      Since:
      0.9.0
    • of

      public static BulkOptions of(int concurrency, Duration minSpacing, int maxRetries, Duration retryBaseDelay, boolean stopOnRateLimit)
      Creates options with every pacing setting given and no route tag.
      Parameters:
      concurrency - how many entries may be in flight at once; at least 1
      minSpacing - the least time between two entries starting; null or negative is zero
      maxRetries - how many times a retryable failure is retried, beyond the first attempt; not negative
      retryBaseDelay - the delay a retry grows from when the service asked for nothing specific; null or negative is zero
      stopOnRateLimit - whether a rate limit ends the run rather than being waited out
      Returns:
      the options
      Throws:
      IllegalArgumentException - if concurrency is below 1 or maxRetries is negative
      Since:
      1.0.0
    • concurrency

      public int concurrency()
      Returns how many entries may be in flight at once.
      Returns:
      the concurrency, at least 1
      Since:
      0.9.0
    • minSpacing

      public Duration minSpacing()
      Returns the least time between two entries starting.
      Returns:
      the spacing, never negative
      Since:
      0.9.0
    • maxRetries

      public int maxRetries()
      Returns how many times a retryable failure is retried, beyond the first attempt.
      Returns:
      the retry count, never negative
      Since:
      0.9.0
    • retryBaseDelay

      public Duration retryBaseDelay()
      Returns the delay a retry grows from when the service asked for nothing specific.
      Returns:
      the base delay, never negative
      Since:
      0.9.0
    • stopOnRateLimit

      public boolean stopOnRateLimit()
      Returns whether a rate limit ends the run rather than being waited out; a limit counts whether or not the service said how long to wait.
      Returns:
      whether the run stops on a rate limit
      Since:
      0.9.0
    • routeTag

      public Optional<String> routeTag()
      Returns the route tag an import's sign-ins carry, on every request, to the proxy provider; see withRouteTag(String).
      Returns:
      the tag, or empty for none
      Since:
      1.0.0
    • withConcurrency

      public BulkOptions withConcurrency(int value)
      Returns a copy running the given number of entries at once.
      Parameters:
      value - how many entries may be in flight
      Returns:
      a copy with the concurrency replaced
      Since:
      0.9.0
    • withoutStoppingOnRateLimit

      public BulkOptions withoutStoppingOnRateLimit()
      Returns a copy that keeps going through a rate limit, waiting each one out: for as long as the service asked, or on a growing delay when it named no wait. The whole run pauses for the wait, and an entry that is still limited after maxRetries waits fails.

      Worth knowing what that trades: continuing to send to a service that has asked you to stop is how an address earns a longer ban than the one it is already serving.

      Returns:
      a copy that does not stop early
      Since:
      0.9.0
    • withRouteTag

      public BulkOptions withRouteTag(String tag)
      Returns a copy whose import signs every credential in through AltLoginService.routed(tag): every request of every entry, on every hop, reaches the proxy provider with tag as its NetworkScope.routeTag(). For a host that pins accounts to proxies and wants a batch of new accounts to sign in through one it chose. Only importCredentials reads it; the runs over stored accounts name the account on every hop instead.

      null does not clear the tag: it throws. Options without a tag are the ones built without this call.

      Parameters:
      tag - the route tag
      Returns:
      a copy with the tag set
      Throws:
      NullPointerException - if tag is null
      IllegalArgumentException - if tag is blank
      Since:
      1.0.0
    • equals

      public boolean equals(Object o)
      Returns whether o holds the same settings.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare
      Returns:
      true when every setting is equal
      Since:
      0.9.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.9.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.9.0