class ActivePublisher::Configuration
Constants
- CONFIGURATION_MUTEX
- DEFAULTS
- NETWORK_RECOVERY_INTERVAL
Attributes
error_handler[RW]
heartbeat[RW]
host[RW]
hosts[RW]
max_async_publisher_lag_time[RW]
messages_per_batch[RW]
network_recovery_interval[RW]
password[RW]
port[RW]
publisher_confirms[RW]
publisher_confirms_timeout[RW]
publisher_threads[RW]
seconds_to_wait_for_graceful_shutdown[RW]
timeout[RW]
tls[RW]
tls_ca_certificates[RW]
tls_cert[RW]
tls_key[RW]
username[RW]
verify_peer[RW]
virtual_host[RW]
Public Class Methods
configure_from_yaml_and_cli(cli_options = {}, reload = false)
click to toggle source
Class Methods
# File lib/active_publisher/configuration.rb, line 62 def self.configure_from_yaml_and_cli(cli_options = {}, reload = false) CONFIGURATION_MUTEX.synchronize do @configure_from_yaml_and_cli = nil if reload @configure_from_yaml_and_cli ||= begin env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["APP_ENV"] || "development" yaml_config = attempt_to_load_yaml_file(env) DEFAULTS.each_pair do |key, value| exists, setting = fetch_config_value(key, cli_options, yaml_config) ::ActivePublisher.configuration.public_send("#{key}=", setting) if exists end true end end end
new()
click to toggle source
Instance Methods
# File lib/active_publisher/configuration.rb, line 117 def initialize DEFAULTS.each_pair do |key, value| self.__send__("#{key}=", value) end end
Private Class Methods
attempt_to_load_yaml_file(env)
click to toggle source
Private class methods
# File lib/active_publisher/configuration.rb, line 82 def self.attempt_to_load_yaml_file(env) yaml_config = {} absolute_config_path = ::File.expand_path(::File.join("config", "active_publisher.yml")) action_subscriber_config_file = ::File.expand_path(::File.join("config", "action_subscriber.yml")) if ::File.exists?(absolute_config_path) yaml_config = load_yaml_config_from_file(absolute_config_path)[env] elsif ::File.exists?(action_subscriber_config_file) yaml_config = load_yaml_config_from_file(action_subscriber_config_file)[env] end yaml_config end
fetch_config_value(key, cli_options, yaml_config)
click to toggle source
# File lib/active_publisher/configuration.rb, line 97 def self.fetch_config_value(key, cli_options, yaml_config) return [true, cli_options[key]] if cli_options.key?(key) return [true, cli_options[key.to_s]] if cli_options.key?(key.to_s) return [true, yaml_config[key]] if yaml_config.key?(key) return [true, yaml_config[key.to_s]] if yaml_config.key?(key.to_s) [false, nil] end
load_yaml_config_from_file(file_path)
click to toggle source
# File lib/active_publisher/configuration.rb, line 106 def self.load_yaml_config_from_file(file_path) erb_yaml = ::ERB.new(::File.read(file_path)).result # Defined in Psych 3.2+ and the new canonical way to load trusted documents: # https://github.com/ruby/psych/issues/533#issuecomment-1019363688 ::YAML.respond_to?(:unsafe_load) ? ::YAML.unsafe_load(erb_yaml) : ::YAML.load(erb_yaml) end
Public Instance Methods
connection_string=(url)
click to toggle source
# File lib/active_publisher/configuration.rb, line 123 def connection_string=(url) settings = ::ActionSubscriber::URI.parse_amqp_url(url) settings.each do |key, value| send("#{key}=", value) end end