Class: Outboxable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/outboxable/configuration.rb

Constant Summary collapse

ALLOWED_MESSAGE_BROKERS =
%i[rabbitmq].freeze
ALLOWED_ORMS =
%i[activerecord mongoid].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/outboxable/configuration.rb', line 24

def initialize
  raise Error, 'Sidekiq is not available. Unfortunately, sidekiq must be available for Outboxable to work' unless Object.const_defined?('Sidekiq')
  raise Error, 'Outboxable Gem only supports Rails but you application does not seem to be a Rails app' unless Object.const_defined?('Rails')
  raise Error, 'Outboxable Gem only support Rails version 7 and newer' if Rails::VERSION::MAJOR < 7
  raise Error, 'Outboxable Gem uses the sidekiq-cron Gem. Make sure you add it to your project' unless Object.const_defined?('Sidekiq::Cron')

  # In accordance to sidekiq-cron README: https://github.com/sidekiq-cron/sidekiq-cron#under-the-hood
  Sidekiq::Options[:cron_poll_interval] = 5

  # Create the cron job for the polling publisher
  Sidekiq::Cron::Job.create(name: 'OutboxablePollingPublisher', cron: '*/5 * * * * *', class: 'Outboxable::PollingPublisherWorker')
end

Instance Attribute Details

#message_brokerObject

Returns the value of attribute message_broker.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def message_broker
  @message_broker
end

#ormObject

Returns the value of attribute orm.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def orm
  @orm
end

#rabbitmq_exchange_nameObject

Returns the value of attribute rabbitmq_exchange_name.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def rabbitmq_exchange_name
  @rabbitmq_exchange_name
end

#rabbitmq_hostObject

Returns the value of attribute rabbitmq_host.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def rabbitmq_host
  @rabbitmq_host
end

#rabbitmq_passwordObject

Returns the value of attribute rabbitmq_password.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def rabbitmq_password
  @rabbitmq_password
end

#rabbitmq_portObject

Returns the value of attribute rabbitmq_port.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def rabbitmq_port
  @rabbitmq_port
end

#rabbitmq_userObject

Returns the value of attribute rabbitmq_user.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def rabbitmq_user
  @rabbitmq_user
end

#rabbitmq_vhostObject

Returns the value of attribute rabbitmq_vhost.



15
16
17
# File 'lib/outboxable/configuration.rb', line 15

def rabbitmq_vhost
  @rabbitmq_vhost
end