/// <summary> /// Constructor for enumerating over all documents starting from a given sequence /// </summary> /// <param name="db">The database to retrieve documents from</param> /// <param name="lastSequence">The sequence to start enumerating from</param> /// <param name="options">The enumeration options (null for default).</param> public CBForestDocEnumerator(C4Database *db, long lastSequence, C4EnumeratorOptions options) { var options_ = &options; _currentDocInfo = (C4DocumentInfo *)Marshal.AllocHGlobal(sizeof(C4DocumentInfo)).ToPointer(); _e = (C4DocEnumerator *)RetryHandler.RetryIfBusy().Execute(err => Native.c4db_enumerateChanges(db, (ulong)lastSequence, options_, err)); }
/// <summary> /// Constructor for enumerating over documents which need indexing /// by a given indexer /// </summary> /// <param name="indexer">The indexer to use for enumeration.</param> public CBForestDocEnumerator(C4Indexer *indexer) { _e = (C4DocEnumerator *)RetryHandler.RetryIfBusy().AllowError(0, C4ErrorDomain.Any) .Execute(err => Native.c4indexer_enumerateDocuments(indexer, err)); _currentDocInfo = (C4DocumentInfo *)Marshal.AllocHGlobal(sizeof(C4DocumentInfo)).ToPointer(); _validationLogic = doc => !((string)doc->docID).StartsWith("_design/"); }
/// <summary> /// Constructor for enumerating over a given subset of documents in a database /// </summary> /// <param name="db">The database to retrieve documents from</param> /// <param name="startKey">The key to start enumeration from</param> /// <param name="endKey">The key to end enumeration at</param> /// <param name="options">The enumeration options (null for default).</param> public CBForestDocEnumerator(C4Database *db, string startKey, string endKey, C4EnumeratorOptions options) { var options_ = &options; _currentDocInfo = (C4DocumentInfo *)Marshal.AllocHGlobal(sizeof(C4DocumentInfo)).ToPointer(); _e = (C4DocEnumerator *)RetryHandler.RetryIfBusy().Execute(err => Native.c4db_enumerateAllDocs(db, startKey, endKey, options_, err)); }
/// <summary> /// The main entry point into this class. It will retry the operation a specified /// number of times if the result of the operation is that the database is busy. /// </summary> /// <returns>A retry handler object for further fluent operations</returns> /// <param name="maxAttempts">The number of times to retry before giving up</param> public static RetryHandler RetryIfBusy(uint maxAttempts = RETRY_ATTEMPTS) { if (maxAttempts == 0) { throw new ArgumentException("Surely you want to try more than zero times", "maxAttempts"); } var retVal = new RetryHandler(); retVal._maxAttempts = maxAttempts; return(retVal); }
public ExpiryEnumerator(C4Database *db, bool dispose) { _e = (C4ExpiryEnumerator *)RetryHandler.RetryIfBusy().Execute(err => Native.c4db_enumerateExpired(db, err)); _dispose = dispose; }
/// <summary> /// The main entry point into this class. It will retry the operation a specified /// number of times if the result of the operation is that the database is busy. /// </summary> /// <returns>A retry handler object for further fluent operations</returns> /// <param name="maxAttempts">The number of times to retry before giving up</param> public static RetryHandler RetryIfBusy(uint maxAttempts = RETRY_ATTEMPTS) { if (maxAttempts == 0) { throw new ArgumentException("Surely you want to try more than zero times", "maxAttempts"); } var retVal = new RetryHandler(); retVal._maxAttempts = maxAttempts; return retVal; }