Class: Aeternitas::Pollable::Configuration
- Inherits:
-
Object
- Object
- Aeternitas::Pollable::Configuration
- Defined in:
- lib/aeternitas/pollable/configuration.rb
Overview
Holds the configuration of a pollable class
Instance Attribute Summary collapse
-
#after_polling ⇒ Object
Methods to be run after each successful poll.
-
#before_polling ⇒ Object
Methods to be run before each poll.
-
#deactivation_errors ⇒ Object
The pollable instance will be deactivated if any of these errors occur while polling.
-
#guard_options ⇒ Object
Configuration of the pollables lock (Default: key => class+id, cooldown => 5.seconds, timeout => 10.minutes).
-
#ignored_errors ⇒ Object
Errors in this list will be wrapped by Error::Ignored if they occur while polling (i.e. ignore in your exception tracker).
-
#polling_frequency ⇒ Object
Method that calculates the next polling time after a successful poll.
-
#queue ⇒ Object
Sidekiq queue the poll job will be enqueued in (Default: ‘polling’).
-
#sleep_on_guard_locked ⇒ Object
When set to true poll jobs (and effectively the Sidekiq worker thread) will sleep until the lock is released if the lock could not be acquired.
Instance Method Summary collapse
- #copy ⇒ Object
-
#initialize ⇒ Configuration
constructor
Creates a new Configuration with default options.
Constructor Details
#initialize ⇒ Configuration
Creates a new Configuration with default options
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/aeternitas/pollable/configuration.rb', line 34 def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end |
Instance Attribute Details
#after_polling ⇒ Object
Methods to be run after each successful poll
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#before_polling ⇒ Object
Methods to be run before each poll
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#deactivation_errors ⇒ Object
The pollable instance will be deactivated if any of these errors occur while polling
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#guard_options ⇒ Object
Configuration of the pollables lock (Default: key => class+id, cooldown => 5.seconds, timeout => 10.minutes)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#ignored_errors ⇒ Object
Errors in this list will be wrapped by Error::Ignored if they occur while polling (i.e. ignore in your exception tracker)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#polling_frequency ⇒ Object
Method that calculates the next polling time after a successful poll. (Default: Aeternitas::PollingFrequency::DAILY)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#queue ⇒ Object
Sidekiq queue the poll job will be enqueued in (Default: ‘polling’)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
#sleep_on_guard_locked ⇒ Object
When set to true poll jobs (and effectively the Sidekiq worker thread) will sleep until the lock is released if the lock could not be acquired. (Default: true)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aeternitas/pollable/configuration.rb', line 23 class Configuration attr_accessor :deactivation_errors, :before_polling, :queue, :polling_frequency, :after_polling, :guard_options, :ignored_errors, :sleep_on_guard_locked # Creates a new Configuration with default options def initialize @polling_frequency = Aeternitas::PollingFrequency::DAILY @before_polling = [] @after_polling = [] @guard_options = { key: ->(obj) { return obj.class.name.to_s }, timeout: 10.minutes, cooldown: 5.seconds } @deactivation_errors = [] @ignored_errors = [] @queue = 'polling' @sleep_on_guard_locked = true end def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end end |
Instance Method Details
#copy ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/aeternitas/pollable/configuration.rb', line 49 def copy config = Configuration.new config.polling_frequency = self.polling_frequency config.before_polling = self.before_polling.deep_dup config.after_polling = self.after_polling.deep_dup config. = self..deep_dup config.deactivation_errors = self.deactivation_errors.deep_dup config.ignored_errors = self.ignored_errors.deep_dup config.queue = self.queue config.sleep_on_guard_locked = self.sleep_on_guard_locked config end |