From 3b545b06764106f14a551caefc81bcd40142be18 Mon Sep 17 00:00:00 2001 From: Brusk Awat Date: Fri, 14 Apr 2023 04:18:16 +0300 Subject: [PATCH] Updates documentation --- Gemfile.lock | 2 +- README.md | 22 +++++++++++++++++----- lib/outboxable/version.rb | 2 +- lib/templates/activerecord_initializer.rb | 2 +- lib/templates/mongoid_initializer.rb | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fef1aa7..b1a083b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - outboxable (1.0.2) + outboxable (1.0.3) bunny (>= 2.19.0) connection_pool (~> 2.3.0) diff --git a/README.md b/README.md index d16f41c..63a1996 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Outboxable -The Outboxable Gem is tailored for Rails applications to implement the transactional outbox pattern. It currently only supports ActiveRecord. +The Outboxable Gem is tailored for Rails applications to implement the transactional outbox pattern. It supports both ActiveRecord and Mongoid. Please take into consideration that this Gem is **opinionated**, meaning it expects you to follow a certain pattern and specific setting. If you don't like it, you can always fork it and change it. @@ -25,13 +25,19 @@ If bundler is not being used to manage dependencies, install the gem by executin $ gem install outboxable ``` -Then run: +For use with ActiveRecord, run: ```shell -$ rails g outboxable:install +$ rails g outboxable:install --orm activerecord ``` -The command above will add a migration file and the Outbox model. You will need then to run the migrations: +For use with Mongoid, run: + +```shell +$ rails g outboxable:install --orm mongoid +``` + +The command above will add a migration file and the Outbox model. You will need then to run the migrations (ActiveRecord only): ```shell $ rails db:migrate @@ -64,7 +70,7 @@ module Outboxable end Outboxable.configure do |config| - # Specify the ORM you are using. For now, only ActiveRecord is supported. + # Specify the ORM you are using. Supported values are :activerecord and :mongoid config.orm = :activerecord # Specify the message broker you are using. For now, only RabbitMQ is supported. @@ -208,6 +214,12 @@ Last but not least, run sidekiq so that the Outboxable Gem can publish the event $ bundle exec sidekiq ``` + + +### Mongoid + +The Outboxable gem works smoothly with Mongoid. It is to be noted that when used with Mongoid, Outboxable does not use the `_id` as the idempotency key. It creates a field called ``idempotency_key`` which is a UUID generated at the time of the insertion of the document. + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/lib/outboxable/version.rb b/lib/outboxable/version.rb index fd35e8a..a1d51b7 100644 --- a/lib/outboxable/version.rb +++ b/lib/outboxable/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Outboxable - VERSION = '1.0.2' + VERSION = '1.0.3' end diff --git a/lib/templates/activerecord_initializer.rb b/lib/templates/activerecord_initializer.rb index 12c5b3e..637ce29 100644 --- a/lib/templates/activerecord_initializer.rb +++ b/lib/templates/activerecord_initializer.rb @@ -23,7 +23,7 @@ def to_envelope(resource:) # Specify the ORM you are using. For now, only ActiveRecord is supported. config.orm = :activerecord - # Specify the message broker you are using. For now, only RabbitMQ is supported. + # Specify the ORM you are using. Supported values are :activerecord and :mongoid config.message_broker = :rabbitmq # RabbitMQ configurations diff --git a/lib/templates/mongoid_initializer.rb b/lib/templates/mongoid_initializer.rb index 2201928..60547c4 100644 --- a/lib/templates/mongoid_initializer.rb +++ b/lib/templates/mongoid_initializer.rb @@ -23,7 +23,7 @@ def to_envelope(resource:) # Specify the ORM you are using. For now, only ActiveRecord is supported. config.orm = :mongoid - # Specify the message broker you are using. For now, only RabbitMQ is supported. + # Specify the ORM you are using. Supported values are :activerecord and :mongoid config.message_broker = :rabbitmq # RabbitMQ configurations