Class: MultiSync::Client
- Inherits:
-
Object
- Object
- MultiSync::Client
- Includes:
- Helpers::Pluralize
- Defined in:
- lib/multi_sync/client.rb
Constant Summary collapse
- SUPPORTED_SOURCE_TYPES =
[[:local, MultiSync::LocalSource], [:manifest, MultiSync::ManifestSource]]
- SUPPORTED_TARGET_TYPES =
[[:local, MultiSync::LocalTarget], [:aws, MultiSync::AwsTarget]]
Instance Method Summary collapse
- #add_source(clazz, options = {}) ⇒ Object
- #add_target(clazz, options = {}) ⇒ Object
-
#initialize(*args) ⇒ Client
constructor
Initialize a new Client object.
- #sync ⇒ Object
Methods included from Helpers::Pluralize
Constructor Details
#initialize(*args) ⇒ Client
Initialize a new Client object
31 32 33 34 |
# File 'lib/multi_sync/client.rb', line 31 def initialize(*args) self.supervisor = Celluloid::SupervisionGroup.run! super end |
Instance Method Details
#add_source(clazz, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/multi_sync/client.rb', line 49 def add_source(clazz, = {}) source = clazz.new() sources << source source end |
#add_target(clazz, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/multi_sync/client.rb', line 39 def add_target(clazz, = {}) # TODO: friendly pool names? pool_name = Celluloid.uuid supervisor.pool(clazz, as: pool_name, args: [], size: MultiSync.target_pool_size) pool_name end |
#sync ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/multi_sync/client.rb', line 58 def sync MultiSync.warn 'Preventing synchronization as there are no sources found.' && return if sync_pointless? if first_run? MultiSync.debug 'Starting synchronization...' determine_sync else MultiSync.debug 'Restarting synchronization...' end sync_attempted MultiSync.debug 'Fetching upload jobs from the future...' (running_upload_jobs | incomplete_upload_jobs).each do | job | begin complete_upload_jobs << job.value rescue => error self.file_sync_attempts = file_sync_attempts + 1 MultiSync.warn error.inspect incomplete_upload_jobs << job end end MultiSync.debug 'Fetching delete jobs from the future...' (running_delete_jobs | incomplete_delete_jobs).each do | job | begin complete_delete_jobs << job.value rescue => error self.file_sync_attempts = file_sync_attempts + 1 MultiSync.warn error.inspect incomplete_delete_jobs << job end end finish_sync end |