Class: Joblin::BackgroundTask

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ApiAccess, Attachments, Executor, Options, RetentionPolicy
Defined in:
app/models/joblin/background_task.rb,
app/models/joblin/background_task/options.rb,
app/models/joblin/background_task/executor.rb,
app/models/joblin/background_task/api_access.rb,
app/models/joblin/background_task/attachments.rb,
app/models/joblin/background_task/retention_policy.rb

Defined Under Namespace

Modules: ApiAccess, Attachments, Executor, Options, RetentionPolicy Classes: BackgroundTaskCallbacks, InvalidJobError

Constant Summary

Constants included from Executor

Executor::BACKGROUND_TASK_THREAD_KEY

Instance Method Summary collapse

Methods included from ApiAccess

#api_access_allowed?

Methods included from Attachments

#attach_file, #attachment_path, #load_attachment

Methods included from Concerns::JobWorkingDirs

#working_dir

Methods included from Options

#options

Instance Method Details

#cancel!Object



37
38
39
# File 'app/models/joblin/background_task.rb', line 37

def cancel!
  update!(workflow_state: 'cancelled')
end

#enqueue!Object



29
30
31
32
33
34
35
# File 'app/models/joblin/background_task.rb', line 29

def enqueue!
  self.workflow_state = 'scheduled' if self.workflow_state == 'unscheduled'

  enter_batch do
    self.class::ExecutorJob.perform_later()
  end
end

#handle_batch_stagnationObject



41
42
43
# File 'app/models/joblin/background_task.rb', line 41

def handle_batch_stagnation
  Joblin::Batching::Batch.cleanup_redis(batch_id)
end