Class: CouchWarmer
- Inherits:
-
Object
- Object
- CouchWarmer
- Defined in:
- lib/couch-warmer.rb
Instance Method Summary collapse
-
#initialize(database) ⇒ CouchWarmer
constructor
database = ‘127.0.0.1:5984/dbname’.
-
#warm(name, suffix) ⇒ Object
name with suffix, suffix.
- #warm_all(suffix) ⇒ Object
Constructor Details
#initialize(database) ⇒ CouchWarmer
database = ‘127.0.0.1:5984/dbname’
5 6 7 |
# File 'lib/couch-warmer.rb', line 5 def initialize(database) @db = CouchRest.database(database) end |
Instance Method Details
#warm(name, suffix) ⇒ Object
name with suffix, suffix
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/couch-warmer.rb', line 24 def warm(name, suffix) puts "warming.. #{name} from #{name}#{suffix}" begin view_name = get_first_view(name + suffix) src = @db.view('_design/' + name + suffix + '/_view/' + view_name) rescue RestClient::RequestTimeout => e puts "working hard...." end msg = "still active.." counter = 1 while is_active? print '.' if counter % 5 == 0 sleep 1 counter += 1 end puts "copying.." after_warm(name + suffix, name) puts "warming #{name} from #{name}#{suffix} done!!!" end |
#warm_all(suffix) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/couch-warmer.rb', line 9 def warm_all(suffix) puts "warming all with suffix #{suffix}" designs = get_all_design_docs suffix designs.each do |design| puts "warming #{design}" begin warm(design.gsub(suffix, ''), suffix) rescue RestClient::InternalServerError => e puts "error 500 on warming #{design} ..... -> next!" end end end |