Permalink
Browse files

NCBC-31 - Added support for view 'on_error' parameter

Change-Id: I5bbc89e55106bde701a6d916609b042b1100db32
Reviewed-on: http://review.couchbase.org/14305
Tested-by: John C. Zablocki <john@couchbase.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
  • Loading branch information...
1 parent 291adc4 commit e2bd3857c89028dfb9dddeccf6ab40e655d4b096 @johnzablocki johnzablocki committed with John C. Zablocki Mar 26, 2012
Showing with 28 additions and 0 deletions.
  1. +21 −0 src/Couchbase/CouchbaseViewBase.cs
  2. +7 −0 src/Couchbase/ICouchbaseView`1.cs
@@ -12,6 +12,8 @@ namespace Couchbase {
public enum StaleMode { AllowStale, UpdateAfter, False }
+ public enum OnErrorMode { Continue, Stop }
+
internal abstract class CouchbaseViewBase<T> : IView<T> {
protected static readonly Enyim.Caching.ILog log = Enyim.Caching.LogManager.GetLogger(typeof(CouchbaseView));
@@ -29,6 +31,7 @@ internal abstract class CouchbaseViewBase<T> : IView<T> {
protected string keys;
protected StaleMode? stale;
+ protected OnErrorMode? onError;
protected bool? descending;
protected bool? inclusive;
@@ -164,6 +167,19 @@ internal abstract class CouchbaseViewBase<T> : IView<T> {
default: throw new ArgumentOutOfRangeException("stale: " + this.stale);
}
+ if (this.onError != null)
+ {
+ switch (onError.Value) {
+ case OnErrorMode.Continue:
+ retval.AddParameter("on_error", "continue");
+ break;
+ case OnErrorMode.Stop:
+ retval.AddParameter("on_error", "stop");
+ break;
+ default: throw new ArgumentOutOfRangeException("on_error: " + this.onError);
+ }
+ }
+
return retval;
}
@@ -216,6 +232,11 @@ private static void AddOptionalRequestParam<T>(IHttpRequest request, string name
return this;
}
+ public IView<T> OnError(OnErrorMode mode) {
+ this.onError = mode;
+ return this;
+ }
+
public IView<T> Stale(StaleMode mode) {
this.stale = mode;
return this;
@@ -30,6 +30,13 @@ public interface IView<T> : IEnumerable<T>
/// <returns>A new <see cref="T:Couchbase.IView"/> instance that includes the stale items from the view.</returns>
IView<T>Stale(StaleMode mode);
+ /// <summary>
+ /// Control the behavior of view engine when returning a request in the event of an error.
+ /// </summary>
+ /// <param name="mode"></param>
+ /// <returns>A new <see cref="T:Couchbase.IView"/> instance potentially abbreviated by error conditions.</returns>
+ IView<T> OnError(OnErrorMode mode);
+
/// <summary>
/// Sort the items of the view in descending order.
/// </summary>

0 comments on commit e2bd385

Please sign in to comment.