예제 #1
0
 public Task <TResult> ReadAsync <TIntermediate, TResult>([InstantHandle] Func <IFdbReadOnlyTransaction, Task <TIntermediate> > handler, [InstantHandle] Func <IFdbReadOnlyTransaction, TIntermediate, Task <TResult> > success, CancellationToken ct)
 {
     return(FdbOperationContext.RunReadWithResultAsync <TIntermediate, TResult>(this, handler, success, ct));
 }
예제 #2
0
 /// <summary>Runs a transactional lambda function against this database, inside a read-only transaction context, with retry logic.</summary>
 /// <param name="state">State that will be passed back to the <paramref name="handler"/></param>
 /// <param name="handler">Asynchronous lambda function that is passed a new read-only transaction on each retry. The result of the task will also be the result of the transactional.</param>
 /// <param name="ct">Optional cancellation token that will be passed to the transaction context, and that can also be used to abort the retry loop.</param>
 public Task <TResult> ReadAsync <TState, TResult>(TState state, Func <IFdbReadOnlyTransaction, TState, Task <TResult> > handler, CancellationToken ct)
 {
     return(FdbOperationContext.RunReadWithResultAsync <TResult>(this, (tr) => handler(tr, state), ct));
 }
 /// <summary>EXPERIMENTAL</summary>
 public Task <R> ReadAsync <R>([InstantHandle] Func <IFdbReadOnlyTransaction, Task <R> > asyncHandler, [InstantHandle] Action <IFdbReadOnlyTransaction> onDone, CancellationToken cancellationToken)
 {
     return(FdbOperationContext.RunReadWithResultAsync <R>(this, asyncHandler, onDone, cancellationToken));
 }
예제 #4
0
        //NOTE: other bindings use different names or concept for transactionals, and some also support ReadOnly vs ReadWrite transaction
        // - Python uses the @transactional decorator with first arg called db_or_trans
        // - JAVA uses db.run() and db.runAsync(), but does not have a method for read-only transactions
        // - Ruby uses db.transact do |tr|
        // - Go uses db.Transact(...) and db.ReadTransact(...)
        // - NodeJS uses fdb.doTransaction(function(...) { ... })

        // Conventions:
        // - ReadAsync() => read-only
        // - WriteAsync() => write-only
        // - ReadWriteAsync() => read/write

        #region IFdbReadOnlyTransactional methods...

        /// <summary>Runs a transactional lambda function against this database, inside a read-only transaction context, with retry logic.</summary>
        /// <param name="handler">Asynchronous lambda function that is passed a new read-only transaction on each retry. The result of the task will also be the result of the transactional.</param>
        /// <param name="ct">Optional cancellation token that will be passed to the transaction context, and that can also be used to abort the retry loop.</param>
        public Task <TResult> ReadAsync <TResult>(Func <IFdbReadOnlyTransaction, Task <TResult> > handler, CancellationToken ct)
        {
            return(FdbOperationContext.RunReadWithResultAsync <TResult>(this, handler, ct));
        }
 /// <summary>Runs a transactional lambda function against this database, inside a read-only transaction context, with retry logic.</summary>
 /// <param name="asyncHandler">Asynchronous lambda function that is passed a new read-only transaction on each retry. The result of the task will also be the result of the transactional.</param>
 /// <param name="cancellationToken">Optional cancellation token that will be passed to the transaction context, and that can also be used to abort the retry loop.</param>
 public Task <R> ReadAsync <R>(Func <IFdbReadOnlyTransaction, Task <R> > asyncHandler, CancellationToken cancellationToken)
 {
     return(FdbOperationContext.RunReadWithResultAsync <R>(this, asyncHandler, null, cancellationToken));
 }