class

Task

Inherits Ktistec::Model::Polymorphic < Ktistec::Model::Common < Ktistec::Model < Reference < Object

Background task.

By default, background tasks are processed sequentially.

Constants

ADAPTIVE_RANDOMIZATION_PERCENTAGE_LONG = 0.025

Adaptive randomization percentage for long intervals.

This percentage represents the total randomization range (e.g., 0.025 = 2.5% total range, meaning ±1.25%). Used when adaptive randomization is enabled and the interval is greater than or equal to ADAPTIVE_RANDOMIZATION_THRESHOLD.

ADAPTIVE_RANDOMIZATION_PERCENTAGE_SHORT = 0.05

Adaptive randomization percentage for short intervals.

This percentage represents the total randomization range (e.g., 0.05 = 5% total range, meaning ±2.5%). Used when adaptive randomization is enabled and the interval is shorter than ADAPTIVE_RANDOMIZATION_THRESHOLD.

ADAPTIVE_RANDOMIZATION_THRESHOLD = 6.hours

Threshold for adaptive randomization calculation .

Intervals shorter than this use ADAPTIVE_RANDOMIZATION_PERCENTAGE_SHORT. Intervals longer than or equal to this use ADAPTIVE_RANDOMIZATION_PERCENTAGE_LONG.

DOWN_DETECTION_SPAN = 80.hours

Minimum time span that failures must cover to mark a recipient as down. FAILED_TASK_RETENTION must exceed this value.

FAILED_TASK_RETENTION = 96.hours

Retention period for completed tasks with failures. This must exceed DOWN_DETECTION_SPAN to ensure failure data is available for down detection.

MIN_RANDOMIZATION_THRESHOLD = 5.minutes

Minimum time delta threshold for applying randomization.

Task scheduling deltas below this threshold will not be randomized to maintain precision for short-interval tasks.

SUCCESSFUL_TASK_RETENTION = 2.hours

Retention period for completed tasks without failures.

Class methods

all_subtypes

Returns type and all concrete (non-abstract) subtypes, including any aliases defined on the type.

Source
clean_up_running_tasks
Source
destroy_old_tasks
Source
priority
Source
priority=(priority : Int32)
Source
running_count

Returns count of currently running tasks.

Source
scheduled(now = Time.utc, reserve = false)
Source
scheduled_soon_count(within : Time::Span = 1.minute)

Returns count of tasks scheduled to run within the given time span.

Source

Instance methods

backtrace
Source
backtrace=(backtrace : Array(String) | Nil)
Source
complete
Source
complete=(complete : Bool)
Source
gone?

Indicates whether or not the task is gone.

Typically, this means that the task was saved but has been destroyed. Destroying a running task is a lightweight signal that the task should terminate itself.

Source
last_attempt_at
Source
last_attempt_at=(last_attempt_at : Time | Nil)
Source
next_attempt_at
Source
next_attempt_at=(next_attempt_at : Time | Nil)
Source
past_due?(now = Time.utc)
Source
perform
Source
runnable?
Source
running
Source
running=(running : Bool)
Source
schedule(next_attempt_at = Time.utc)
Source
source_iri
Source
source_iri=(source_iri : String)
Source
subject_iri
Source
subject_iri=(subject_iri : String)
Source

Nested types