Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

got it working, now receiving docs

  • Loading branch information...
commit 63cfcd44c7d87b2c20060fdd7a9e7a9b2b9b9c0e 1 parent e07c3a4
@scalabl3 authored
Showing with 29 additions and 45 deletions.
  1. +3 −22 README.md
  2. +26 −23 xdcr.rb
View
25 README.md
@@ -1,6 +1,6 @@
# Cross-Data Center Replication (XDCR) Simulator in Sinatra
-**When working**, can be used to "do stuff" with documents as they are streamed through XDCR to Sinatra. Still a work in progress...
+Can be used to "do stuff" with documents as they are streamed through XDCR to Sinatra. Still a work in progress...
# Pre-Requisites
@@ -40,27 +40,8 @@ $ ruby xdcr.rb
- /{database}/master/{vbucket};{uuid}
- /{database}/{docid} (GET)
- /{database}/_ensure_full_commit (POST)
-
-**PARTIAL**
-- /{database}/_revs_diff (POST) **GETTING STUCK HERE on the Response Back**
-
-**NOT TESTED YET**
+- /{database}/_revs_diff (POST)
- /{database}/_bulk_docs (POST)
-# Currently Working on... #
-
-***Current Error***
-Error replicating vbucket 965:
+# It works now!
- {
- { nocatch, { bad_request, <<"Invalid rev format">> }
- },
- [
- { couch_doc,parse_rev,1 },
- { couch_api_wrap, '-get_missing_revs/2-fun-0-', 1 },
- { lists,map,2 },
- { couch_api_wrap, '-get_missing_revs/2-fun-1-', 3 },
- { xdc_vbucket_rep_worker, find_missing,2 },
- { xdc_vbucket_rep_worker, queue_fetch_loop,4 }
- ]
- }
View
49 xdcr.rb
@@ -251,24 +251,6 @@ def response_db_master(method, database, master, uuid)
end
-
-
-post '/:database/_ensure_full_commit' do #(POST)
- require_basic_auth
- content_type :json
-
- 5.times { puts }
- puts params.inspect
- puts "POST requested [database] /#{params[:database]}/_ensure_full_commit"
- status 201
-
- out = { :ok => true }
-
- puts out.to_json
- out.to_json
-end
-
-
revs_diff_regex = %r{[\/]([\w]+)([\/]|%2f|%2F)([\w]+)([;]|%3b|%3B)([\w]+)[\/](_revs_diff)}
post revs_diff_regex do #(POST)
@@ -276,6 +258,7 @@ def response_db_master(method, database, master, uuid)
content_type :json
5.times { puts }
+ puts "POST requested [database] /_revs_diff"
#puts "POST requested [database] /#{params[:captures][0]}/_revs_diff"
#puts params.class.to_s
#json = JSON.parse(params[0][0]) if params && params[0]
@@ -288,13 +271,13 @@ def response_db_master(method, database, master, uuid)
raw_data = request.body.read
data = JSON.parse raw_data
puts raw_data
- puts data.inspect
+ #puts data.inspect
puts
out = {} # "03ee06461a12f3c288bb865b22000170": {"missing": ["2-3a24009a9525bde9e4bfa8a99046b00d"]} }
data.each_pair do |k,v|
- out[k] = { :missing => [v] }
+ out[k] = { :missing => v }
end
#params.each_pair do |k,v|
@@ -303,19 +286,39 @@ def response_db_master(method, database, master, uuid)
status 200
- puts out.to_json
+ puts "RESPONSE: #{out.to_json}"
out.to_json
end
+ensure_commit_regex = %r{[\/]([\w]+)([\/]|%2f|%2F)([\w]+)([;]|%3b|%3B)([\w]+)[\/](_ensure_full_commit)}
+
+post ensure_commit_regex do #(POST)
+ require_basic_auth
+ content_type :json
+
+ 5.times { puts }
+ #puts params.inspect
+ puts "POST requested [database] /_ensure_full_commit"
+ status 201
+
+ out = { :ok => true }
+
+ #puts out.to_json
+ out.to_json
+end
+
+
+bulk_docs_regex = %r{[\/]([\w]+)([\/]|%2f|%2F)([\w]+)([;]|%3b|%3B)([\w]+)[\/](_bulk_docs)}
-post '/:database/_bulk_docs' do #(POST)
+post bulk_docs_regex do #(POST)
require_basic_auth
content_type :json
5.times { puts }
- puts "POST requested [database] /#{params[:database]}/_bulk_docs"
+ puts "POST requested [database] /_bulk_docs"
+ #puts "POST requested [database] /#{params[:database]}/_bulk_docs"
request.body.rewind # in case someone already read it
data = JSON.parse request.body.read

0 comments on commit 63cfcd4

Please sign in to comment.
Something went wrong with that request. Please try again.