Module: SolidObjects::Transmission
- Defined in:
- lib/solid_objects/transmission.rb,
sig/generated/lib/solid_objects/transmission.rbs
Constant Summary collapse
- REQUIRED_FIELDS =
%w[effectId actorType actorId operation].freeze
- IDEMPOTENCY_PREFIX =
"transmit:"- EFFECT_NAME =
"solid-objects.transmit"- UNDELIVERED_STATUSES =
%w[pending processing].freeze
Class Method Summary collapse
- .deliver_through(effect_name:, arguments:, context:, deliver:) ⇒ nil
- .receive(envelope, resolve_actor_type: :itself.to_proc, mailbox: Mailbox.new, actor_loader: method(:load_application_actors)) ⇒ MessageReference
Class Method Details
.deliver_through(effect_name:, arguments:, context:, deliver:) ⇒ nil
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/solid_objects/transmission.rb', line 32 def deliver_through(effect_name:, arguments:, context:, deliver:) staged_envelope( arguments, effect_id: context.id, actor_type: context.actor_type, actor_id: context.actor_id ) undelivered_envelopes_through(effect_name:, context:).each do |envelope| deliver.call(envelope) end nil end |
.receive(envelope, resolve_actor_type: :itself.to_proc, mailbox: Mailbox.new, actor_loader: method(:load_application_actors)) ⇒ MessageReference
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/solid_objects/transmission.rb', line 12 def receive(envelope, resolve_actor_type: :itself.to_proc, mailbox: Mailbox.new, actor_loader: method(:load_application_actors)) validate!(envelope) actor_type = resolve_actor_type.call(envelope["actorType"]).to_s actor_class = fetch_actor_class(actor_type, actor_loader) operation = envelope["operation"].to_sym unless actor_class.definition..key?(operation) raise UnknownMessage, "unknown operation #{envelope["operation"].inspect}" end mailbox.enqueue( reference: Reference.new(actor_type:, actor_id: envelope["actorId"]), operation:, arguments: envelope.fetch("arguments", {}), delivery_mode: "internal", idempotency_key: "#{IDEMPOTENCY_PREFIX}#{envelope["effectId"]}" ) end |