Adds metadata to outboxes

This commit is contained in:
Muhammad Nawzad 2024-08-19 11:06:17 +03:00
parent 08ef9242e5
commit 61767b40c2
No known key found for this signature in database
GPG Key ID: B954B6AAE33940B2
3 changed files with 8 additions and 1 deletions

View File

@ -27,7 +27,12 @@ module Outboxable
outboxes.new(
routing_key:,
exchange: Outboxable.configuration.rabbitmq_exchange_name,
payload: as_json
payload: as_json,
metadata: if respond_to?(:metadata_for_outbox)
metadata_for_outbox
else
{}
end
)
end

View File

@ -15,6 +15,7 @@ class CreateOutboxableOutboxes < ActiveRecord::Migration[7.0]
t.jsonb :payload, default: {}
t.jsonb :headers, default: {}
t.jsonb :metadata, default: {}, null: true
t.integer :size, null: false, default: 0

View File

@ -22,6 +22,7 @@ class Outbox
field :payload, type: Hash, default: {}
field :headers, type: Hash, default: {}
field :metadata, type: Hash, default: {}
index({ idempotency_key: 1 }, { unique: true, name: 'idempotency_key_unique_index' })