Class: Backup::Syncer::Cloud::Base
- Defined in:
- lib/backup/syncer/cloud/base.rb
Direct Known Subclasses
Constant Summary collapse
- MUTEX =
Mutex.new
Instance Attribute Summary collapse
-
#max_retries ⇒ Object
Number of times to retry failed operations.
-
#retry_waitsec ⇒ Object
Time in seconds to pause before each retry.
-
#thread_count ⇒ Object
Number of threads to use for concurrency.
Attributes inherited from Base
#excludes, #mirror, #path, #syncer_id
Instance Method Summary collapse
-
#initialize(syncer_id = nil, &block) ⇒ Base
constructor
A new instance of Base.
- #perform! ⇒ Object
Methods inherited from Base
Methods included from Config::Helpers
Methods included from Utilities::Helpers
Constructor Details
#initialize(syncer_id = nil, &block) ⇒ Base
Returns a new instance of Base.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/backup/syncer/cloud/base.rb', line 29 def initialize(syncer_id = nil, &block) super instance_eval(&block) if block_given? @thread_count ||= 0 @max_retries ||= 10 @retry_waitsec ||= 30 @path ||= 'backups' @path = path.sub(/^\//, '') end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#max_retries ⇒ Object
Number of times to retry failed operations.
Default: 10
21 22 23 |
# File 'lib/backup/syncer/cloud/base.rb', line 21 def max_retries @max_retries end |
#retry_waitsec ⇒ Object
Time in seconds to pause before each retry.
Default: 30
27 28 29 |
# File 'lib/backup/syncer/cloud/base.rb', line 27 def retry_waitsec @retry_waitsec end |
#thread_count ⇒ Object
Number of threads to use for concurrency.
Default: 0 (no concurrency)
15 16 17 |
# File 'lib/backup/syncer/cloud/base.rb', line 15 def thread_count @thread_count end |
Instance Method Details
#perform! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/backup/syncer/cloud/base.rb', line 41 def perform! log!(:started) @transfer_count = 0 @unchanged_count = 0 @skipped_count = 0 @orphans = thread_count > 0 ? Queue.new : [] directories.each {|dir| sync_directory(dir) } orphans_result = process_orphans Logger.info "\nSummary:" Logger.info "\s\sTransferred Files: #{ @transfer_count }" Logger.info "\s\s#{ orphans_result }" Logger.info "\s\sUnchanged Files: #{ @unchanged_count }" Logger.warn "\s\sSkipped Files: #{ @skipped_count }" if @skipped_count > 0 log!(:finished) end |