Class: Thinner::Client
- Inherits:
-
Object
- Object
- Thinner::Client
- Defined in:
- lib/thinner/client.rb
Overview
A Thinner::Client runs as a background process and purges a list of urls in batches.
Constant Summary collapse
- ERRORS =
The list of Errors we want to catch.
[Varnish::Error, Varnish::BrokenConnection, Varnish::CommandFailed, Timeout::Error, Errno::ECONNREFUSED]
Instance Attribute Summary collapse
-
#purged_urls ⇒ Object
readonly
A list of successfully purged urls.
Instance Method Summary collapse
-
#initialize(urls) ⇒ Client
constructor
Before purging, each Thinner::Client grabs various configuration settings and makes a copy of the passed in urls.
-
#run! ⇒ Object
Kickstart the purging process and loop through the array until there aren’t any urls left to purge.
Constructor Details
#initialize(urls) ⇒ Client
Before purging, each Thinner::Client grabs various configuration settings and makes a copy of the passed in urls.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/thinner/client.rb', line 17 def initialize(urls) @batch = Thinner.configuration.batch_length @timeout = Thinner.configuration.sleep_time @varnish = Varnish::Client.new Thinner.configuration.server @log_file = Thinner.configuration.log_file @purged_urls = [] @urls = Array.new urls @length = @urls.length logger handle_errors end |
Instance Attribute Details
#purged_urls ⇒ Object (readonly)
A list of successfully purged urls.
10 11 12 |
# File 'lib/thinner/client.rb', line 10 def purged_urls @purged_urls end |
Instance Method Details
#run! ⇒ Object
Kickstart the purging process and loop through the array until there aren’t any urls left to purge. Each time the loop runs it will update the process label with the first url in the list.
32 33 34 35 36 37 38 39 40 |
# File 'lib/thinner/client.rb', line 32 def run! while @urls.length > 0 @current_job = @urls.slice! 0, @batch $0 = "#{PROCESS_IDENTIFIER}: purging #{@current_job.first}" purge_urls sleep @timeout end close_log end |