Class: SpreeCmCommissioner::MaintenanceTask
- Includes:
- StoreMetadata
- Defined in:
- app/models/spree_cm_commissioner/maintenance_task.rb
Direct Known Subclasses
SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation, SpreeCmCommissioner::MaintenanceTasks::Event
Constant Summary collapse
- MAX_ATTEMPTS =
5
Instance Method Summary collapse
- #async_execute ⇒ Object
-
#execute ⇒ Object
Execute the maintenance task with error handling and attempt tracking.
-
#maintain ⇒ Object
Override in subclasses with specific maintenance logic.
Instance Method Details
#async_execute ⇒ Object
24 25 26 |
# File 'app/models/spree_cm_commissioner/maintenance_task.rb', line 24 def async_execute SpreeCmCommissioner::MaintenanceTasks::ProcessJob.perform_later(task_id: id) end |
#execute ⇒ Object
Execute the maintenance task with error handling and attempt tracking
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/spree_cm_commissioner/maintenance_task.rb', line 29 def execute log_run("Attempt #{attempt_count + 1} started at #{Time.current.iso8601}") update(attempt_count: attempt_count + 1) maintain log_run("Completed at #{Time.current.iso8601}") update!(completed_at: Time.current) # Don't re-raise - continue processing other tasks rescue StandardError => e log_run("Failed at #{Time.current.iso8601}: #{e.}") update(last_error: e.) log_failure(e) end |
#maintain ⇒ Object
Override in subclasses with specific maintenance logic
46 47 48 |
# File 'app/models/spree_cm_commissioner/maintenance_task.rb', line 46 def maintain raise NotImplementedError, "#{self.class} must implement #maintain" end |