Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

figured out regex issue for url, now next point of errors

  • Loading branch information...
commit e9149ebd28c2b1fad73f764e0cf472a0ad73afd8 1 parent 892e6c2
@scalabl3 authored
Showing with 91 additions and 38 deletions.
  1. +5 −10 README.md
  2. +86 −28 xdcr.rb
View
15 README.md
@@ -33,12 +33,13 @@ $ ruby xdcr.rb
- /pools (GET)
- /pools/default (GET)
-- /pools/default/buckets (GET) **GETTING STUCK HERE**
+- /pools/default/buckets (GET)
- /pools/default/buckets/{bucket} (GET)
- /{database} (HEAD, GET)
+- /{database}/master/{vbucket};{uuid} **GETTING STUCK HERE**
- /{database}/{docid} (GET)
-**NOT POSTING NEED TO CHECK**
+**NOT POSTING YET**
- /{database}/_ensure_full_commit (POST)
- /{database}/_revs_diff (POST)
- /{database}/_bulk_docs (POST)
@@ -46,11 +47,5 @@ $ ruby xdcr.rb
# Currently Working on... #
***Current Error***
-VBucketMap = [ [0,-1] * 1024]
-
-2012-11-06 11:02:33 - Error replicating vbucket 955:
-{db_not_found, <<"http://Administrator:*****@127.0.0.1:4567/default/955;9e4d14d5a9be45cba5ec5534f42e129b/">>}
-
-
-if VBucketMap = [ [1,-1] * 1024 ]
-2012-11-06 11:20:12 - Error replicating vbucket 955: {badrecord,dict}
+2012-11-06 13:52:45 - Error replicating vbucket 9:
+ {db_not_found, <<"http://Administrator:*****@127.0.0.1:4567/default/master;9e4d14d5a9be45cba5ec5534f42e129b/">>}
View
114 xdcr.rb
@@ -3,7 +3,7 @@
require 'json'
require 'active_support'
-
+set :server, 'webrick'
basic_auth do
realm 'Give me password!'
@@ -19,7 +19,7 @@
UUID_POOL = "3b5211459ec34c589522f78c2284099e" #SecureRandom.uuid.gsub("-", "")
UUID_BUCKET = "9e4d14d5a9be45cba5ec5534f42e129b" #SecureRandom.uuid.gsub("-", "")
VBucketMap = []
-1024.times { VBucketMap << [1,-1] }
+1024.times { VBucketMap << [0,1] }
puts VBucketMap.size
@@ -138,53 +138,77 @@
end
+# matches
+#/default%2b602%3b9e4d14d5a9be45cba5ec5534f42e129b
+#/default/602;9e4d14d5a9be45cba5ec5534f42e129b
+vbucket_regex = %r{[\/]([\w]+)([\/]|%2f)([\d]+)([;]|%3b)([\w]+)}
-get '/:database' do #(HEAD, GET)
+
+
+head vbucket_regex do
require_basic_auth
content_type :json
- 5.times { puts }
- puts "GET requested [database] /#{params[:database]}"
-
-
-
- if params[:database] == XDCR_BUCKET
- out = { :db_name => XDCR_BUCKET }
- status 200
-
- puts out.to_json
- out.to_json
- else
- status 404
- nil
+ params[:captures].each_with_index do |c,i|
+ puts "capture[#{i}] = #{c}"
end
+ puts params.inspect
+
+ result = database_response("HEAD", params[:captures][0], params[:captures][2].to_i, params[:captures][4])
+ status result[0]
end
-get '/:database/:vbucket;:uuid/' do #(GET)
+get vbucket_regex do
require_basic_auth
content_type :json
- 5.times { puts }
- puts "GET requested [database] /#{params[:database]}/#{params[:vbucket]};#{:uuid}"
+ params[:captures].each_with_index do |c,i|
+ puts "capture[#{i}] = #{c}"
+ end
puts params.inspect
+ result = database_response("GET", params[:captures][0], params[:captures][2].to_i, params[:captures][4])
+ status result[0]
+
+ result_hash = { :db_name => XDCR_BUCKET }
+
+ if result[0].to_i == 200
+ return result_hash.to_json
+ else
+ return nil
+ end
+end
+
+
+
+
+
+
+#encapsulate GET and HEAD request results
+def database_response(method, database, vbucket_number, uuid)
- if params[:database] == XDCR_BUCKET
- status 200
- nil
+ 5.times { puts }
+ puts "#{method} requested [database] /#{database}/#{vbucket_number};#{uuid}"
+
+ if database == XDCR_BUCKET
+ return [200]
else
- status 404
- nil
+ return [404]
end
end
+
+=begin
+
+
+
post '/:database/_ensure_full_commit' do #(POST)
require_basic_auth
content_type :json
@@ -203,7 +227,7 @@
-post '/{database}/_revs_diff' do #(POST)
+post '/:database/_revs_diff' do #(POST)
require_basic_auth
content_type :json
@@ -216,8 +240,6 @@
end
-
-
post '/:database/_bulk_docs' do #(POST)
require_basic_auth
content_type :json
@@ -230,3 +252,39 @@
nil
end
+
+
+get '/:database' do #(HEAD, GET)
+ require_basic_auth
+ content_type :json
+
+ 5.times { puts }
+ puts "GET requested [database] /#{params[:database]}"
+
+
+
+ if params[:database] == XDCR_BUCKET
+ out = { :db_name => XDCR_BUCKET }
+ status 200
+
+ puts out.to_json
+ out.to_json
+ else
+ status 404
+ nil
+ end
+end
+
+
+
+
+get '/*' do
+ puts "(GET) NO MATCH"
+end
+
+head '/*' do
+ puts "(HEAD) NO MATCH"
+end
+
+
+=end
Please sign in to comment.
Something went wrong with that request. Please try again.