コード例 #1
0
 private async Task <T> ExecuteWriteOperationAsync <T>(IClientSessionHandle session, IWriteOperation <T> operation, CancellationToken cancellationToken)
 {
     using (var binding = new WritableServerBinding(_cluster, session.ToCoreSession()))
     {
         return(await _operationExecutor.ExecuteWriteOperationAsync(binding, operation, cancellationToken).ConfigureAwait(false));
     }
 }
コード例 #2
0
 private T ExecuteWriteOperation <T>(IClientSessionHandle session, IWriteOperation <T> operation, CancellationToken cancellationToken)
 {
     using (var binding = new WritableServerBinding(_cluster, session.ToCoreSession()))
     {
         return(_operationExecutor.ExecuteWriteOperation(binding, operation, cancellationToken));
     }
 }
コード例 #3
0
 private async Task <T> ExecuteReadOperationAsync <T>(IClientSessionHandle session, IReadOperation <T> operation, ReadPreference readPreference, CancellationToken cancellationToken)
 {
     using (var binding = new ReadPreferenceBinding(_cluster, readPreference, session.ToCoreSession()))
     {
         return(await _operationExecutor.ExecuteReadOperationAsync(binding, operation, cancellationToken).ConfigureAwait(false));
     }
 }
コード例 #4
0
 private T ExecuteReadOperation <T>(IClientSessionHandle session, IReadOperation <T> operation, ReadPreference readPreference, CancellationToken cancellationToken)
 {
     using (var binding = new ReadPreferenceBinding(_cluster, readPreference, session.ToCoreSession()))
     {
         return(_operationExecutor.ExecuteReadOperation(binding, operation, cancellationToken));
     }
 }
コード例 #5
0
        internal IWriteBindingHandle GetWriteBinding(IClientSessionHandle session)
        {
            var request = __threadStaticRequest;

            if (request != null)
            {
                return(ToWriteBinding(request.Binding).Fork());
            }

            return(new ReadWriteBindingHandle(new WritableServerBinding(_cluster, session.ToCoreSession())));
        }
コード例 #6
0
        // internal methods
        internal IReadBindingHandle GetReadBinding(ReadPreference readPreference, IClientSessionHandle session)
        {
            var request = __threadStaticRequest;

            if (request != null)
            {
                return(request.Binding.Fork());
            }

            if (readPreference.ReadPreferenceMode == ReadPreferenceMode.Primary)
            {
                return(new ReadWriteBindingHandle(new WritableServerBinding(_cluster, session.ToCoreSession())));
            }
            else
            {
                return(new ReadBindingHandle(new ReadPreferenceBinding(_cluster, readPreference, session.ToCoreSession())));
            }
        }
コード例 #7
0
 private TResult ExecuteReadOperation <TResult>(IClientSessionHandle session, IReadOperation <TResult> operation, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var binding = new ReadPreferenceBinding(_cluster, _settings.ReadPreference, session.ToCoreSession()))
     {
         return(_operationExecutor.ExecuteReadOperation(binding, operation, cancellationToken));
     }
 }