예제 #1
0
        /// <summary>Returns the list of all the subdirectories of the current directory, it it exists.</summary>
        public static Task <List <string> > TryListAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbReadOnlyRetryable db, CancellationToken ct)
        {
            Contract.NotNull(subspace, nameof(subspace));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => subspace.TryListAsync(tr), ct));
        }
예제 #2
0
        /// <summary>Returns the list of subdirectories of directory at <paramref name="path"/>, if it exists</summary>
        public static Task <List <string> > TryListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, FdbDirectoryPath path, CancellationToken ct)
        {
            Contract.NotNull(directory, nameof(directory));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => directory.TryListAsync(tr, path), ct));
        }
예제 #3
0
        /// <summary>Attempts to open the directory with the given <paramref name="path"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, FdbDirectoryPath path, Slice layer, CancellationToken ct)
        {
            Contract.NotNull(directory, nameof(directory));
            Contract.NotNull(db, nameof(db));

            return(db.ReadAsync((tr) => directory.TryOpenAsync(tr, path, layer), ct));
        }
 /// <summary>Read a single page of a range query from the database, using a dedicated transaction.</summary>
 /// <param name="db">Database instance</param>
 /// <remarks>
 /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
 /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
 /// </remarks>
 public static Task <FdbRangeChunk> GetRangeAsync(this IFdbReadOnlyRetryable db, FdbKeySelector beginInclusive, FdbKeySelector endExclusive, FdbRangeOptions options, int iteration, CancellationToken cancellationToken)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     return(db.ReadAsync((tr) => tr.GetRangeAsync(beginInclusive, endExclusive, options, iteration), cancellationToken));
 }
 /// <summary>Resolve a single key selector from the database, using a dedicated transaction.</summary>
 /// <param name="db">Database instance</param>
 /// <remarks>
 /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
 /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
 /// </remarks>
 public static Task <Slice> GetKeyAsync(this IFdbReadOnlyRetryable db, FdbKeySelector keySelector, CancellationToken cancellationToken)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     return(db.ReadAsync((tr) => tr.GetKeyAsync(keySelector), cancellationToken));
 }
 /// <summary>Read a sequence of keys from the database, using a dedicated transaction.</summary>
 /// <param name="db">Database instance</param>
 /// <remarks>
 /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
 /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
 /// </remarks>
 public static Task <Slice[]> GetValuesAsync(this IFdbReadOnlyRetryable db, [NotNull] IEnumerable <Slice> keys, CancellationToken cancellationToken)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     return(db.ReadAsync((tr) => tr.GetValuesAsync(keys), cancellationToken));
 }
 /// <summary>Returns the list of subdirectories of the current directory.</summary>
 public static Task <List <string> > ListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, CancellationToken ct)
 {
     if (directory == null)
     {
         throw new ArgumentNullException(nameof(directory));
     }
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     return(db.ReadAsync((tr) => directory.ListAsync(tr), ct));
 }
 /// <summary>Resolve a list of key selectors from the database, using a dedicated transaction.</summary>
 /// <param name="db">Database instance</param>
 /// <remarks>
 /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
 /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
 /// </remarks>
 public static Task <Slice[]> GetKeysAsync(this IFdbReadOnlyRetryable db, [NotNull] FdbKeySelector[] keySelectors, CancellationToken cancellationToken)
 {
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (keySelectors == null)
     {
         throw new ArgumentNullException("keySelectors");
     }
     return(db.ReadAsync((tr) => tr.GetKeysAsync(keySelectors), cancellationToken));
 }
        /// <summary>Checks if a directory already exists</summary>
        /// <returns>Returns true if the directory exists, otherwise false.</returns>
        public static Task <bool> ExistsAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, IEnumerable <string> path, CancellationToken ct)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            return(db.ReadAsync((tr) => directory.ExistsAsync(tr, path), ct));
        }
        /// <summary>Checks if this directory exists</summary>
        /// <returns>Returns true if the directory exists, otherwise false.</returns>
        public static Task <bool> ExistsAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbReadOnlyRetryable db, CancellationToken ct)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            return(db.ReadAsync((tr) => subspace.ExistsAsync(tr), ct));
        }
        /// <summary>Returns the list of all the subdirectories of the current directory, it it exists.</summary>
        public static Task <List <string> > TryListAsync([NotNull] this FdbDirectorySubspace subspace, [NotNull] IFdbReadOnlyRetryable db, CancellationToken cancellationToken)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException("subspace");
            }
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }

            return(db.ReadAsync((tr) => subspace.TryListAsync(tr), cancellationToken));
        }
 /// <summary>Returns the list of subdirectories of the sub-directory with the given <paramref name="name"/>.</summary>
 public static Task <List <string> > ListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] string name, CancellationToken cancellationToken)
 {
     if (directory == null)
     {
         throw new ArgumentNullException("directory");
     }
     if (db == null)
     {
         throw new ArgumentNullException("db");
     }
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     return(db.ReadAsync((tr) => directory.ListAsync(tr, new [] { name }), cancellationToken));
 }
 /// <summary>Returns the list of subdirectories of directory at <paramref name="path"/>, if it exists</summary>
 public static Task <List <string> > TryListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, IEnumerable <string> path, CancellationToken ct)
 {
     if (directory == null)
     {
         throw new ArgumentNullException(nameof(directory));
     }
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     if (path == null)
     {
         throw new ArgumentNullException(nameof(path));                           //REVIEW: or not?
     }
     return(db.ReadAsync((tr) => directory.TryListAsync(tr, path), ct));
 }
        /// <summary>Attempts to open the directory with the given <paramref name="path"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] IEnumerable <string> path, Slice layer, CancellationToken cancellationToken)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(db.ReadAsync((tr) => directory.TryOpenAsync(tr, path, layer), cancellationToken));
        }
        /// <summary>Returns the list of subdirectories of directory at <paramref name="path"/>.</summary>
        public static Task <List <string> > ListAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] IEnumerable <string> path, CancellationToken cancellationToken)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            return(db.ReadAsync((tr) => directory.ListAsync(tr, path), cancellationToken));
        }
        /// <summary>Attempts to open the directory with the given <paramref name="name"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] string name, Slice layer, CancellationToken ct)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            return(db.ReadAsync((tr) => directory.TryOpenAsync(tr, new[] { name }, layer), ct));
        }
        /// <summary>Attempts to open the directory with the given <paramref name="path"/>.</summary>
        public static Task <FdbDirectorySubspace> TryOpenAsync([NotNull] this IFdbDirectory directory, [NotNull] IFdbReadOnlyRetryable db, [NotNull] IEnumerable <string> path, CancellationToken ct)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(db.ReadAsync((tr) => directory.TryOpenAsync(tr, path, Slice.Nil), ct));
        }
예제 #18
0
 public static Task <FdbRangeChunk> GetRangeAsync(this IFdbReadOnlyRetryable db, KeySelector beginInclusive, KeySelector endExclusive, FdbRangeOptions options, int iteration, CancellationToken ct)
 {
     Contract.NotNull(db);
     return(db.ReadAsync((tr) => tr.GetRangeAsync(beginInclusive, endExclusive, options, iteration), ct));
 }
예제 #19
0
 public static Task <Slice[]> GetKeysAsync(this IFdbReadOnlyRetryable db, IEnumerable <KeySelector> keySelectors, CancellationToken ct)
 {
     Contract.NotNull(db);
     Contract.NotNull(keySelectors);
     return(db.ReadAsync((tr) => tr.GetKeysAsync(keySelectors), ct));
 }
예제 #20
0
 public static Task <Slice> GetKeyAsync(this IFdbReadOnlyRetryable db, KeySelector keySelector, CancellationToken ct)
 {
     Contract.NotNull(db);
     return(db.ReadAsync((tr) => tr.GetKeyAsync(keySelector), ct));
 }
예제 #21
0
 public static Task <Slice[]> GetValuesAsync(this IFdbReadOnlyRetryable db, Slice[] keys, CancellationToken ct)
 {
     Contract.NotNull(db);
     return(db.ReadAsync((tr) => tr.GetValuesAsync(keys), ct));
 }
 public static Task <Slice[]> GetKeysAsync([NotNull] this IFdbReadOnlyRetryable db, [NotNull] KeySelector[] keySelectors, CancellationToken cancellationToken)
 {
     Contract.NotNull(db, nameof(db));
     Contract.NotNull(keySelectors, nameof(keySelectors));
     return(db.ReadAsync((tr) => tr.GetKeysAsync(keySelectors), cancellationToken));
 }
 public static Task <Slice[]> GetValuesAsync([NotNull] this IFdbReadOnlyRetryable db, [NotNull] IEnumerable <Slice> keys, CancellationToken cancellationToken)
 {
     Contract.NotNull(db, nameof(db));
     return(db.ReadAsync((tr) => tr.GetValuesAsync(keys), cancellationToken));
 }
        //REVIEW: this may be too dangerous!
        // Users may call GetAsync() or SetAsync() multiple times, outside of a transaction...

        /// <summary>Read a single key from the database, using a dedicated transaction.</summary>
        /// <param name="db">Database instance</param>
        /// <param name="key"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <remarks>
        /// Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request).
        /// If you need to read several keys at once, use a version of <see cref="GetValuesAsync"/>.
        /// If you need to combine multiple read or write operations, consider using on of the multiple <see cref="IFdbReadOnlyRetryable.ReadAsync"/> or <see cref="IFdbRetryable.ReadWriteAsync"/> overrides.
        /// </remarks>
        public static Task <Slice> GetAsync([NotNull] this IFdbReadOnlyRetryable db, Slice key, CancellationToken cancellationToken)
        {
            Contract.NotNull(db, nameof(db));
            return(db.ReadAsync((tr) => tr.GetAsync(key), cancellationToken));
        }