Class: Backup::Syncer::Cloud::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/syncer/cloud/base.rb

Direct Known Subclasses

CloudFiles

Defined Under Namespace

Classes: LocalFile, SyncContext

Constant Summary collapse

MUTEX =

Create a Mutex to synchronize certain parts of the code in order to prevent race conditions or broken STDOUT.

Mutex.new

Constants included from CLI::Helpers

CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Attributes inherited from Base

#mirror, #path

Instance Method Summary collapse

Methods inherited from Base

#add, #directories

Methods included from Configuration::Helpers

included

Constructor Details

#initializeBase

Instantiates a new Cloud Syncer object for either the Cloud::S3 or Cloud::CloudFiles Syncer.

Pre-configured defaults specified in either Configuration::Syncer::Cloud::S3 or Configuration::Syncer::Cloud::CloudFiles are set via a super() call to Syncer::Base.

If not specified in the pre-configured defaults, the Cloud specific defaults are set here before evaluating any block provided in the user's configuration file.


42
43
44
45
46
47
# File 'lib/backup/syncer/cloud/base.rb', line 42

def initialize
  super

  @concurrency_type  ||= false
  @concurrency_level ||= 2
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Configuration::Helpers

Instance Attribute Details

#concurrency_levelObject

Concurrency level - the number of threads or processors to use. Defaults to 2.


28
29
30
# File 'lib/backup/syncer/cloud/base.rb', line 28

def concurrency_level
  @concurrency_level
end

#concurrency_typeObject

Concurrency setting - defaults to false, but can be set to:

  • :threads

  • :processes


23
24
25
# File 'lib/backup/syncer/cloud/base.rb', line 23

def concurrency_type
  @concurrency_type
end

Instance Method Details

#perform!Object

Performs the Sync operation


51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/backup/syncer/cloud/base.rb', line 51

def perform!
  Logger.message(
    "#{ syncer_name } started the syncing process:\n" +
    "\s\sConcurrency: #{ @concurrency_type } Level: #{ @concurrency_level }"
  )

  @directories.each do |directory|
    SyncContext.new(
      File.expand_path(directory), repository_object, @path
    ).sync! @mirror, @concurrency_type, @concurrency_level
  end

  Logger.message("#{ syncer_name } Syncing Complete!")
end