Exception: Servus::Extensions::Async::Errors::JobNameConflictError

Inherits:
AsyncError
  • Object
show all
Defined in:
lib/servus/extensions/async/errors.rb

Overview

Raised when call_async is invoked on a service whose generated job was never published because the application already owns the constant.

The generated job class exists but has no name, and ActiveJob serializes a job by its class name — enqueueing it would succeed and then fail on the worker at deserialization, far from the call site. Refusing here keeps the failure where it was caused.

See Also:

Class Method Summary collapse

Class Method Details

.for(service, const_name) ⇒ JobNameConflictError

Parameters:

  • service (Class) —

    the service whose job constant is taken

  • const_name (String) —

    the constant the application owns

Returns:



39
40
41
42
43
44
45
46
# File 'lib/servus/extensions/async/errors.rb', line 39

def self.for(service, const_name)
  new(
    "Cannot enqueue #{service.name}: its generated job was not published because " \
    "#{const_name} is already defined by the application. An unnamed job would " \
    'enqueue but no worker could deserialize it. Rename the service or the ' \
    "application's #{const_name} to stop the collision."
  )
end