Skip to content

Instantly share code, notes, and snippets.

@TigerWolf
Last active December 30, 2015 21:09
Show Gist options
  • Save TigerWolf/7885785 to your computer and use it in GitHub Desktop.
Save TigerWolf/7885785 to your computer and use it in GitHub Desktop.
class PerformanceWorker
include Wisper
def perform
publish(:start_download, self)
PerformanceDownloader.new(url, attributes)
publish(:finish_download, self)
Transaction.start
publish(:import_start, self)
PerformancePurger.new(dbtable)
PerformnanceParser.new(attributes, dbtable)
publish(:import_finish, self)
Transaction.end
if transation_failed?
publish(:import_failed, self)
end
end
end
class Owner
def set_things_in_motion
worker = PerformanceWorker.new
worker.subscribe(WorkerLog.new)
worker.perform
end
end
class WorkerLog
def on_download_started(worker)
worker.log.update_attributes(:download_started, Time.now)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment