lib/tobox/configuration.rb in tobox-0.5.1 vs lib/tobox/configuration.rb in tobox-0.5.2
- old
+ new
@@ -18,10 +18,11 @@
log_level: nil,
database_uri: nil,
database_options: nil,
table: :outbox,
created_at_column: nil,
+ batch_size: 1,
max_attempts: 10,
exponential_retry_factor: 2,
wait_for_events_delay: 5,
shutdown_timeout: 10,
grace_shutdown_timeout: 5,
@@ -62,11 +63,11 @@
@default_logger = @config[:logger] || Logger.new(STDERR, formatter: DEFAULT_LOG_FORMATTER) # rubocop:disable Style/GlobalStdStream
@default_logger.level = @config[:log_level] || (env == "production" ? Logger::INFO : Logger::DEBUG)
@database = if @config[:database_uri]
database_opts = @config[:database_options] || {}
- database_opts[:max_connections] = @config[:concurrency] if @config[:worker] == :thread
+ database_opts[:max_connections] ||= (@config[:concurrency] if @config[:worker] == :thread)
db = Sequel.connect(@config[:database_uri].to_s, database_opts)
Array(@lifecycle_events[:database_connect]).each { |cb| cb.call(db) }
db
else
Sequel::DATABASES.first
@@ -81,12 +82,13 @@
end
freeze
end
- def on(*events, &callback)
- events.each do |event|
- (@handlers[event.to_sym] ||= []) << callback
+ def on(*event_types, &callback)
+ callback_events = (@handlers[callback] ||= [])
+ event_types.each do |event_type|
+ callback_events << event_type.to_sym
end
self
end
def on_start(&callback)