mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 22:06:47 +00:00
Merge branch 'main' of github.com:broosk1993/outboxable
This commit is contained in:
commit
e6f41a0cf9
@ -111,3 +111,7 @@ Metrics/CyclomaticComplexity:
|
|||||||
Max: 15
|
Max: 15
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 15
|
Max: 15
|
||||||
|
Lint/DuplicateMethods: # Disables duplicate methods warning
|
||||||
|
Enabled: false
|
||||||
|
Gemspec/RequiredRubyVersion: # Disables required ruby version warning
|
||||||
|
Enabled: false
|
||||||
|
|||||||
8
Gemfile
8
Gemfile
@ -1,15 +1,15 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source "https://rubygems.org"
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
# Specify your gem's dependencies in outboxable.gemspec
|
# Specify your gem's dependencies in outboxable.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem "rake", "~> 13.0"
|
gem 'rake', '~> 13.0'
|
||||||
|
|
||||||
gem "rspec", "~> 3.0"
|
gem 'rspec', '~> 3.0'
|
||||||
|
|
||||||
gem "rubocop", "~> 1.21"
|
gem 'rubocop-rails', '~> 2.18'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "sidekiq", "~> 7.0", require: true
|
gem "sidekiq", "~> 7.0", require: true
|
||||||
|
|||||||
14
Gemfile.lock
14
Gemfile.lock
@ -57,19 +57,23 @@ GEM
|
|||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-support (3.12.0)
|
rspec-support (3.12.0)
|
||||||
rubocop (1.45.1)
|
rubocop (1.48.0)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 3.2.0.0)
|
parser (>= 3.2.0.0)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
rexml (>= 3.2.5, < 4.0)
|
rexml (>= 3.2.5, < 4.0)
|
||||||
rubocop-ast (>= 1.24.1, < 2.0)
|
rubocop-ast (>= 1.26.0, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.26.0)
|
rubocop-ast (1.27.0)
|
||||||
parser (>= 3.2.1.0)
|
parser (>= 3.2.1.0)
|
||||||
ruby-progressbar (1.11.0)
|
rubocop-rails (2.18.0)
|
||||||
|
activesupport (>= 4.2.0)
|
||||||
|
rack (>= 1.1)
|
||||||
|
rubocop (>= 1.33.0, < 2.0)
|
||||||
|
ruby-progressbar (1.13.0)
|
||||||
set (1.0.3)
|
set (1.0.3)
|
||||||
sidekiq (7.0.7)
|
sidekiq (7.0.7)
|
||||||
concurrent-ruby (< 2)
|
concurrent-ruby (< 2)
|
||||||
@ -95,7 +99,7 @@ DEPENDENCIES
|
|||||||
outboxable!
|
outboxable!
|
||||||
rake (~> 13.0)
|
rake (~> 13.0)
|
||||||
rspec (~> 3.0)
|
rspec (~> 3.0)
|
||||||
rubocop (~> 1.21)
|
rubocop-rails (~> 2.18)
|
||||||
sidekiq (~> 7.0)
|
sidekiq (~> 7.0)
|
||||||
sidekiq-cron (~> 1.10)
|
sidekiq-cron (~> 1.10)
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ Outboxable.configure do |config|
|
|||||||
# RabbitMQ configurations
|
# RabbitMQ configurations
|
||||||
config.rabbitmq_host = ENV.fetch('RABBITMQ__HOST')
|
config.rabbitmq_host = ENV.fetch('RABBITMQ__HOST')
|
||||||
config.rabbitmq_port = ENV.fetch('RABBITMQ__PORT', 5672)
|
config.rabbitmq_port = ENV.fetch('RABBITMQ__PORT', 5672)
|
||||||
config.rabbitmq_user = ENV.fetch('RABBITMQ__USER')
|
config.rabbitmq_user = ENV.fetch('RABBITMQ__USERNAME')
|
||||||
config.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD')
|
config.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD')
|
||||||
config.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST')
|
config.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST')
|
||||||
config.rabbitmq_event_bus_exchange = ENV.fetch('EVENTBUS__EXCHANGE_NAME')
|
config.rabbitmq_event_bus_exchange = ENV.fetch('EVENTBUS__EXCHANGE_NAME')
|
||||||
|
|||||||
6
Rakefile
6
Rakefile
@ -1,11 +1,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "bundler/gem_tasks"
|
require 'bundler/gem_tasks'
|
||||||
require "rspec/core/rake_task"
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
|
|
||||||
require "rubocop/rake_task"
|
require 'rubocop/rake_task'
|
||||||
|
|
||||||
RuboCop::RakeTask.new
|
RuboCop::RakeTask.new
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module Outboxable
|
|||||||
class InstallGenerator < Rails::Generators::Base
|
class InstallGenerator < Rails::Generators::Base
|
||||||
include Rails::Generators::Migration
|
include Rails::Generators::Migration
|
||||||
|
|
||||||
source_root File.expand_path('../../../templates', __FILE__)
|
source_root File.expand_path('../../templates', __dir__)
|
||||||
|
|
||||||
# Copy initializer into user app
|
# Copy initializer into user app
|
||||||
def copy_initializer
|
def copy_initializer
|
||||||
@ -11,26 +11,26 @@ module Outboxable
|
|||||||
|
|
||||||
# Copy user information (model & Migrations) into user app
|
# Copy user information (model & Migrations) into user app
|
||||||
def create_user_model
|
def create_user_model
|
||||||
target_path = "app/models/outbox.rb"
|
target_path = 'app/models/outbox.rb'
|
||||||
unless File.exist?(File.join(Rails.root, target_path))
|
if Rails.root.join(target_path).exist?
|
||||||
template("outbox.rb", target_path)
|
say_status('skipped', 'Model outbox already exists')
|
||||||
else
|
else
|
||||||
say_status('skipped', "Model outbox already exists")
|
template('outbox.rb', target_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Copy migrations
|
# Copy migrations
|
||||||
def copy_migrations
|
def copy_migrations
|
||||||
if self.class.migration_exists?('db/migrate', "create_outboxable_outboxes")
|
if self.class.migration_exists?('db/migrate', 'create_outboxable_outboxes')
|
||||||
say_status('skipped', "Migration create_outboxable_outboxes already exists")
|
say_status('skipped', 'Migration create_outboxable_outboxes already exists')
|
||||||
else
|
else
|
||||||
migration_template('create_outboxable_outboxes.rb', "db/migrate/create_outboxable_outboxes.rb")
|
migration_template('create_outboxable_outboxes.rb', 'db/migrate/create_outboxable_outboxes.rb')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use to assign migration time otherwise generator will error
|
# Use to assign migration time otherwise generator will error
|
||||||
def self.next_migration_number(dir)
|
def self.next_migration_number(_dir)
|
||||||
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
Time.now.utc.strftime('%Y%m%d%H%M%S')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "outboxable/version"
|
require_relative 'outboxable/version'
|
||||||
|
|
||||||
require 'outboxable/worker'
|
require 'outboxable/worker'
|
||||||
require 'outboxable/publishing_manager'
|
require 'outboxable/publishing_manager'
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module Outboxable
|
|||||||
|
|
||||||
def to_envelope(resource:)
|
def to_envelope(resource:)
|
||||||
# throw not implemented method error
|
# throw not implemented method error
|
||||||
raise NotImplementedError, "Please implement the to_envelope method in your own module"
|
raise NotImplementedError, 'Please implement the to_envelope method in your own module'
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish
|
def publish
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Outboxable.configure do |config|
|
|||||||
# RabbitMQ configurations
|
# RabbitMQ configurations
|
||||||
config.rabbitmq_host = ENV.fetch('RABBITMQ__HOST')
|
config.rabbitmq_host = ENV.fetch('RABBITMQ__HOST')
|
||||||
config.rabbitmq_port = ENV.fetch('RABBITMQ__PORT', 5672)
|
config.rabbitmq_port = ENV.fetch('RABBITMQ__PORT', 5672)
|
||||||
config.rabbitmq_user = ENV.fetch('RABBITMQ__USER')
|
config.rabbitmq_user = ENV.fetch('RABBITMQ__USERNAME')
|
||||||
config.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD')
|
config.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD')
|
||||||
config.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST')
|
config.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST')
|
||||||
config.rabbitmq_event_bus_exchange = ENV.fetch('EVENTBUS__EXCHANGE_NAME')
|
config.rabbitmq_event_bus_exchange = ENV.fetch('EVENTBUS__EXCHANGE_NAME')
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative "lib/outboxable/version"
|
require_relative 'lib/outboxable/version'
|
||||||
|
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = "outboxable"
|
spec.name = 'outboxable'
|
||||||
spec.version = Outboxable::VERSION
|
spec.version = Outboxable::VERSION
|
||||||
spec.authors = ["Brusk Awat"]
|
spec.authors = ['Brusk Awat']
|
||||||
spec.email = ["broosk.edogawa@gmail.com"]
|
spec.email = ['broosk.edogawa@gmail.com']
|
||||||
|
|
||||||
spec.summary = "An opiniated Gem for Rails applications to implement the transactional outbox pattern."
|
spec.summary = 'An opiniated Gem for Rails applications to implement the transactional outbox pattern.'
|
||||||
spec.description = "The Outboxable Gem is tailored for Rails applications to implement the transactional outbox pattern. It currently only supports ActiveRecord."
|
spec.description = 'The Outboxable Gem is tailored for Rails applications to implement the transactional outbox pattern. It currently only supports ActiveRecord.'
|
||||||
spec.homepage = "https://githuh.com/broosk1993/outboxable"
|
spec.homepage = 'https://github.com/broosk1993/outboxable'
|
||||||
spec.license = "MIT"
|
spec.license = 'MIT'
|
||||||
spec.required_ruby_version = ">= 2.6.0"
|
spec.required_ruby_version = '>= 3.1.2'
|
||||||
|
|
||||||
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
||||||
|
|
||||||
spec.metadata["homepage_uri"] = spec.homepage
|
spec.metadata['homepage_uri'] = spec.homepage
|
||||||
spec.metadata["source_code_uri"] = "https://githuh.com/broosk1993/outboxable"
|
spec.metadata['source_code_uri'] = 'https://github.com/broosk1993/outboxable'
|
||||||
spec.metadata["changelog_uri"] = "https://githuh.com/broosk1993/outboxable/CHANGELOG.md"
|
spec.metadata['changelog_uri'] = 'https://github.com/broosk1993/outboxable/blob/main/CHANGELOG.md'
|
||||||
|
|
||||||
# Specify which files should be added to the gem when it is released.
|
# Specify which files should be added to the gem when it is released.
|
||||||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
||||||
@ -27,10 +27,11 @@ Gem::Specification.new do |spec|
|
|||||||
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
spec.bindir = "exe"
|
spec.bindir = 'exe'
|
||||||
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
||||||
spec.require_paths = ["lib"]
|
spec.require_paths = ['lib']
|
||||||
|
|
||||||
spec.add_dependency 'bunny', '>= 2.19.0'
|
spec.add_dependency 'bunny', '>= 2.19.0'
|
||||||
spec.add_dependency 'connection_pool', '~> 2.3.0'
|
spec.add_dependency 'connection_pool', '~> 2.3.0'
|
||||||
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'sidekiq/testing'
|
require 'sidekiq/testing'
|
||||||
|
|
||||||
RSpec.describe Outboxable do
|
RSpec.describe Outboxable do
|
||||||
it "has a version number" do
|
it 'has a version number' do
|
||||||
expect(Outboxable::VERSION).not_to be nil
|
expect(Outboxable::VERSION).not_to be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'polling publisher sidekiq worker' do
|
context 'polling publisher sidekiq worker' do
|
||||||
it "should be able to perform" do
|
it 'should be able to perform' do
|
||||||
expect {
|
expect do
|
||||||
Outboxable::PollingPublisherWorker.perform_async
|
Outboxable::PollingPublisherWorker.perform_async
|
||||||
}.to change(Outboxable::PollingPublisherWorker.jobs, :size).by(1)
|
end.to change(Outboxable::PollingPublisherWorker.jobs, :size).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "outboxable"
|
require 'outboxable'
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
# Enable flags like --only-failures and --next-failure
|
# Enable flags like --only-failures and --next-failure
|
||||||
config.example_status_persistence_file_path = ".rspec_status"
|
config.example_status_persistence_file_path = '.rspec_status'
|
||||||
|
|
||||||
# Disable RSpec exposing methods globally on `Module` and `main`
|
# Disable RSpec exposing methods globally on `Module` and `main`
|
||||||
config.disable_monkey_patching!
|
config.disable_monkey_patching!
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user