lib/rubyrep/replication_run.rb in rubyrep-1.0.1 vs lib/rubyrep/replication_run.rb in rubyrep-1.0.2
- old
+ new
@@ -17,27 +17,34 @@
Replicators.replicators[session.configuration.options[:replicator]].new(helper)
end
# Executes the replication run.
def run
- success = false
- replicator # ensure that replicator is created and has chance to validate settings
+ return unless [:left, :right].any? do |database|
+ session.send(database).select_one(
+ "select id from #{session.configuration.options[:rep_prefix]}_pending_changes"
+ ) != nil
+ end
+ begin
+ success = false
+ replicator # ensure that replicator is created and has chance to validate settings
- loop do
- begin
- session.reload_changes # ensure the cache of change log records is up-to-date
- diff = ReplicationDifference.new session
- diff.load
- break unless diff.loaded?
- replicator.replicate_difference diff if diff.type != :no_diff
- rescue Exception => e
- helper.log_replication_outcome diff, e.message,
- e.class.to_s + "\n" + e.backtrace.join("\n")
+ loop do
+ begin
+ session.reload_changes # ensure the cache of change log records is up-to-date
+ diff = ReplicationDifference.new session
+ diff.load
+ break unless diff.loaded?
+ replicator.replicate_difference diff if diff.type != :no_diff
+ rescue Exception => e
+ helper.log_replication_outcome diff, e.message,
+ e.class.to_s + "\n" + e.backtrace.join("\n")
+ end
end
+ success = true # considered to be successful if we get till here
+ ensure
+ helper.finalize success
end
- success = true # considered to be successful if we get till here
- ensure
- helper.finalize success
end
# Creates a new ReplicationRun instance.
# * +session+: the current Session
def initialize(session)
\ No newline at end of file