Permalink
Browse files

archive -> prepare

  • Loading branch information...
1 parent db67d3d commit f569e52ca13cfb04543506418b86e17c0615df76 Dhruv Bansal committed Sep 20, 2013
@@ -8,7 +8,7 @@ module FTPSyncerOverride
# Saves the syncer as a stash in Vayacondios.
def before_sync
super()
- Wukong::Deploy.vayacondios_client.set(vayacondios_topic, nil, self)
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, 'ftp', self)
end
# Announces a successful sync and updates the last sync state
@@ -17,23 +17,29 @@ def after_sync
super()
Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
success: true,
+ step: 'ftp',
}.tap { |e| e[:duration] = duration if duration })
- Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "last", { state: 1, time: Time.now.utc.to_i })
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "ftp.last", { state: 1, time: Time.now.utc.to_i })
end
# Announces an error during a sync and updates the last sync
# state and time.
def on_error error
super(error)
- Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, success: false, error: error.class, message: error.message)
- Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "last", { state: 0, time: Time.now.utc.to_i })
+ Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
+ success: false,
+ step: 'ftp',
+ error: error.class,
+ message: error.message,
+ })
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "ftp.last", { state: 0, time: Time.now.utc.to_i })
end
# Returns the Vayacondios topic for this FTP syncer.
#
# @return [String] the Vayacondios topic
def vayacondios_topic
- "listeners.sync-ftp-#{name}"
+ "listeners.#{name}"
end
# Returns a representation of this FTP syncer suitable for a
@@ -42,7 +48,6 @@ def vayacondios_topic
# @return [Hash]
def to_vayacondios
{
- name: name,
protocol: settings[:protocol],
username: settings[:username],
password: (settings[:password] ? true : false),
@@ -3,44 +3,51 @@ module Deploy
# Attaches to the hooks provided by the Wukong::Load::Syncer class
# to write data to Vayacondios.
- module ArchiveSyncerOverride
+ module PrepareSyncerOverride
# Saves the syncer as a stash in Vayacondios.
def before_sync
super()
- Wukong::Deploy.vayacondios_client.set(vayacondios_topic, nil, self)
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, 'prepare', self)
end
# Announces a successful sync and updates the last sync state
# and time.
def after_sync
super()
- Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, success: success?, files: files)
- Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "last", { state: (success? ? 1 : 0), time: Time.now.utc.to_i })
+ Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
+ success: success?,
+ step: 'prepare',
+ files: files,
+ })
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "prepare.last", { state: (success? ? 1 : 0), time: Time.now.utc.to_i })
end
# Announces an error during a sync and updates the last sync
# state and time.
def on_error error
super(error)
- Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, success: false, error: error.class, message: error.message)
- Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "last", { state: 0, time: Time.now.utc.to_i })
+ Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
+ success: false,
+ error: error.class,
+ message: error.message,
+ })
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "prepare.last", { state: 0, time: Time.now.utc.to_i })
end
- # Returns the Vayacondios topic for this ArchiveSyncer.
+ # Returns the Vayacondios topic for this PrepareSyncer.
#
# @return [String] the Vayacondios topic
def vayacondios_topic
- "listeners.sync-archive-#{name}"
+ "listeners.#{name}"
end
- # Returns a representation of this ArchiveSyncer suitable for a
+ # Returns a representation of this PrepareSyncer suitable for a
# Vayacondios stash.
#
# @return [Hash]
def to_vayacondios
{
- name: name,
split: settings[:split],
lines: settings[:lines],
bytes: settings[:bytes],
@@ -53,7 +60,7 @@ module HandlerOverride
# The topic for this Handler.
#
- # Delegates to ArchiveSyncer#vayacondios_topic.
+ # Delegates to PrepareSyncer#vayacondios_topic.
#
# @return [String]
def vayacondios_topic
@@ -67,6 +74,7 @@ def after_process original
super(original)
Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
success: true,
+ step: 'prepare',
path: relative_path_of(original, settings[:input]),
size: File.size(original),
})
@@ -80,6 +88,7 @@ def on_error original, error
super(original, error)
Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
success: false,
+ step: 'prepare',
path: relative_path_of(original, settings[:input]),
error: error.class,
message: error.message
@@ -8,7 +8,7 @@ module S3SyncerOverride
# Saves the syncer as a stash in Vayacondios.
def before_sync
super()
- Wukong::Deploy.vayacondios_client.set(vayacondios_topic, nil, self)
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, 's3', self)
end
# Announces a successful sync and updates the last sync state
@@ -17,24 +17,30 @@ def after_sync
super()
Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
success: true,
+ step: 's3',
bytes: (bytes || 0),
}.tap { |e| e[:duration] = duration if duration })
- Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "last", { state: 1, time: Time.now.utc.to_i })
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "s3.last", { state: 1, time: Time.now.utc.to_i })
end
# Announces an error during a sync and updates the last sync
# state and time.
def on_error error
super(error)
- Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, success: false, error: error.class, message: error.message)
- Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "last", { state: 0, time: Time.now.utc.to_i })
+ Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
+ success: false,
+ step: 's3',
+ error: error.class,
+ message: error.message,
+ })
+ Wukong::Deploy.vayacondios_client.set!(vayacondios_topic, "s3.last", { state: 0, time: Time.now.utc.to_i })
end
# Returns the Vayacondios topic for this S3Syncer.
#
# @return [String] the Vayacondios topic
def vayacondios_topic
- "listeners.sync-s3-#{name}"
+ "listeners.#{name}"
end
# Returns a representation of this S3Syncer suitable for a
@@ -43,7 +49,6 @@ def vayacondios_topic
# @return [Hash]
def to_vayacondios
{
- name: name,
bucket: s3_uri,
region: settings[:region],
}
@@ -1,7 +1,7 @@
require_relative('extensions/uses_lockfile')
require_relative('extensions/uses_file_state')
require_relative('extensions/ftp_syncer')
-require_relative('extensions/archive_syncer')
+require_relative('extensions/prepare_syncer')
require_relative('extensions/s3_syncer')
Wukong::Load::SyncRunner.class_eval do
@@ -15,12 +15,12 @@
Wukong::Load::FTPSyncer.class_eval do
include Wukong::Deploy::FTPSyncerOverride
end
-Wukong::Load::ArchiveSyncer.class_eval do
+Wukong::Load::PrepareSyncer.class_eval do
include Wukong::Deploy::UsesFileStateOverride
- include Wukong::Deploy::ArchiveSyncerOverride
+ include Wukong::Deploy::PrepareSyncerOverride
end
-Wukong::Load::ArchiveSyncer::Handler.class_eval do
- include Wukong::Deploy::ArchiveSyncerOverride::HandlerOverride
+Wukong::Load::PrepareSyncer::Handler.class_eval do
+ include Wukong::Deploy::PrepareSyncerOverride::HandlerOverride
end
Wukong::Load::S3Syncer.class_eval do
include Wukong::Deploy::S3SyncerOverride

0 comments on commit f569e52

Please sign in to comment.