// public methods /// <inheritdoc /> public IChangeStreamCursor <TResult> Execute(IReadBinding binding, CancellationToken cancellationToken) { var bindingHandle = binding as IReadBindingHandle; if (bindingHandle == null) { throw new ArgumentException("The binding value passed to ChangeStreamOperation.Execute must implement IReadBindingHandle.", nameof(binding)); } IAsyncCursor <RawBsonDocument> cursor; ICursorBatchInfo cursorBatchInfo; BsonTimestamp initialOperationTime; using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { cursor = ExecuteAggregateOperation(channelBinding, cancellationToken); cursorBatchInfo = (ICursorBatchInfo)cursor; initialOperationTime = GetInitialOperationTimeIfRequired(channel, channelBinding, cursorBatchInfo); } var postBatchResumeToken = GetInitialPostBatchResumeTokenIfRequired(cursorBatchInfo); return(new ChangeStreamCursor <TResult>( cursor, _resultSerializer, bindingHandle.Fork(), this, postBatchResumeToken, initialOperationTime, _startAfter, _resumeAfter, _startAtOperationTime)); }
/// <inheritdoc /> public async Task <IAsyncCursor <TResult> > ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { var bindingHandle = binding as IReadBindingHandle; if (bindingHandle == null) { throw new ArgumentException("The binding value passed to ChangeStreamOperation.ExecuteAsync must implement IReadBindingHandle.", nameof(binding)); } IAsyncCursor <RawBsonDocument> cursor; using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { cursor = await ResumeAsync(channelBinding, cancellationToken).ConfigureAwait(false); if (_startAtOperationTime == null && _resumeAfter == null) { var maxWireVersion = channel.ConnectionDescription.IsMasterResult.MaxWireVersion; if (maxWireVersion >= 7) { _startAtOperationTime = binding.Session.OperationTime; } } } return(new ChangeStreamCursor <TResult>(cursor, _resultSerializer, bindingHandle.Fork(), this)); }
/// <inheritdoc/> public BsonDocument Execute(IReadBinding binding, CancellationToken cancellationToken) { using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(); return(operation.Execute(channelBinding, cancellationToken)); } }
// public methods public BsonDocument Execute(IReadBinding binding, CancellationToken cancellationToken = default(CancellationToken)) { using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = new CurrentOpUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); return(operation.Execute(channelBinding, cancellationToken)); } }
/// <inheritdoc/> public async Task <BsonDocument> ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(); return(await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false)); } }
// public methods public BsonDocument Execute(IReadBinding binding, CancellationToken cancellationToken = default(CancellationToken)) { using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel.ConnectionDescription.ServerVersion); return(operation.Execute(channelBinding, cancellationToken)); } }
// public methods /// <inheritdoc/> public IEnumerable <TResult> Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(); return(operation.Execute(channelBinding, cancellationToken)); } }
/// <inheritdoc/> public async Task <TResult> ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel.ConnectionDescription.ServerVersion); return(await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false)); } }
/// <inheritdoc/> public TResult Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel.ConnectionDescription.ServerVersion); return(operation.Execute(channelBinding, cancellationToken)); } }
/// <inheritdoc/> public long Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(channel, channelBinding); var document = operation.Execute(channelBinding, cancellationToken); return(document["n"].ToInt64()); } }
// public methods /// <inheritdoc/> public IAsyncCursor <TValue> Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(channel, channelBinding); var values = operation.Execute(channelBinding, cancellationToken); return(new SingleBatchAsyncCursor <TValue>(values)); } }
/// <inheritdoc/> public async Task <IAsyncCursor <BsonDocument> > ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel); return(await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false)); } }
// public methods /// <inheritdoc/> public IAsyncCursor <BsonDocument> Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel); return(operation.Execute(channelBinding, cancellationToken)); } }
/// <inheritdoc/> public async Task <IAsyncCursor <TValue> > ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(channel, channelBinding); var values = await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false); return(new SingleBatchAsyncCursor <TValue>(values)); } }
/// <inheritdoc/> public async Task <long> ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(channel, channelBinding); var document = await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false); return(document["n"].ToInt64()); } }
// public methods /// <inheritdoc/> public long Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(); var cursor = operation.Execute(channelBinding, cancellationToken); var result = cursor.ToList(cancellationToken); return(ExtractCountFromResult(result)); } }
// methods public IEnumerable <BsonDocument> Execute(IReadBinding binding, CancellationToken cancellationToken) { using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = new FindUsersUsingUserManagementCommandsOperation( _databaseNamespace, _username, _messageEncoderSettings); return(operation.Execute(channelBinding, cancellationToken)); } }
/// <inheritdoc/> public IReadOnlyList <IAsyncCursor <TDocument> > Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(channel, channelBinding); var result = operation.Execute(channelBinding, cancellationToken); return(CreateCursors(channelSource, operation.Command, result)); } }
// methods /// <inheritdoc/> public IAsyncCursor <TResult> Execute(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); EnsureIsReadOnlyPipeline(); using (EventContext.BeginOperation()) using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel); var result = operation.Execute(channelBinding, cancellationToken); return(CreateCursor(channelSource, channel, operation.Command, result)); } }
/// <inheritdoc/> public async Task <IReadOnlyList <IAsyncCursor <TDocument> > > ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var operation = CreateOperation(channel.ConnectionDescription.ServerVersion); var result = await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false); return(CreateCursors(channelSource, operation.Command, result)); } }
/// <inheritdoc/> public async Task <long> ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(); var cursor = await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false); var result = await cursor.ToListAsync(cancellationToken).ConfigureAwait(false); return(ExtractCountFromResult(result)); } }
/// <inheritdoc/> public async Task <IAsyncCursor <TResult> > ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) { Ensure.IsNotNull(binding, nameof(binding)); EnsureIsReadOnlyPipeline(); using (EventContext.BeginOperation()) using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var operation = CreateOperation(channel, channelBinding); var result = await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false); return(CreateCursor(channelSource, channel, operation.Command, result)); } }
/// <inheritdoc/> public IAsyncCursor <TDocument> Execute(IReadBinding binding, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var readPreference = binding.ReadPreference; using (EventContext.BeginFind(_batchSize, _limit)) { var operation = CreateOperation(channel, channelBinding); var commandResult = operation.Execute(channelBinding, cancellationToken); return(CreateCursor(channelSource, commandResult)); } } }
/// <inheritdoc/> public IAsyncCursor <TDocument> Execute(IReadBinding binding, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference)) { var readPreference = binding.ReadPreference; var slaveOk = readPreference != null && readPreference.ReadPreferenceMode != ReadPreferenceMode.Primary; using (EventContext.BeginFind(_batchSize, _limit)) { var operation = CreateOperation(channel.ConnectionDescription.ServerVersion, channelSource.ServerDescription.Type); var commandResult = operation.Execute(binding, cancellationToken); return(CreateCursor(channelSource, commandResult, slaveOk)); } } }
// methods public IEnumerable <BsonDocument> Execute(IReadBinding binding, CancellationToken cancellationToken) { using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { IReadOperation <IEnumerable <BsonDocument> > operation; if (Feature.UserManagementCommands.IsSupported(channel.ConnectionDescription.ServerVersion)) { operation = new FindUsersUsingUserManagementCommandsOperation(_databaseNamespace, _username, _messageEncoderSettings); } else { operation = new FindUsersUsingSystemUsersCollectionOperation(_databaseNamespace, _username, _messageEncoderSettings); } return(operation.Execute(channelBinding, cancellationToken)); } }
/// <inheritdoc/> public async Task <IAsyncCursor <TDocument> > ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.IsNotNull(binding, nameof(binding)); using (EventContext.BeginOperation()) using (var channelSource = await binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false)) using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { var readPreference = binding.ReadPreference; var slaveOk = readPreference != null && readPreference.ReadPreferenceMode != ReadPreferenceMode.Primary; using (EventContext.BeginFind(_batchSize, _limit)) { var operation = CreateOperation(channel, channelBinding); var commandResult = await operation.ExecuteAsync(channelBinding, cancellationToken).ConfigureAwait(false); return(CreateCursor(channelSource, commandResult, slaveOk)); } } }
// public methods /// <inheritdoc /> public IAsyncCursor <TResult> Execute(IReadBinding binding, CancellationToken cancellationToken) { var bindingHandle = binding as IReadBindingHandle; if (bindingHandle == null) { throw new ArgumentException("The binding value passed to ChangeStreamOperation.Execute must implement IReadBindingHandle.", nameof(binding)); } IAsyncCursor <RawBsonDocument> cursor; using (var channelSource = binding.GetReadChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadBinding(channelSource.Server, channel, binding.ReadPreference, binding.Session.Fork())) { cursor = ExecuteAggregateOperation(channelBinding, resuming: false, cancellationToken); SaveInitialOperationTimeIfRequired(channel, channelBinding, cursor); } return(new ChangeStreamCursor <TResult>(cursor, _resultSerializer, bindingHandle.Fork(), this)); }