Class: Rabbit::Config
- Inherits:
-
Object
- Object
- Rabbit::Config
- Defined in:
- lib/rabbit.rb
Instance Attribute Summary collapse
-
#after_receiving_hooks ⇒ Object
Returns the value of attribute after_receiving_hooks.
-
#backoff_handler_max_retries ⇒ Object
Returns the value of attribute backoff_handler_max_retries.
-
#before_receiving_hooks ⇒ Object
Returns the value of attribute before_receiving_hooks.
-
#connection_reset_exceptions ⇒ Object
Returns the value of attribute connection_reset_exceptions.
-
#connection_reset_max_retries ⇒ Object
Returns the value of attribute connection_reset_max_retries.
-
#connection_reset_timeout ⇒ Object
Returns the value of attribute connection_reset_timeout.
-
#default_publishing_job_queue ⇒ Object
Returns the value of attribute default_publishing_job_queue.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#exception_notifier ⇒ Object
Returns the value of attribute exception_notifier.
-
#group_id ⇒ Object
Returns the value of attribute group_id.
-
#handler_resolver_callable ⇒ Object
Returns the value of attribute handler_resolver_callable.
-
#hooks ⇒ Object
Returns the value of attribute hooks.
-
#logger_message_size_limit ⇒ Object
Returns the value of attribute logger_message_size_limit.
- #malformed_logger ⇒ Object
-
#project_id ⇒ Object
Returns the value of attribute project_id.
- #publish_logger ⇒ Object
-
#publishing_job_class_callable ⇒ Object
Returns the value of attribute publishing_job_class_callable.
-
#queue_name_conversion ⇒ Object
Returns the value of attribute queue_name_conversion.
-
#queue_suffix ⇒ Object
Returns the value of attribute queue_suffix.
- #receive_logger ⇒ Object
-
#receiving_job_class_callable ⇒ Object
Returns the value of attribute receiving_job_class_callable.
-
#skip_publishing_in ⇒ Object
Returns the value of attribute skip_publishing_in.
-
#use_backoff_handler ⇒ Object
Returns the value of attribute use_backoff_handler.
Instance Method Summary collapse
- #app_name ⇒ Object
-
#initialize(group_id: nil, project_id: nil, queue_suffix: nil, hooks: {}, environment: :production, queue_name_conversion: nil, receiving_job_class_callable: nil, publishing_job_class_callable: nil, default_publishing_job_queue: :default, handler_resolver_callable: nil, exception_notifier: nil, before_receiving_hooks: [], after_receiving_hooks: [], skip_publishing_in: %i[test development],, use_backoff_handler: false, backoff_handler_max_retries: 6, connection_reset_max_retries: 10, connection_reset_timeout: 0.2, connection_reset_exceptions: [Bunny::ConnectionClosedError], logger_message_size_limit: 9_500, receive_logger: nil, publish_logger: nil, malformed_logger: nil) ⇒ Config
constructor
rubocop:disable Metrics/MethodLength.
- #read_queue ⇒ Object
- #skip_publish? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(group_id: nil, project_id: nil, queue_suffix: nil, hooks: {}, environment: :production, queue_name_conversion: nil, receiving_job_class_callable: nil, publishing_job_class_callable: nil, default_publishing_job_queue: :default, handler_resolver_callable: nil, exception_notifier: nil, before_receiving_hooks: [], after_receiving_hooks: [], skip_publishing_in: %i[test development],, use_backoff_handler: false, backoff_handler_max_retries: 6, connection_reset_max_retries: 10, connection_reset_timeout: 0.2, connection_reset_exceptions: [Bunny::ConnectionClosedError], logger_message_size_limit: 9_500, receive_logger: nil, publish_logger: nil, malformed_logger: nil) ⇒ Config
rubocop:disable Metrics/MethodLength
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rabbit.rb', line 39 def initialize( # rubocop:disable Metrics/MethodLength group_id: nil, project_id: nil, queue_suffix: nil, hooks: {}, environment: :production, queue_name_conversion: nil, receiving_job_class_callable: nil, publishing_job_class_callable: nil, default_publishing_job_queue: :default, handler_resolver_callable: nil, exception_notifier: nil, before_receiving_hooks: [], after_receiving_hooks: [], skip_publishing_in: %i[test development], use_backoff_handler: false, backoff_handler_max_retries: 6, connection_reset_max_retries: 10, connection_reset_timeout: 0.2, connection_reset_exceptions: [Bunny::ConnectionClosedError], logger_message_size_limit: 9_500, receive_logger: nil, publish_logger: nil, malformed_logger: nil ) self.group_id = group_id self.project_id = project_id self.queue_suffix = queue_suffix self.hooks = hooks self.environment = environment.to_sym self.queue_name_conversion = queue_name_conversion self.receiving_job_class_callable = receiving_job_class_callable self.publishing_job_class_callable = publishing_job_class_callable self.default_publishing_job_queue = default_publishing_job_queue self.handler_resolver_callable = handler_resolver_callable self.exception_notifier = exception_notifier self.before_receiving_hooks = before_receiving_hooks self.after_receiving_hooks = after_receiving_hooks self.skip_publishing_in = skip_publishing_in self.use_backoff_handler = use_backoff_handler self.backoff_handler_max_retries = backoff_handler_max_retries self.connection_reset_max_retries = connection_reset_max_retries self.connection_reset_timeout = connection_reset_timeout self.connection_reset_exceptions = connection_reset_exceptions self. = @receive_logger = receive_logger @publish_logger = publish_logger @malformed_logger = malformed_logger end |
Instance Attribute Details
#after_receiving_hooks ⇒ Object
Returns the value of attribute after_receiving_hooks.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def after_receiving_hooks @after_receiving_hooks end |
#backoff_handler_max_retries ⇒ Object
Returns the value of attribute backoff_handler_max_retries.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def backoff_handler_max_retries @backoff_handler_max_retries end |
#before_receiving_hooks ⇒ Object
Returns the value of attribute before_receiving_hooks.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def before_receiving_hooks @before_receiving_hooks end |
#connection_reset_exceptions ⇒ Object
Returns the value of attribute connection_reset_exceptions.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def connection_reset_exceptions @connection_reset_exceptions end |
#connection_reset_max_retries ⇒ Object
Returns the value of attribute connection_reset_max_retries.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def connection_reset_max_retries @connection_reset_max_retries end |
#connection_reset_timeout ⇒ Object
Returns the value of attribute connection_reset_timeout.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def connection_reset_timeout @connection_reset_timeout end |
#default_publishing_job_queue ⇒ Object
Returns the value of attribute default_publishing_job_queue.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def default_publishing_job_queue @default_publishing_job_queue end |
#environment ⇒ Object
Returns the value of attribute environment.
36 37 38 |
# File 'lib/rabbit.rb', line 36 def environment @environment end |
#exception_notifier ⇒ Object
Returns the value of attribute exception_notifier.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def exception_notifier @exception_notifier end |
#group_id ⇒ Object
Returns the value of attribute group_id.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def group_id @group_id end |
#handler_resolver_callable ⇒ Object
Returns the value of attribute handler_resolver_callable.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def handler_resolver_callable @handler_resolver_callable end |
#hooks ⇒ Object
Returns the value of attribute hooks.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def hooks @hooks end |
#logger_message_size_limit ⇒ Object
Returns the value of attribute logger_message_size_limit.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def @logger_message_size_limit end |
#malformed_logger ⇒ Object
120 121 122 |
# File 'lib/rabbit.rb', line 120 def malformed_logger @malformed_logger || default_malformed_logger end |
#project_id ⇒ Object
Returns the value of attribute project_id.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def project_id @project_id end |
#publish_logger ⇒ Object
116 117 118 |
# File 'lib/rabbit.rb', line 116 def publish_logger @publish_logger || default_publish_logger end |
#publishing_job_class_callable ⇒ Object
Returns the value of attribute publishing_job_class_callable.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def publishing_job_class_callable @publishing_job_class_callable end |
#queue_name_conversion ⇒ Object
Returns the value of attribute queue_name_conversion.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def queue_name_conversion @queue_name_conversion end |
#queue_suffix ⇒ Object
Returns the value of attribute queue_suffix.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def queue_suffix @queue_suffix end |
#receive_logger ⇒ Object
112 113 114 |
# File 'lib/rabbit.rb', line 112 def receive_logger @receive_logger || default_receive_logger end |
#receiving_job_class_callable ⇒ Object
Returns the value of attribute receiving_job_class_callable.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def receiving_job_class_callable @receiving_job_class_callable end |
#skip_publishing_in ⇒ Object
Returns the value of attribute skip_publishing_in.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def skip_publishing_in @skip_publishing_in end |
#use_backoff_handler ⇒ Object
Returns the value of attribute use_backoff_handler.
16 17 18 |
# File 'lib/rabbit.rb', line 16 def use_backoff_handler @use_backoff_handler end |
Instance Method Details
#app_name ⇒ Object
104 105 106 |
# File 'lib/rabbit.rb', line 104 def app_name [group_id, project_id].join(".") end |
#read_queue ⇒ Object
108 109 110 |
# File 'lib/rabbit.rb', line 108 def read_queue [app_name, queue_suffix].reject { |x| x.nil? || x.empty? }.join(".") end |
#skip_publish? ⇒ Boolean
100 101 102 |
# File 'lib/rabbit.rb', line 100 def skip_publish? skip_publishing_in.include?(environment) end |
#validate! ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/rabbit.rb', line 90 def validate! raise InvalidConfig, "missing project_id" unless project_id raise InvalidConfig, "missing group_id" unless group_id raise InvalidConfig, "missing exception_notifier" unless exception_notifier unless %i[test development production].include?(environment) raise "environment should be one of (test, development, production)" end end |