replicator/lib/ruby/pg-wal-plugin.rb
def plugin_waitevent
    # Make sure we are a standby.
    if ! is_standby()
      raise UserError, "You can only wait for events on a standby"
    end
    
    # We take timeout and event ID arguments. 
    event = @args.getProperty("event")
    timeout = @args.getProperty("timeout")
    if ! event
      raise UserError, "You must supply an event to wait for"
    end
    if ! timeout 
      timeout = 0
    else
      # Have to convert type as we are holding a string, not a Fixnum.  
      timeout = timeout.to_i
    end
    
    # Write the values. 
    waited = 0
    while timeout == 0 || waited < timeout
      latest_event = read_status_file(@wal_restored)
      if latest_event >= event
        puts "Found matching event: #{latest_event}"
        break
      end
      sleep 1
      waited += 1
    end
  end
# Waits for an event to arrive on the standby.  
Waits for an event to arrive on the standby.
Waits for an event to arrive on the standby .
def plugin_waitevent
    if ! is_standby()
      raise UserError, "You can only wait for events on a standby"
    end
    event = @args.getProperty("event")
    timeout = @args.getProperty("timeout")
    if ! event
      raise UserError, "You must supply an event to wait for"
    end
    if ! timeout 
      timeout = 0
    else
      timeout = timeout.to_i
    end
    waited = 0
    while timeout == 0 || waited < timeout
      latest_event = read_status_file(@wal_restored)
      if latest_event >= event
        puts "Found matching event: #{latest_event}"
        break
      end
      sleep 1
      waited += 1
    end
  end
def plugin_waitevent if ! is_standby ( ) raise UserError , "You can only wait for events on a standby" end event = @args . getProperty ( "event" ) timeout = @args . getProperty ( "timeout" ) if ! event raise UserError , "You must supply an event to wait for" end if ! timeout timeout = 0 else timeout = timeout . to_i end waited = 0 while timeout == 0 || waited < timeout latest_event = read_status_file ( @wal_restored ) if latest_event >= event puts "Found matching event: #{latest_event}" break end sleep 1 waited += 1 end end
Waits for an event to arrive on the standby.
Waits for an event to arrive on the standby .
# Make sure we are a standby. # We take timeout and event ID arguments.  # Have to convert type as we are holding a string, not a Fixnum.   # Write the values. 