Class: Polipus::Plugin::Sleeper
- Inherits:
-
Object
- Object
- Polipus::Plugin::Sleeper
- Defined in:
- lib/polipus/plugins/sleeper.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Sleeper
constructor
A new instance of Sleeper.
- #on_initialize(crawler) ⇒ Object
- #on_message_processed(_crawler) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Sleeper
Returns a new instance of Sleeper.
5 6 7 |
# File 'lib/polipus/plugins/sleeper.rb', line 5 def initialize( = {}) @delay = [:delay] ||= 1 end |
Instance Method Details
#on_initialize(crawler) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/polipus/plugins/sleeper.rb', line 9 def on_initialize(crawler) crawler.logger.info { "Sleeper plugin loaded, sleep for #{@delay} after each request" } proc do # Set to 1 the number of threads @options[:workers] = 1 end end |
#on_message_processed(_crawler) ⇒ Object
17 18 19 |
# File 'lib/polipus/plugins/sleeper.rb', line 17 def (_crawler) sleep @delay end |