def worker
      while (record = first)
        tries = 0
        begin
          if Hash === record
            # Write batch update
            write(dump(record))
            @size += record.size
          else
            # Write single record
            record[1] = @serializer.dump(record.last) if record.size > 1
            write(@format.dump(record))
            @size += 1
          end
        rescue Exception => ex
          tries += 1
          warn "Daybreak worker, try #{tries}: #{ex.message}"
          tries <= 3 ? retry : raise
        ensure
          pop
        end
      end
    rescue Exception => ex
      warn "Daybreak worker terminated: #{ex.message}"
    end
def worker
      while (record = first)
        tries = 0
        begin
          if Hash === record
            # Write batch update
            write(dump(record))
            @size += record.size
          else
            # Write single record
            record[1] = @serializer.dump(record.last) if record.size > 1
            write(@format.dump(record))
            @size += 1
          end
        rescue Exception => ex
          tries += 1
          warn "Daybreak worker, try #{tries}: #{ex.message}"
          tries <= 3 ? retry : raise
        ensure
          pop
        end
      end
    rescue Exception => ex
      warn "Daybreak worker terminated: #{ex.message}"
    end
Worker thread