Class: ActivePublisher::Configuration
- Inherits:
-
Object
- Object
- ActivePublisher::Configuration
- Defined in:
- lib/active_publisher/configuration.rb
Constant Summary collapse
- CONFIGURATION_MUTEX =
::Mutex.new
- NETWORK_RECOVERY_INTERVAL =
1.freeze
- DEFAULTS =
{ :error_handler => lambda { |error, env_hash| ::ActivePublisher::Logging.logger.error(error.class) ::ActivePublisher::Logging.logger.error(error.) ::ActivePublisher::Logging.logger.error(error.backtrace.join("\n")) if error.backtrace.respond_to?(:join) }, :heartbeat => 5, :host => "localhost", :hosts => [], :password => "guest", :messages_per_batch => 25, :max_async_publisher_lag_time => 10, :max_payload_bytes => nil, :network_recovery_interval => NETWORK_RECOVERY_INTERVAL, :port => 5672, :publisher_threads => 1, :publisher_confirms => false, :publisher_confirms_timeout => 5_000, #specified as a number of milliseconds :seconds_to_wait_for_graceful_shutdown => 30, :timeout => 1, :tls => false, :tls_ca_certificates => [], :tls_cert => nil, :tls_key => nil, :username => "guest", :verify_peer => true, :virtual_host => "/" }
Instance Attribute Summary collapse
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#heartbeat ⇒ Object
Returns the value of attribute heartbeat.
-
#host ⇒ Object
Returns the value of attribute host.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#max_async_publisher_lag_time ⇒ Object
Returns the value of attribute max_async_publisher_lag_time.
-
#max_payload_bytes ⇒ Object
Returns the value of attribute max_payload_bytes.
-
#messages_per_batch ⇒ Object
Returns the value of attribute messages_per_batch.
-
#network_recovery_interval ⇒ Object
Returns the value of attribute network_recovery_interval.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#publisher_confirms ⇒ Object
Returns the value of attribute publisher_confirms.
-
#publisher_confirms_timeout ⇒ Object
Returns the value of attribute publisher_confirms_timeout.
-
#publisher_threads ⇒ Object
Returns the value of attribute publisher_threads.
-
#seconds_to_wait_for_graceful_shutdown ⇒ Object
Returns the value of attribute seconds_to_wait_for_graceful_shutdown.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#tls ⇒ Object
Returns the value of attribute tls.
-
#tls_ca_certificates ⇒ Object
Returns the value of attribute tls_ca_certificates.
-
#tls_cert ⇒ Object
Returns the value of attribute tls_cert.
-
#tls_key ⇒ Object
Returns the value of attribute tls_key.
-
#username ⇒ Object
Returns the value of attribute username.
-
#verify_peer ⇒ Object
Returns the value of attribute verify_peer.
-
#virtual_host ⇒ Object
Returns the value of attribute virtual_host.
Class Method Summary collapse
Instance Method Summary collapse
- #connection_string=(url) ⇒ Object
-
#initialize ⇒ Configuration
constructor
Instance Methods.
Constructor Details
#initialize ⇒ Configuration
Instance Methods
119 120 121 122 123 |
# File 'lib/active_publisher/configuration.rb', line 119 def initialize DEFAULTS.each_pair do |key, value| self.__send__("#{key}=", value) end end |
Instance Attribute Details
#error_handler ⇒ Object
Returns the value of attribute error_handler.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def error_handler @error_handler end |
#heartbeat ⇒ Object
Returns the value of attribute heartbeat.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def heartbeat @heartbeat end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def host @host end |
#hosts ⇒ Object
Returns the value of attribute hosts.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def hosts @hosts end |
#max_async_publisher_lag_time ⇒ Object
Returns the value of attribute max_async_publisher_lag_time.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def max_async_publisher_lag_time @max_async_publisher_lag_time end |
#max_payload_bytes ⇒ Object
Returns the value of attribute max_payload_bytes.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def max_payload_bytes @max_payload_bytes end |
#messages_per_batch ⇒ Object
Returns the value of attribute messages_per_batch.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def @messages_per_batch end |
#network_recovery_interval ⇒ Object
Returns the value of attribute network_recovery_interval.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def network_recovery_interval @network_recovery_interval end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def port @port end |
#publisher_confirms ⇒ Object
Returns the value of attribute publisher_confirms.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def publisher_confirms @publisher_confirms end |
#publisher_confirms_timeout ⇒ Object
Returns the value of attribute publisher_confirms_timeout.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def publisher_confirms_timeout @publisher_confirms_timeout end |
#publisher_threads ⇒ Object
Returns the value of attribute publisher_threads.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def publisher_threads @publisher_threads end |
#seconds_to_wait_for_graceful_shutdown ⇒ Object
Returns the value of attribute seconds_to_wait_for_graceful_shutdown.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def seconds_to_wait_for_graceful_shutdown @seconds_to_wait_for_graceful_shutdown end |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def timeout @timeout end |
#tls ⇒ Object
Returns the value of attribute tls.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def tls @tls end |
#tls_ca_certificates ⇒ Object
Returns the value of attribute tls_ca_certificates.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def tls_ca_certificates @tls_ca_certificates end |
#tls_cert ⇒ Object
Returns the value of attribute tls_cert.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def tls_cert @tls_cert end |
#tls_key ⇒ Object
Returns the value of attribute tls_key.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def tls_key @tls_key end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def username @username end |
#verify_peer ⇒ Object
Returns the value of attribute verify_peer.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def verify_peer @verify_peer end |
#virtual_host ⇒ Object
Returns the value of attribute virtual_host.
6 7 8 |
# File 'lib/active_publisher/configuration.rb', line 6 def virtual_host @virtual_host end |
Class Method Details
.configure_from_yaml_and_cli(cli_options = {}, reload = false) ⇒ Object
Class Methods
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/active_publisher/configuration.rb', line 64 def self.configure_from_yaml_and_cli( = {}, 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, , yaml_config) ::ActivePublisher.configuration.public_send("#{key}=", setting) if exists end true end end end |
Instance Method Details
#connection_string=(url) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/active_publisher/configuration.rb', line 125 def connection_string=(url) settings = ::ActionSubscriber::URI.parse_amqp_url(url) settings.each do |key, value| send("#{key}=", value) end end |