lib/foreman_tasks/dynflow/configuration.rb in foreman-tasks-0.2.0 vs lib/foreman_tasks/dynflow/configuration.rb in foreman-tasks-0.2.1

- old
+ new

@@ -17,14 +17,10 @@ # if remote set to true, use this path for socket communication # between this process and the external executor attr_accessor :remote_socket_path - # what persistence adapater should be used, by default, it uses Sequlel - # adapter based on Rails app database.yml configuration - attr_accessor :persistence_adapter - # what transaction adapater should be used, by default, it uses the ActiveRecord # based adapter, expecting ActiveRecord is used as ORM in the application attr_accessor :transaction_adapter attr_accessor :eager_load_paths @@ -35,11 +31,10 @@ self.action_logger = Rails.logger self.dynflow_logger = Rails.logger self.pool_size = 5 self.remote = Rails.env.production? self.remote_socket_path = File.join(Rails.root, "tmp", "sockets", "dynflow_socket") - self.persistence_adapter = default_persistence_adapter self.transaction_adapter = ::Dynflow::TransactionAdapters::ActiveRecord.new self.eager_load_paths = [] self.lazy_initialization = !Rails.env.production? end @@ -57,19 +52,15 @@ # generates the options hash consumable by the Dynflow's world def world_options { logger_adapter: ::Dynflow::LoggerAdapters::Delegator.new(action_logger, dynflow_logger), pool_size: 5, - persistence_adapter: persistence_adapter, + persistence_adapter: initialize_persistence, transaction_adapter: transaction_adapter, executor: -> world { initialize_executor world } } end - def default_persistence_adapter - ForemanTasks::Dynflow::Persistence.new(default_sequel_adapter_options) - end - def default_sequel_adapter_options db_config = ActiveRecord::Base.configurations[Rails.env].dup db_config['adapter'] = 'postgres' if db_config['adapter'] == 'postgresql' if db_config['adapter'] == 'sqlite3' @@ -88,8 +79,13 @@ if self.remote? ::Dynflow::Executors::RemoteViaSocket.new(world, self.remote_socket_path) else ::Dynflow::Executors::Parallel.new(world, self.pool_size) end + end + + # Sequel adapter based on Rails app database.yml configuration + def initialize_persistence + ForemanTasks::Dynflow::Persistence.new(default_sequel_adapter_options) end end end