Skip to content

CSHARP-3550: CSOT: Server Selection #1705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/MongoDB.Driver/Core/Bindings/ChannelChannelSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

using System;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver.Core.Misc;
using MongoDB.Driver.Core.Servers;
Expand Down Expand Up @@ -64,13 +63,13 @@ public void Dispose()
}
}

public IChannelHandle GetChannel(CancellationToken cancellationToken)
public IChannelHandle GetChannel(OperationContext operationContext)
{
ThrowIfDisposed();
return GetChannelHelper();
}

public Task<IChannelHandle> GetChannelAsync(CancellationToken cancellationToken)
public Task<IChannelHandle> GetChannelAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return Task.FromResult(GetChannelHelper());
Expand Down
13 changes: 6 additions & 7 deletions src/MongoDB.Driver/Core/Bindings/ChannelReadBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver.Core.Misc;
using MongoDB.Driver.Core.Servers;
Expand Down Expand Up @@ -58,26 +57,26 @@ public void Dispose()
}
}

public IChannelSourceHandle GetReadChannelSource(CancellationToken cancellationToken)
public IChannelSourceHandle GetReadChannelSource(OperationContext operationContext)
{
ThrowIfDisposed();
return GetReadChannelSourceHelper();
}

public Task<IChannelSourceHandle> GetReadChannelSourceAsync(CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return Task.FromResult<IChannelSourceHandle>(GetReadChannelSourceHelper());
}

public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public IChannelSourceHandle GetReadChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetReadChannelSource(cancellationToken);
return GetReadChannelSource(operationContext);
}

public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetReadChannelSourceAsync(cancellationToken);
return GetReadChannelSourceAsync(operationContext);
}

private IChannelSourceHandle GetReadChannelSourceHelper()
Expand Down
41 changes: 20 additions & 21 deletions src/MongoDB.Driver/Core/Bindings/ChannelReadWriteBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver.Core.Misc;
using MongoDB.Driver.Core.Servers;
Expand Down Expand Up @@ -56,68 +55,68 @@ public void Dispose()
}
}

public IChannelSourceHandle GetReadChannelSource(CancellationToken cancellationToken)
public IChannelSourceHandle GetReadChannelSource(OperationContext operationContext)
{
ThrowIfDisposed();
return GetChannelSourceHelper();
}

public Task<IChannelSourceHandle> GetReadChannelSourceAsync(CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return Task.FromResult(GetChannelSourceHelper());
}

public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public IChannelSourceHandle GetReadChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetReadChannelSource(cancellationToken);
return GetReadChannelSource(operationContext);
}

public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetReadChannelSourceAsync(cancellationToken);
return GetReadChannelSourceAsync(operationContext);
}

public IChannelSourceHandle GetWriteChannelSource(CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext)
{
ThrowIfDisposed();
return GetChannelSourceHelper();
}

public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetWriteChannelSource(cancellationToken);
return GetWriteChannelSource(operationContext);
}

public IChannelSourceHandle GetWriteChannelSource(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSource(cancellationToken); // ignore mayUseSecondary
return GetWriteChannelSource(operationContext); // ignore mayUseSecondary
}

public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSource(mayUseSecondary, cancellationToken);
return GetWriteChannelSource(operationContext, mayUseSecondary);
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return Task.FromResult(GetChannelSourceHelper());
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetWriteChannelSourceAsync(cancellationToken);
return GetWriteChannelSourceAsync(operationContext);
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSourceAsync(cancellationToken); // ignore mayUseSecondary
return GetWriteChannelSourceAsync(operationContext); // ignore mayUseSecondary
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSourceAsync(mayUseSecondary, cancellationToken);
return GetWriteChannelSourceAsync(operationContext, mayUseSecondary);
}

private IChannelSourceHandle GetChannelSourceHelper()
Expand Down
9 changes: 4 additions & 5 deletions src/MongoDB.Driver/Core/Bindings/ChannelSourceHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

using System;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver.Core.Misc;
using MongoDB.Driver.Core.Servers;
Expand Down Expand Up @@ -55,16 +54,16 @@ public ICoreSessionHandle Session
}

// methods
public IChannelHandle GetChannel(CancellationToken cancellationToken)
public IChannelHandle GetChannel(OperationContext operationContext)
{
ThrowIfDisposed();
return _reference.Instance.GetChannel(cancellationToken);
return _reference.Instance.GetChannel(operationContext);
}

public Task<IChannelHandle> GetChannelAsync(CancellationToken cancellationToken)
public Task<IChannelHandle> GetChannelAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return _reference.Instance.GetChannelAsync(cancellationToken);
return _reference.Instance.GetChannelAsync(operationContext);
}

public void Dispose()
Expand Down
41 changes: 20 additions & 21 deletions src/MongoDB.Driver/Core/Bindings/ChannelSourceReadWriteBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver.Core.Misc;
using MongoDB.Driver.Core.Servers;
Expand Down Expand Up @@ -46,68 +45,68 @@ public ICoreSessionHandle Session
get { return _session; }
}

public IChannelSourceHandle GetReadChannelSource(CancellationToken cancellationToken)
public IChannelSourceHandle GetReadChannelSource(OperationContext operationContext)
{
ThrowIfDisposed();
return GetChannelSourceHelper();
}

public Task<IChannelSourceHandle> GetReadChannelSourceAsync(CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return Task.FromResult(GetChannelSourceHelper());
}

public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public IChannelSourceHandle GetReadChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetReadChannelSource(cancellationToken);
return GetReadChannelSource(operationContext);
}

public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetReadChannelSourceAsync(cancellationToken);
return GetReadChannelSourceAsync(operationContext);
}

public IChannelSourceHandle GetWriteChannelSource(CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext)
{
ThrowIfDisposed();
return GetChannelSourceHelper();
}

public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetWriteChannelSource(cancellationToken);
return GetWriteChannelSource(operationContext);
}

public IChannelSourceHandle GetWriteChannelSource(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSource(cancellationToken); // ignore mayUseSecondary
return GetWriteChannelSource(operationContext); // ignore mayUseSecondary
}

public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public IChannelSourceHandle GetWriteChannelSource(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSource(mayUseSecondary, cancellationToken);
return GetWriteChannelSource(operationContext, mayUseSecondary);
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext)
{
ThrowIfDisposed();
return Task.FromResult(GetChannelSourceHelper());
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers)
{
return GetWriteChannelSourceAsync(cancellationToken);
return GetWriteChannelSourceAsync(operationContext);
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSourceAsync(cancellationToken); // ignore mayUseSecondary
return GetWriteChannelSourceAsync(operationContext); // ignore mayUseSecondary
}

public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationContext operationContext, IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary)
{
return GetWriteChannelSourceAsync(mayUseSecondary, cancellationToken);
return GetWriteChannelSourceAsync(operationContext, mayUseSecondary);
}

public void Dispose()
Expand Down
Loading