Class JobDefinitionRegistry

java.lang.Object
com.bluebell.greenhouse.radicle.services.job.JobDefinitionRegistry

@Service public class JobDefinitionRegistry extends Object
Registry of executable job definitions. Enum-only historical types intentionally have no definition.
Version:
3.0.6
Author:
Stephen Prizio
  • Constructor Details

    • JobDefinitionRegistry

      public JobDefinitionRegistry()
      Creates the active definition registry and registers every currently executable job type.
  • Method Details

    • resolve

      public <T extends JobPayload> JobDefinition<T> resolve(JobDefinitionKey<T> key)
      Resolves and validates a typed definition.
      Type Parameters:
      T - payload type
      Parameters:
      key - typed definition key
      Returns:
      registered definition
    • contains

      public boolean contains(JobType jobType)
      Returns whether the job type is currently executable.
      Parameters:
      jobType - job type
      Returns:
      true when registered
    • minimumRerunInterval

      public Duration minimumRerunInterval(JobType jobType)
      Returns the shortest gap permitted between two scheduled runs of a job type.
      Parameters:
      jobType - job type
      Returns:
      minimum rerun interval, or zero when the type has no definition
    • isRetryable

      public boolean isRetryable(JobType jobType, String failureKind, int attemptNumber)
      Returns whether a failed attempt of this type may be retried again. Attempt limits come from the definition rather than from the attempt row, so raising a limit applies to work already queued.
      Parameters:
      jobType - job type
      failureKind - failure category
      attemptNumber - failed attempt number
      Returns:
      true when another automatic attempt is permitted
    • retryDelay

      public Duration retryDelay(JobType jobType, int attemptNumber)
      Calculates the delay before the next automatic attempt, using the definition's own backoff, ceiling and jitter rather than a constant duplicated at each failure site.
      Parameters:
      jobType - job type
      attemptNumber - failed attempt number
      Returns:
      retry delay