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.

Abstract ActiveJob base class for executing Servus services asynchronously.

This class is never enqueued directly. Instead, Call generates a named subclass per service (e.g. Treasury::TransferGold::ServiceJob) so that background runners like Sidekiq and GoodJob display a meaningful, per-service job name rather than one generic class for every invocation.

Each generated subclass carries a reference to its owning service in #servus_service, set at generation time. #perform uses that reference to route back through the standard Base.call lifecycle — validation, logging, benchmarking, guards, and event emission all run exactly as if the service had been called synchronously.

Examples:

The class Servus generates for a service

Treasury::TransferGold::ServiceJob < Servus::Extensions::Async::Job
Treasury::TransferGold::ServiceJob.servus_service
# => Treasury::TransferGold::Service

See Also:

Instance Method Summary collapse

Instance Method Details

#perform(**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 job's service with the provided arguments.

The service is identified by #servus_service rather than a serialized name — the job class itself encodes which service to run.

Parameters:

  • args (Hash)

    keyword arguments to pass to the service

Returns:



44
45
46
# File 'lib/servus/extensions/async/job.rb', line 44

def perform(**args)
  self.class.servus_service.call(**args)
end

#servus_serviceClass<Servus::Base>?

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.

The service class this job invokes. Set on each generated subclass when Call#build_servus_job_class creates it.

Returns:



31
# File 'lib/servus/extensions/async/job.rb', line 31

class_attribute :servus_service