Module: MaintenanceTasks

Defined in:
lib/maintenance_tasks.rb,
lib/maintenance_tasks/cli.rb,
lib/maintenance_tasks/engine.rb,
app/models/maintenance_tasks/run.rb,
app/models/maintenance_tasks/task.rb,
app/jobs/maintenance_tasks/task_job.rb,
app/models/maintenance_tasks/runner.rb,
app/models/maintenance_tasks/ticker.rb,
app/models/maintenance_tasks/progress.rb,
app/models/maintenance_tasks/runs_page.rb,
app/helpers/maintenance_tasks/tasks_helper.rb,
app/models/maintenance_tasks/task_data_show.rb,
app/models/maintenance_tasks/task_data_index.rb,
app/models/maintenance_tasks/application_record.rb,
lib/generators/maintenance_tasks/task_generator.rb,
app/helpers/maintenance_tasks/application_helper.rb,
app/controllers/maintenance_tasks/runs_controller.rb,
app/models/concerns/maintenance_tasks/run_concern.rb,
app/controllers/maintenance_tasks/tasks_controller.rb,
app/models/maintenance_tasks/no_collection_builder.rb,
lib/generators/maintenance_tasks/install_generator.rb,
app/models/maintenance_tasks/csv_collection_builder.rb,
app/jobs/concerns/maintenance_tasks/task_job_concern.rb,
app/models/maintenance_tasks/null_collection_builder.rb,
app/validators/maintenance_tasks/run_status_validator.rb,
app/controllers/maintenance_tasks/application_controller.rb,
app/models/maintenance_tasks/batch_csv_collection_builder.rb

Overview

The engine’s namespace module. It provides isolation between the host application’s code and the engine-specific code. Top-level engine constants and variables are defined under this module.

Defined Under Namespace

Modules: ApplicationHelper, RunConcern, Runner, TaskJobConcern, TasksHelper Classes: ApplicationController, ApplicationRecord, BatchCsvCollectionBuilder, CLI, CsvCollectionBuilder, Engine, InstallGenerator, NoCollectionBuilder, NullCollectionBuilder, Progress, Run, RunStatusValidator, RunsController, RunsPage, Task, TaskDataIndex, TaskDataShow, TaskGenerator, TaskJob, TasksController, Ticker

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.active_storage_serviceSymbol

The Active Storage service to use for uploading CSV file blobs.

Returns:

  • (Symbol)

    the key for the storage service, as specified in the app’s config/storage.yml.



52
# File 'lib/maintenance_tasks.rb', line 52

mattr_accessor :active_storage_service

.backtrace_cleanerActiveSupport::BacktraceCleaner?

The Active Support backtrace cleaner that will be used to clean the backtrace of a Task that errors.

Returns:

  • (ActiveSupport::BacktraceCleaner, nil)

    the backtrace cleaner to use when cleaning a Run’s backtrace.



62
# File 'lib/maintenance_tasks.rb', line 62

mattr_accessor :backtrace_cleaner

.jobString

The name of the job to be used to perform Tasks. Defaults to ‘“MaintenanceTasks::TaskJob”`. This job must be either a class that inherits from TaskJob or a class that includes TaskJobConcern.

Returns:

  • (String)

    the name of the job class.



30
# File 'lib/maintenance_tasks.rb', line 30

mattr_accessor :job, default: "MaintenanceTasks::TaskJob"

.parent_controllerString

The parent controller all web UI controllers will inherit from. Must be a class that inherits from ‘ActionController::Base`. Defaults to `“ActionController::Base”`

Returns:

  • (String)

    the name of the parent controller for web UI.



72
# File 'lib/maintenance_tasks.rb', line 72

mattr_accessor :parent_controller, default: "ActionController::Base"

.report_errors_as_handledBoolean

How unexpected errors are reported to Rails.error.report.

When an error occurs that isn’t explicitly handled (e.g., via ‘report_on`), it gets reported to Rails.error.report. This setting determines whether these errors are marked as “handled” or “unhandled”.

The current default of ‘true` is for backwards compatibility, but it prevents error subscribers from distinguishing between expected and unexpected errors. Setting this to `false` provides more accurate error reporting and will become the default in v3.0.

Returns:

  • (Boolean)

    whether to report unexpected errors as handled (true) or unhandled (false).

See Also:



110
# File 'lib/maintenance_tasks.rb', line 110

mattr_accessor :report_errors_as_handled, default: true

.serialize_cursors_as_jsonBoolean

Controls whether or not cursor values are stored as JSON in the database. Defaults to false.

Storing cursors as JSON enables more complex cursor structures. For example, with JSON cursors a task can iterate over collections using multiple fields or columns to track progress. This is particularly useful for iterating over models with composite primary keys.

Be advised that this feature comes with a few caveats:

  1. Cursor values must be capable of being serialized to JSON and parsed from JSON. If they are not, errors will occur during task execution.

  2. If a cursor contains a value that loses precision when serialized, it may lead to unexpected behaviour.

  3. This feature utilizes a string column to store the JSON data. If your database has a hard limit on how big a string value can be, be mindful that certain cursor structures could result in a value that could exceed that limit and cause issues.

A new column was added to discern JSON cursors from plain string cursors. Make sure you have run the latest database migrations provided by the gem before enabling this feature.

Returns:

  • (Boolean)

    whether or not to store cursor values as JSON.



138
# File 'lib/maintenance_tasks.rb', line 138

mattr_accessor :serialize_cursors_as_json, default: false

.status_reload_frequencyActiveSupport::Duration, Numeric

The frequency at which to reload the run status during iteration. Defaults to 1 second, meaning reload status every second.

Returns:

  • (ActiveSupport::Duration, Numeric)

    the time interval between status reloads.



94
# File 'lib/maintenance_tasks.rb', line 94

mattr_accessor :status_reload_frequency, default: 1.second

.stuck_task_durationActiveSupport::Duration

The duration after which a task is considered stuck and can be force cancelled.

Returns:

  • (ActiveSupport::Duration)

    the threshold in seconds after which a task is considered stuck.



86
# File 'lib/maintenance_tasks.rb', line 86

mattr_accessor :stuck_task_duration, default: 5.minutes

.task_staleness_thresholdActiveSupport::Duration, false

The threshold after which a task is considered stale. Defaults to 30 days. Can be disabled by setting this to ‘false`.

Returns:

  • (ActiveSupport::Duration, false)

    time interval after which a task is considered stale.



146
# File 'lib/maintenance_tasks.rb', line 146

mattr_accessor :task_staleness_threshold, default: 30.days

.tasks_moduleString

The module to namespace Tasks in, as a String. Defaults to ‘Maintenance’.

Returns:

  • (String)

    the name of the module.



20
# File 'lib/maintenance_tasks.rb', line 20

mattr_accessor :tasks_module, default: "Maintenance"

.ticker_delayActiveSupport::Duration, Numeric

The delay between updates to the tick count. After each iteration, the progress of the Task may be updated. This duration in seconds limits these updates, skipping if the duration since the last update is lower than this value, except if the job is interrupted, in which case the progress will always be recorded.

Returns:

  • (ActiveSupport::Duration, Numeric)

    duration of the delay between updates to the tick count during Task iterations.



43
# File 'lib/maintenance_tasks.rb', line 43

mattr_accessor :ticker_delay, default: 1.second

Instance Attribute Details

#metadataObject



79
# File 'lib/maintenance_tasks.rb', line 79

mattr_accessor :metadata, default: nil

Class Method Details

.deprecatorObject

@api-private



169
170
171
# File 'lib/maintenance_tasks.rb', line 169

def deprecator
  @deprecator ||= ActiveSupport::Deprecation.new("3.0", "MaintenanceTasks")
end

.error_handlerObject

Deprecated.


155
156
157
158
159
# File 'lib/maintenance_tasks.rb', line 155

def error_handler
  deprecator.warn(DEPRECATION_MESSAGE)

  @error_handler
end

.error_handler=(proc) ⇒ Object

Deprecated.


162
163
164
165
166
# File 'lib/maintenance_tasks.rb', line 162

def error_handler=(proc)
  deprecator.warn(DEPRECATION_MESSAGE)

  @error_handler = proc
end