Module: Wukong::Deploy::FTPSyncerOverride
- Defined in:
- lib/wukong-deploy/extensions/ftp_syncer.rb
Overview
Attaches to the hooks provided by the Wukong::Load::Syncer class to write data to Vayacondios.
Instance Method Summary collapse
-
#after_sync ⇒ Object
Announces a successful sync and updates the last sync state and time.
-
#before_sync ⇒ Object
Saves the syncer as a stash in Vayacondios.
-
#on_error(error) ⇒ Object
Announces an error during a sync and updates the last sync state and time.
-
#to_vayacondios ⇒ Hash
Returns a representation of this FTP syncer suitable for a Vayacondios stash.
-
#vayacondios_topic ⇒ String
Returns the Vayacondios topic for this FTP syncer.
Instance Method Details
#after_sync ⇒ Object
Announces a successful sync and updates the last sync state and time.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wukong-deploy/extensions/ftp_syncer.rb', line 16 def after_sync super() Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, { success: true, step: 'ftp', files: self.files, }.tap { |e| e[:duration] = duration if duration }) now = Time.now.utc.to_i last_ftp_sync_summary = { state: 1, time: now} last_ftp_sync_summary[:data] = now unless self.files.empty? Wukong::Deploy.vayacondios_client.set(vayacondios_topic, "ftp.last", last_ftp_sync_summary) end |
#before_sync ⇒ Object
Saves the syncer as a stash in Vayacondios.
9 10 11 12 |
# File 'lib/wukong-deploy/extensions/ftp_syncer.rb', line 9 def before_sync super() Wukong::Deploy.vayacondios_client.set(vayacondios_topic, 'ftp', self) end |
#on_error(error) ⇒ Object
Announces an error during a sync and updates the last sync state and time.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wukong-deploy/extensions/ftp_syncer.rb', line 31 def on_error error super(error) Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, { success: false, step: 'ftp', error: error.class, message: error., files: self.files, }) Wukong::Deploy.vayacondios_client.set(vayacondios_topic, "ftp.last", { state: 0, time: Time.now.utc.to_i }) end |
#to_vayacondios ⇒ Hash
Returns a representation of this FTP syncer suitable for a Vayacondios stash.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/wukong-deploy/extensions/ftp_syncer.rb', line 54 def to_vayacondios { protocol: settings[:protocol], username: settings[:username], password: (settings[:password] ? true : false), host: settings[:host], port: port, path: settings[:path], } end |
#vayacondios_topic ⇒ String
Returns the Vayacondios topic for this FTP syncer.
46 47 48 |
# File 'lib/wukong-deploy/extensions/ftp_syncer.rb', line 46 def vayacondios_topic "listeners.#{name}" end |