Class: FlowChat::AsyncJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- FlowChat::AsyncJob
- Defined in:
- lib/flow_chat/async_job.rb,
lib/flow_chat/async_job.rb
Overview
Fallback when ActiveJob is not available
Direct Known Subclasses
Class Method Summary collapse
-
.perform_later(args) ⇒ Object
Stub perform_later for testing when ActiveJob is not available.
Instance Method Summary collapse
-
#execute(controller, **job_params) ⇒ Object
Abstract method - user must implement User builds processor AND calls processor.run themselves Job params from use_async(JobClass, key: value) are passed as keyword arguments.
- #perform(request_context:, **job_params) ⇒ Object
Class Method Details
.perform_later(args) ⇒ Object
Stub perform_later for testing when ActiveJob is not available
59 60 61 |
# File 'lib/flow_chat/async_job.rb', line 59 def self.perform_later(args) new.perform(**args) end |
Instance Method Details
#execute(controller, **job_params) ⇒ Object
Abstract method - user must implement User builds processor AND calls processor.run themselves Job params from use_async(JobClass, key: value) are passed as keyword arguments
31 32 33 |
# File 'lib/flow_chat/async_job.rb', line 31 def execute(controller, **job_params) raise NotImplementedError, "Subclasses must implement #execute(controller, **job_params)" end |
#perform(request_context:, **job_params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flow_chat/async_job.rb', line 15 def perform(request_context:, **job_params) FlowChat.logger.debug { "AsyncJob: Starting background job with params: #{job_params.inspect}" } # Create BackgroundController from serialized request controller = BackgroundController.new(request_context) # User implements execute and calls processor.run themselves # Pass job_params as keyword arguments to execute execute(controller, **job_params) FlowChat.logger.debug { "AsyncJob: Background job completed successfully" } end |