0
@@ -15,8 +15,20 @@ Require CouchRest and Slipcover:
0
Create the members of the cluster (these could be on different hosts, but we'll just simulate that here):
0
- >> db1 = CouchRest.new('localhost:5984').database('grabbit-import')
0
- >> db2 = CouchRest.new('127.0.0.1:5984').database('test_suite_db')
0
+ >> cr1 = CouchRest.new('localhost:5984')
0
+ >> cr1.database('slipcover-test').delete!
0
+ >> begin; cr1.create_db('slipcover-test'); rescue; nil; end;
0
+Create cluster member two.
0
+ >> cr2 = CouchRest.new('127.0.0.1:5984')
0
+ >> cr2.database('slipcover-test2').delete!
0
+ >> begin; cr2.create_db('slipcover-test2'); rescue; nil; end;
0
+ >> db1 = cr1.database('slipcover-test')
0
+ >> db2 = cr2.database('slipcover-test2')
0
+ >> saved = db1.save({"test"=>"doc"})
0
Assign them to Slipcover for management:
0
@@ -24,7 +36,7 @@ Assign them to Slipcover for management:
0
By default, our cluster will re-raise any errors that occur in individual members
0
- >> lambda{ cluster.get(
"00485b412155c325a3e6982470931ccd" )}.raises_error? RestClient::Request::RequestFailed
0
+ >> lambda{ cluster.get(
saved['id'] )}.raises_error? RestClient::Request::RequestFailed
0
but, if we want to ignore certain errors in the members (like in this case where we only want to hear back from the member of the cluster that actually has the document we're looking for), we can tell Slipcover to silence errors of a certain type
0
@@ -33,19 +45,19 @@ but, if we want to ignore certain errors in the members (like in this case where
0
=> [RestClient::Request::RequestFailed]
0
and then getting a document that's present on only one of the members will return the document without any noise from the other cluster members:
0
- >> result = cluster.get( "00485b412155c325a3e6982470931ccd" )
0
- >> result.first["metadata"].first["artist"]
0
+ >> result = cluster.get( saved['id'] )
0
+ >> result.first['test']
0
If members raise other errors that aren't included in the list to be silenced, however, they will bring things to a halt. For example, if we add another member to the cluster on a broken connection
0
- >> db3 = CouchRest.new('broken-socket').database('
grabbit-import')
0
+ >> db3 = CouchRest.new('broken-socket').database('
no-couch-here')
0
>> cluster.add_member db3
0
then the resulting errors will still raise:
0
- >> lambda{ cluster.get(
"00485b412155c325a3e6982470931ccd" )}.raises_error? SocketError
0
+ >> lambda{ cluster.get(
saved['id'] )}.raises_error? SocketError
0
Let's remove this broken cluster member so we can continue our tests:
Comments
No one has commented yet.