Class: Railbox::Queue::HandlingQueue
- Defined in:
- lib/railbox/queue/handling_queue.rb
Overview
HandlingQueue is responsible for enqueuing “class method call” actions into the transactional outbox table.
Usage example:
Railbox::HandlingQueue.enqueue(
service: "MyService",
method: "perform_action",
body: { key: "value" },
headers: { ... },
query: { ... },
entity_type: "User",
entity_id: 123,
meta: { ... }
)
This method creates a Railbox::TransactionalOutboxMutator record to be processed by a background job later, enabling reliable, auditable, and decoupled invocation of class methods in your system.
A ValidationError is raised if the given options are invalid (for example, missing class, method, or incorrect body format).
Constant Summary collapse
- OPTIONS =
%i[headers query relative_entity meta].freeze
Class Method Summary collapse
-
.enqueue(service:, method: 'create', body: {}, **opts) ⇒ Boolean
Enqueues a class method call operation for asynchronous processing via the transactional outbox.
Class Method Details
.enqueue(service:, method: 'create', body: {}, **opts) ⇒ Boolean
Enqueues a class method call operation for asynchronous processing via the transactional outbox.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/railbox/queue/handling_queue.rb', line 35 def enqueue(service:, method: 'create', body: {}, **opts) opts.deep_symbolize_keys!.slice!(*OPTIONS) (service, method, body, **opts) to_queue( action_type: 'handler', action_data: {class_name: service, method_name: method}, body: body, status: 'in_progress', **opts ) true end |