Module: QueueKit::Clients::CommandTimeout
- Defined in:
- lib/queue_kit/clients/command_timeout.rb
Class Method Summary collapse
Instance Method Summary collapse
- #command_clients_size ⇒ Object
- #command_timeout(attempts = 0) ⇒ Object
- #command_timeout_from(options) ⇒ Object
- #command_timeout_ms ⇒ Object
- #max_command_timeout_ms ⇒ Object
Class Method Details
.with_ivars(klass) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/queue_kit/clients/command_timeout.rb', line 4 def self.with_ivars(klass) mod = self klass.class_eval do include mod attr_accessor :command_timeout_ms attr_accessor :max_command_timeout_ms end end |
Instance Method Details
#command_clients_size ⇒ Object
37 38 39 |
# File 'lib/queue_kit/clients/command_timeout.rb', line 37 def command_clients_size 1 end |
#command_timeout(attempts = 0) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/queue_kit/clients/command_timeout.rb', line 13 def command_timeout(attempts = 0) timeout = command_timeout_ms timeout += timeout * (attempts / command_clients_size).floor if timeout > (max = max_command_timeout_ms) timeout = max end timeout end |
#command_timeout_from(options) ⇒ Object
24 25 26 27 |
# File 'lib/queue_kit/clients/command_timeout.rb', line 24 def command_timeout_from() @command_timeout_ms = [:command_timeout_ms] || 10 @max_command_timeout_ms = [:max_command_timeout_ms] || 1000 end |
#command_timeout_ms ⇒ Object
29 30 31 |
# File 'lib/queue_kit/clients/command_timeout.rb', line 29 def command_timeout_ms 10 end |
#max_command_timeout_ms ⇒ Object
33 34 35 |
# File 'lib/queue_kit/clients/command_timeout.rb', line 33 def max_command_timeout_ms 1000 end |