class Task
- Task
- Reference
- Object
Overview
Background task.
By default, background tasks are processed sequentially.
Included Modules
Extended Modules
Direct Known Subclasses
- Task::Backup
- Task::CleanOauth
- Task::CollectGarbage
- Task::Deliver
- Task::Fetch::Hashtag
- Task::Fetch::Thread
- Task::HandleFollowRequest
- Task::Monitor
- Task::Performance
- Task::Receive
- Task::RefreshActor
- Task::RunScripts
- Task::Terminate
- Task::UpdateMetrics
Defined in:
models/task.crmodels/task/backup.cr
models/task/clean_oauth.cr
models/task/collect_garbage.cr
models/task/deliver.cr
models/task/fetch/hashtag.cr
models/task/fetch/mixins/fetcher.cr
models/task/fetch/thread.cr
models/task/handle_follow_request.cr
models/task/mixins/singleton.cr
models/task/mixins/transfer.cr
models/task/monitor.cr
models/task/performance.cr
models/task/receive.cr
models/task/refresh_actor.cr
models/task/run_scripts.cr
models/task/terminate.cr
models/task/update_metrics.cr
Constant Summary
-
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 useADAPTIVE_RANDOMIZATION_PERCENTAGE_LONG. -
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.
Class Method Summary
-
.all_subtypes
Returns type and all concrete (non-abstract) subtypes, including any aliases defined on the type.
- .clean_up_running_tasks
- .destroy_old_tasks
- .priority
- .priority=(priority : Int32)
- .scheduled(now = Time.utc, reserve = false)
Instance Method Summary
- #backtrace : Array(String) | Nil
- #backtrace=(backtrace : Array(String) | Nil)
- #complete : Bool
- #complete=(complete : Bool)
-
#gone?
Indicates whether or not the task is gone.
- #last_attempt_at : Time | Nil
- #last_attempt_at=(last_attempt_at : Time | Nil)
- #next_attempt_at : Time | Nil
- #next_attempt_at=(next_attempt_at : Time | Nil)
- #past_due?(now = Time.utc)
- #perform
- #runnable?
- #running : Bool
- #running=(running : Bool)
- #schedule(next_attempt_at = nil)
- #source_iri : String
- #source_iri=(source_iri : String)
- #subject_iri : String
- #subject_iri=(subject_iri : String)
Instance methods inherited from module Ktistec::Model::Polymorphic
_validate_type
_validate_type,
as_a(as _as : T.class) : T forall T
as_a,
type : String
type,
type=(type : String)
type=
Macros inherited from module Ktistec::Model::Polymorphic
find(_id id, *, as _as)find(*, as _as, **options) find
Instance methods inherited from module Ktistec::Model::Common
created_at : Time
created_at,
created_at=(created_at : Time)
created_at=,
updated_at : Time
updated_at,
updated_at=(updated_at : Time)
updated_at=
Instance methods inherited from module Ktistec::Model
==(other : self)==(other) ==, _run_validations _run_validations, _save_model(skip_validation = false) _save_model, _serialize_graph(nodes, association = nil, index = nil, skip_associated = false) _serialize_graph, assign(properties : Hash(String, Any), *, _strict : Bool = false) forall Any
assign(*, _strict : Bool = false, **properties) assign, changed!(*properties : Symbol) changed!, changed?
changed?(*properties : Symbol) changed?, clear_changed!
clear_changed!(*properties : Symbol) clear_changed!, destroy destroy, destroyed? destroyed?, errors errors, hash(hasher) hash, id : Int64 | Nil id, id=(id : Int64 | Nil) id=, inspect(io : IO) inspect, new_record? new_record?, reload! reload!, save(skip_validation = false, skip_associated = false) save, serialize_graph(skip_associated = false) serialize_graph, table_name table_name, to_h to_h, to_json(json : JSON::Builder) to_json, to_s(io : IO) to_s, update_property(property, value) update_property, valid?(skip_associated = false) valid?, validate(skip_associated = false) validate
Constructor methods inherited from module Ktistec::Model
new(properties : Hash(String, Any), *, _strict : Bool = false) forall Anynew(*, _strict : Bool = false, **properties) new
Macros inherited from module Ktistec::Model
belongs_to(name, primary_key = id, foreign_key = nil, class_name = nil, inverse_of = nil)
belongs_to,
derived(decl, *, aliased_to)
derived,
has_many(name, primary_key = id, foreign_key = nil, class_name = nil, inverse_of = nil)
has_many,
has_one(name, primary_key = id, foreign_key = nil, class_name = nil, inverse_of = nil)
has_one,
validates(property, &block)
validates
Class Method Detail
Returns type and all concrete (non-abstract) subtypes, including any aliases defined on the type.
Instance Method Detail
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.