Class: Beetle::Configuration
- Inherits:
-
Object
- Object
- Beetle::Configuration
- Defined in:
- lib/beetle/configuration.rb
Instance Attribute Summary collapse
-
#additional_subscription_servers ⇒ Object
list of additional amqp servers to use for subscribers (defaults to
""
). -
#api_port ⇒ Object
Returns the port on which the Rabbit API is hosted.
-
#beetle_policy_exchange_name ⇒ Object
system_exchange_name is the name of the exchange on which to publish system internal messages, such as messages to set up queue policies.
-
#beetle_policy_updates_queue_name ⇒ Object
Name of the policy update queue.
-
#beetle_policy_updates_routing_key ⇒ Object
Name of the policy update routing key.
-
#broker_default_policy ⇒ Object
default logger (defaults to
Logger.new(log_file)
). -
#channel_max ⇒ Object
the max number of channels the publisher tries to negotiate with the server.
-
#config_file ⇒ Object
external config file (defaults to
no file
). -
#dead_lettering_enabled ⇒ Object
(also: #dead_lettering_enabled?)
In contrast to RabbitMQ 2.x, RabbitMQ 3.x preserves message order when requeing a message.
-
#dead_lettering_msg_ttl ⇒ Object
The time a message spends in the dead letter queue if dead lettering is enabled, before it is returned to the original queue.
-
#frame_max ⇒ Object
the maximum permissible size of a frame (in bytes).
-
#gc_threshold ⇒ Object
number of seconds after which keys are removed from the message deduplication store (defaults to
1.hour
). -
#lazy_queues_enabled ⇒ Object
(also: #lazy_queues_enabled?)
Lazy queues have the advantage of consuming a lot less memory on the broker.
-
#log_file ⇒ Object
set this to a logger instance if you want redis operations to be logged.
-
#logger ⇒ Object
set this to whatever your brokers have installed as default policy.
-
#password ⇒ Object
the password to use when connectiong to the AMQP servers (defaults to
"guest"
). -
#prefetch_count ⇒ Object
Prefetch count for subscribers (defaults to 1).
-
#publisher_connect_timeout ⇒ Object
the connect/disconnect timeout in seconds for the publishing connection (defaults to
5
). -
#publishing_timeout ⇒ Object
the socket timeout in seconds for message publishing (defaults to
0
). -
#rabbitmq_api_read_timeout ⇒ Object
Read timeout for http requests to RabbitMQ HTTP API.
-
#rabbitmq_api_write_timeout ⇒ Object
Write timeout for http requests to RabbitMQ HTTP API.
-
#redis_configuration_client_ids ⇒ Object
the redis configuration client ids living on the worker machines taking part in the redis failover, separated by comma (defaults to
""
). -
#redis_configuration_client_timeout ⇒ Object
number of seconds the redis configuration server waits for answers from clients (defaults to
5
). -
#redis_configuration_master_retries ⇒ Object
redis configuration server options how often should the redis configuration server try to reach the redis master before nominating a new one (defaults to
3
). -
#redis_configuration_master_retry_interval ⇒ Object
number of seconds to wait between retries (defaults to
10
). -
#redis_connect_timeout ⇒ Object
redis connect timeout.
-
#redis_db ⇒ Object
redis database number to use for the message deduplication store (defaults to
4
). -
#redis_failover_client_dead_interval ⇒ Object
how long to wait until a redis_failover client daemon can be considered dead.
-
#redis_failover_client_heartbeat_interval ⇒ Object
how often heartbeat messages are exchanged between failover daemons.
-
#redis_failover_timeout ⇒ Object
how long we should repeatedly retry a redis operation before giving up, with a one second sleep between retries (defaults to
180.seconds
). -
#redis_logger ⇒ Object
defaults to
STDOUT
. -
#redis_read_timeout ⇒ Object
redis read timeout.
-
#redis_server ⇒ Object
the redis server to use for deduplication either a string like
"localhost:6379"
(default) or a file that contains the string. -
#redis_servers ⇒ Object
comma separated list of redis servers available for master/slave switching e.g.
-
#redis_status_key_expiry_interval ⇒ Object
how long we want status keys to survive after we have seen the second message of a redundant message pair.
-
#redis_write_timeout ⇒ Object
redis write timeout.
-
#servers ⇒ Object
list of amqp servers to use (defaults to
"localhost:5672"
). -
#system_name ⇒ Object
system name (used for redis cluster partitioning) (defaults to
system
). -
#throttling_refresh_interval ⇒ Object
refresh interval for determining queue lenghts for throttling.
-
#tmpdir ⇒ Object
directory to store large intermediate files (defaults ‘/tmp’).
-
#update_queue_properties_synchronously ⇒ Object
Whether to update quueue policies synchronously or asynchronously.
-
#user ⇒ Object
the AMQP user to use when connecting to the AMQP servers (defaults to
"guest"
). -
#vhost ⇒ Object
the virtual host to use on the AMQP servers (defaults to
"/"
).
Instance Method Summary collapse
-
#brokers ⇒ Object
returns the configured amqp brokers.
-
#initialize ⇒ Configuration
constructor
:nodoc:.
-
#redis_options ⇒ Object
redis optins to be passed to Redis.new.
-
#reload ⇒ Object
reloads the configuration from the configuration file if one is configured.
Constructor Details
#initialize ⇒ Configuration
:nodoc:
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/beetle/configuration.rb', line 155 def initialize #:nodoc: self.system_name = "system" self.beetle_policy_exchange_name = "beetle-policies" self.beetle_policy_updates_queue_name = "beetle-policy-updates" self.beetle_policy_updates_routing_key = "beetle.policy.update" self.broker_default_policy = {} self.gc_threshold = 1.hour.to_i self.redis_server = "localhost:6379" self.redis_servers = "" self.redis_db = 4 self.redis_connect_timeout = 5.0 self.redis_read_timeout = 5.0 self.redis_write_timeout = 5.0 self.redis_failover_timeout = 180.seconds self.redis_status_key_expiry_interval = 0.seconds self.redis_failover_client_heartbeat_interval = 10.seconds self.redis_failover_client_dead_interval = 60.seconds self.redis_configuration_master_retries = 3 self.redis_configuration_master_retry_interval = 10.seconds self.redis_configuration_client_timeout = 5.seconds self.redis_configuration_client_ids = "" self.servers = "localhost:5672" self.additional_subscription_servers = "" self.vhost = "/" self.user = "guest" self.password = "guest" self.api_port = 15672 self.frame_max = 131072 self.channel_max = 2047 self.prefetch_count = 1 self.dead_lettering_enabled = false self.dead_lettering_msg_ttl = 1000 # 1 second self.rabbitmq_api_read_timeout = 60 # 60 seconds self.rabbitmq_api_write_timeout = 60 # 60 seconds self.lazy_queues_enabled = false self.throttling_refresh_interval = 60 # seconds self.update_queue_properties_synchronously = false self.publishing_timeout = 0 self.publisher_connect_timeout = 5 # seconds self.tmpdir = "/tmp" self.log_file = STDOUT end |
Instance Attribute Details
#additional_subscription_servers ⇒ Object
list of additional amqp servers to use for subscribers (defaults to ""
)
77 78 79 |
# File 'lib/beetle/configuration.rb', line 77 def additional_subscription_servers @additional_subscription_servers end |
#api_port ⇒ Object
Returns the port on which the Rabbit API is hosted
122 123 124 |
# File 'lib/beetle/configuration.rb', line 122 def api_port @api_port end |
#beetle_policy_exchange_name ⇒ Object
system_exchange_name is the name of the exchange on which to publish system internal messages, such as messages to set up queue policies. Whenever a queue is declared in the client, either by publisher or consumer, a message with the queue policy parameters is sent to this exachange. (defaults to beetle
)
11 12 13 |
# File 'lib/beetle/configuration.rb', line 11 def beetle_policy_exchange_name @beetle_policy_exchange_name end |
#beetle_policy_updates_queue_name ⇒ Object
Name of the policy update queue
13 14 15 |
# File 'lib/beetle/configuration.rb', line 13 def beetle_policy_updates_queue_name @beetle_policy_updates_queue_name end |
#beetle_policy_updates_routing_key ⇒ Object
Name of the policy update routing key
15 16 17 |
# File 'lib/beetle/configuration.rb', line 15 def beetle_policy_updates_routing_key @beetle_policy_updates_routing_key end |
#broker_default_policy ⇒ Object
default logger (defaults to Logger.new(log_file)
)
17 18 19 |
# File 'lib/beetle/configuration.rb', line 17 def broker_default_policy @broker_default_policy end |
#channel_max ⇒ Object
the max number of channels the publisher tries to negotiate with the server. Defaults to 2047, which is the RabbitMQ default in 3.7. We can’t set this to 0 because of a bug in bunny.
89 90 91 |
# File 'lib/beetle/configuration.rb', line 89 def channel_max @channel_max end |
#config_file ⇒ Object
external config file (defaults to no file
)
145 146 147 |
# File 'lib/beetle/configuration.rb', line 145 def config_file @config_file end |
#dead_lettering_enabled ⇒ Object Also known as: dead_lettering_enabled?
In contrast to RabbitMQ 2.x, RabbitMQ 3.x preserves message order when requeing a message. This can lead to throughput degradation (when rejected messages block the processing of other messages at the head of the queue) in some cases.
This setting enables the creation of dead letter queues that mimic the old beetle behaviour on RabbitMQ 3.x. Instead of rejecting messages with “requeue => true”, beetle will setup dead letter queues for all queues, will reject messages with “requeue => false”, where messages are temporarily moved to the side and are republished to the end of the original queue when they expire in the dead letter queue.
By default this is turned off and needs to be explicitly enabled.
106 107 108 |
# File 'lib/beetle/configuration.rb', line 106 def dead_lettering_enabled @dead_lettering_enabled end |
#dead_lettering_msg_ttl ⇒ Object
The time a message spends in the dead letter queue if dead lettering is enabled, before it is returned to the original queue
111 112 113 |
# File 'lib/beetle/configuration.rb', line 111 def dead_lettering_msg_ttl @dead_lettering_msg_ttl end |
#frame_max ⇒ Object
the maximum permissible size of a frame (in bytes). defaults to 128 KB
85 86 87 |
# File 'lib/beetle/configuration.rb', line 85 def frame_max @frame_max end |
#gc_threshold ⇒ Object
number of seconds after which keys are removed from the message deduplication store (defaults to 1.hour
)
26 27 28 |
# File 'lib/beetle/configuration.rb', line 26 def gc_threshold @gc_threshold end |
#lazy_queues_enabled ⇒ Object Also known as: lazy_queues_enabled?
Lazy queues have the advantage of consuming a lot less memory on the broker. For backwards compatibility, they are disabled by default.
93 94 95 |
# File 'lib/beetle/configuration.rb', line 93 def lazy_queues_enabled @lazy_queues_enabled end |
#log_file ⇒ Object
set this to a logger instance if you want redis operations to be logged. defaults to nil
.
24 25 26 |
# File 'lib/beetle/configuration.rb', line 24 def log_file @log_file end |
#logger ⇒ Object
set this to whatever your brokers have installed as default policy. For example, if you have installed a policy that makes every queue lazy, it should be set to {"queue-moode" => "lazy"}
.
20 21 22 |
# File 'lib/beetle/configuration.rb', line 20 def logger @logger end |
#password ⇒ Object
the password to use when connectiong to the AMQP servers (defaults to "guest"
)
83 84 85 |
# File 'lib/beetle/configuration.rb', line 83 def password @password end |
#prefetch_count ⇒ Object
Prefetch count for subscribers (defaults to 1). Setting this higher than 1 can potentially increase throughput, but comes at the cost of decreased parallelism.
136 137 138 |
# File 'lib/beetle/configuration.rb', line 136 def prefetch_count @prefetch_count end |
#publisher_connect_timeout ⇒ Object
the connect/disconnect timeout in seconds for the publishing connection (defaults to 5
). consider this a highly experimental feature for now.
131 132 133 |
# File 'lib/beetle/configuration.rb', line 131 def publisher_connect_timeout @publisher_connect_timeout end |
#publishing_timeout ⇒ Object
the socket timeout in seconds for message publishing (defaults to 0
). consider this a highly experimental feature for now.
126 127 128 |
# File 'lib/beetle/configuration.rb', line 126 def publishing_timeout @publishing_timeout end |
#rabbitmq_api_read_timeout ⇒ Object
Read timeout for http requests to RabbitMQ HTTP API
117 118 119 |
# File 'lib/beetle/configuration.rb', line 117 def rabbitmq_api_read_timeout @rabbitmq_api_read_timeout end |
#rabbitmq_api_write_timeout ⇒ Object
Write timeout for http requests to RabbitMQ HTTP API
119 120 121 |
# File 'lib/beetle/configuration.rb', line 119 def rabbitmq_api_write_timeout @rabbitmq_api_write_timeout end |
#redis_configuration_client_ids ⇒ Object
the redis configuration client ids living on the worker machines taking part in the redis failover, separated by comma (defaults to ""
)
72 73 74 |
# File 'lib/beetle/configuration.rb', line 72 def redis_configuration_client_ids @redis_configuration_client_ids end |
#redis_configuration_client_timeout ⇒ Object
number of seconds the redis configuration server waits for answers from clients (defaults to 5
)
70 71 72 |
# File 'lib/beetle/configuration.rb', line 70 def redis_configuration_client_timeout @redis_configuration_client_timeout end |
#redis_configuration_master_retries ⇒ Object
redis configuration server options how often should the redis configuration server try to reach the redis master before nominating a new one (defaults to 3
)
66 67 68 |
# File 'lib/beetle/configuration.rb', line 66 def redis_configuration_master_retries @redis_configuration_master_retries end |
#redis_configuration_master_retry_interval ⇒ Object
number of seconds to wait between retries (defaults to 10
)
68 69 70 |
# File 'lib/beetle/configuration.rb', line 68 def redis_configuration_master_retry_interval @redis_configuration_master_retry_interval end |
#redis_connect_timeout ⇒ Object
redis connect timeout. defaults to 5 seconds.
37 38 39 |
# File 'lib/beetle/configuration.rb', line 37 def redis_connect_timeout @redis_connect_timeout end |
#redis_db ⇒ Object
redis database number to use for the message deduplication store (defaults to 4
)
35 36 37 |
# File 'lib/beetle/configuration.rb', line 35 def redis_db @redis_db end |
#redis_failover_client_dead_interval ⇒ Object
how long to wait until a redis_failover client daemon can be considered dead. defaults to 60 seconds.
62 63 64 |
# File 'lib/beetle/configuration.rb', line 62 def redis_failover_client_dead_interval @redis_failover_client_dead_interval end |
#redis_failover_client_heartbeat_interval ⇒ Object
how often heartbeat messages are exchanged between failover daemons. defaults to 10 seconds.
58 59 60 |
# File 'lib/beetle/configuration.rb', line 58 def redis_failover_client_heartbeat_interval @redis_failover_client_heartbeat_interval end |
#redis_failover_timeout ⇒ Object
how long we should repeatedly retry a redis operation before giving up, with a one second sleep between retries (defaults to 180.seconds
). this value needs to be somewehere between the maximum time it takes to auto-switch redis and the smallest handler timeout.
47 48 49 |
# File 'lib/beetle/configuration.rb', line 47 def redis_failover_timeout @redis_failover_timeout end |
#redis_logger ⇒ Object
defaults to STDOUT
22 23 24 |
# File 'lib/beetle/configuration.rb', line 22 def redis_logger @redis_logger end |
#redis_read_timeout ⇒ Object
redis read timeout. defaults to 5 seconds.
39 40 41 |
# File 'lib/beetle/configuration.rb', line 39 def redis_read_timeout @redis_read_timeout end |
#redis_server ⇒ Object
the redis server to use for deduplication either a string like "localhost:6379"
(default) or a file that contains the string. use a file if you are using a beetle configuration_client process to update it for automatic redis failover.
30 31 32 |
# File 'lib/beetle/configuration.rb', line 30 def redis_server @redis_server end |
#redis_servers ⇒ Object
comma separated list of redis servers available for master/slave switching e.g. “192.168.1.2:6379,192.168.1.3:6379”
33 34 35 |
# File 'lib/beetle/configuration.rb', line 33 def redis_servers @redis_servers end |
#redis_status_key_expiry_interval ⇒ Object
how long we want status keys to survive after we have seen the second message of a redundant message pair. Defaults to 0 seconds, but will be set to something non-zero with the next major beetle release. A recommended value would be 5 minutes (300 seconds). Setting this to a high value (hours) will reduce the likelihood of executing handler logic more than once, but can cause a higher redis database size with all associated problems.
54 55 56 |
# File 'lib/beetle/configuration.rb', line 54 def redis_status_key_expiry_interval @redis_status_key_expiry_interval end |
#redis_write_timeout ⇒ Object
redis write timeout. defaults to 5 seconds.
41 42 43 |
# File 'lib/beetle/configuration.rb', line 41 def redis_write_timeout @redis_write_timeout end |
#servers ⇒ Object
list of amqp servers to use (defaults to "localhost:5672"
)
75 76 77 |
# File 'lib/beetle/configuration.rb', line 75 def servers @servers end |
#system_name ⇒ Object
system name (used for redis cluster partitioning) (defaults to system
)
7 8 9 |
# File 'lib/beetle/configuration.rb', line 7 def system_name @system_name end |
#throttling_refresh_interval ⇒ Object
refresh interval for determining queue lenghts for throttling.
139 140 141 |
# File 'lib/beetle/configuration.rb', line 139 def throttling_refresh_interval @throttling_refresh_interval end |
#tmpdir ⇒ Object
directory to store large intermediate files (defaults ‘/tmp’)
142 143 144 |
# File 'lib/beetle/configuration.rb', line 142 def tmpdir @tmpdir end |
#update_queue_properties_synchronously ⇒ Object
Whether to update quueue policies synchronously or asynchronously.
114 115 116 |
# File 'lib/beetle/configuration.rb', line 114 def update_queue_properties_synchronously @update_queue_properties_synchronously end |
#user ⇒ Object
the AMQP user to use when connecting to the AMQP servers (defaults to "guest"
)
81 82 83 |
# File 'lib/beetle/configuration.rb', line 81 def user @user end |
#vhost ⇒ Object
the virtual host to use on the AMQP servers (defaults to "/"
)
79 80 81 |
# File 'lib/beetle/configuration.rb', line 79 def vhost @vhost end |
Instance Method Details
#brokers ⇒ Object
returns the configured amqp brokers
148 149 150 151 152 153 |
# File 'lib/beetle/configuration.rb', line 148 def brokers { 'servers' => self.servers, 'additional_subscription_servers' => self.additional_subscription_servers } end |
#redis_options ⇒ Object
redis optins to be passed to Redis.new
230 231 232 233 234 235 236 237 238 |
# File 'lib/beetle/configuration.rb', line 230 def { db: redis_db, connect_timeout: redis_connect_timeout, read_timeout: redis_read_timeout, write_timeout: redis_write_timeout, logger: redis_logger, } end |
#reload ⇒ Object
reloads the configuration from the configuration file if one is configured
214 215 216 |
# File 'lib/beetle/configuration.rb', line 214 def reload load_config if @config_file end |