Class: Servus::Extensions::Async::Job Private

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/servus/extensions/async/job.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

ActiveJob for executing Servus services asynchronously.

This job is used by Call#call_async to execute services in the background. It receives the service class name and arguments, instantiates the service, and executes it via Base.call.

Examples:

Enqueued by call_async

Services::SendEmail::Service.call_async(user_id: 123)
# Internally enqueues:
#   Job.perform_later(name: "Services::SendEmail::Service", args: { user_id: 123 })

Instance Method Summary collapse

Instance Method Details

#perform(name:, args:) ⇒ Servus::Support::Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes the service with the provided arguments.

Dynamically loads the service class by name and calls it with the provided keyword arguments.

Parameters:

  • name (String)

    fully-qualified service class name

  • args (Hash)

    keyword arguments to pass to the service

Returns:

Raises:



32
33
34
# File 'lib/servus/extensions/async/job.rb', line 32

def perform(name:, args:)
  constantize!(name).call(**args)
end