Skip to content

Commit de8c0ce

Browse files
author
Oleksandr Poliakov
committed
CSHARP-3550: CSOT: Server Selection
1 parent 27fd9e5 commit de8c0ce

File tree

141 files changed

+1928
-2418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+1928
-2418
lines changed

src/MongoDB.Driver/Core/Bindings/ChannelChannelSource.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
using System;
17-
using System.Threading;
1817
using System.Threading.Tasks;
1918
using MongoDB.Driver.Core.Misc;
2019
using MongoDB.Driver.Core.Servers;
@@ -64,13 +63,13 @@ public void Dispose()
6463
}
6564
}
6665

67-
public IChannelHandle GetChannel(CancellationToken cancellationToken)
66+
public IChannelHandle GetChannel(OperationCancellationContext cancellationContext)
6867
{
6968
ThrowIfDisposed();
7069
return GetChannelHelper();
7170
}
7271

73-
public Task<IChannelHandle> GetChannelAsync(CancellationToken cancellationToken)
72+
public Task<IChannelHandle> GetChannelAsync(OperationCancellationContext cancellationContext)
7473
{
7574
ThrowIfDisposed();
7675
return Task.FromResult(GetChannelHelper());

src/MongoDB.Driver/Core/Bindings/ChannelReadBinding.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
using System;
1717
using System.Collections.Generic;
18-
using System.Threading;
1918
using System.Threading.Tasks;
2019
using MongoDB.Driver.Core.Misc;
2120
using MongoDB.Driver.Core.Servers;
@@ -58,26 +57,26 @@ public void Dispose()
5857
}
5958
}
6059

61-
public IChannelSourceHandle GetReadChannelSource(CancellationToken cancellationToken)
60+
public IChannelSourceHandle GetReadChannelSource(OperationCancellationContext cancellationContext)
6261
{
6362
ThrowIfDisposed();
6463
return GetReadChannelSourceHelper();
6564
}
6665

67-
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(CancellationToken cancellationToken)
66+
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationCancellationContext cancellationContext)
6867
{
6968
ThrowIfDisposed();
7069
return Task.FromResult<IChannelSourceHandle>(GetReadChannelSourceHelper());
7170
}
7271

73-
public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
72+
public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
7473
{
75-
return GetReadChannelSource(cancellationToken);
74+
return GetReadChannelSource(cancellationContext);
7675
}
7776

78-
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
77+
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
7978
{
80-
return GetReadChannelSourceAsync(cancellationToken);
79+
return GetReadChannelSourceAsync(cancellationContext);
8180
}
8281

8382
private IChannelSourceHandle GetReadChannelSourceHelper()

src/MongoDB.Driver/Core/Bindings/ChannelReadWriteBinding.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
using System;
1717
using System.Collections.Generic;
18-
using System.Threading;
1918
using System.Threading.Tasks;
2019
using MongoDB.Driver.Core.Misc;
2120
using MongoDB.Driver.Core.Servers;
@@ -56,68 +55,68 @@ public void Dispose()
5655
}
5756
}
5857

59-
public IChannelSourceHandle GetReadChannelSource(CancellationToken cancellationToken)
58+
public IChannelSourceHandle GetReadChannelSource(OperationCancellationContext cancellationContext)
6059
{
6160
ThrowIfDisposed();
6261
return GetChannelSourceHelper();
6362
}
6463

65-
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(CancellationToken cancellationToken)
64+
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationCancellationContext cancellationContext)
6665
{
6766
ThrowIfDisposed();
6867
return Task.FromResult(GetChannelSourceHelper());
6968
}
7069

71-
public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
70+
public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
7271
{
73-
return GetReadChannelSource(cancellationToken);
72+
return GetReadChannelSource(cancellationContext);
7473
}
7574

76-
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
75+
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
7776
{
78-
return GetReadChannelSourceAsync(cancellationToken);
77+
return GetReadChannelSourceAsync(cancellationContext);
7978
}
8079

81-
public IChannelSourceHandle GetWriteChannelSource(CancellationToken cancellationToken)
80+
public IChannelSourceHandle GetWriteChannelSource(OperationCancellationContext cancellationContext)
8281
{
8382
ThrowIfDisposed();
8483
return GetChannelSourceHelper();
8584
}
8685

87-
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
86+
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
8887
{
89-
return GetWriteChannelSource(cancellationToken);
88+
return GetWriteChannelSource(cancellationContext);
9089
}
9190

92-
public IChannelSourceHandle GetWriteChannelSource(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
91+
public IChannelSourceHandle GetWriteChannelSource(IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
9392
{
94-
return GetWriteChannelSource(cancellationToken); // ignore mayUseSecondary
93+
return GetWriteChannelSource(cancellationContext); // ignore mayUseSecondary
9594
}
9695

97-
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
96+
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
9897
{
99-
return GetWriteChannelSource(mayUseSecondary, cancellationToken);
98+
return GetWriteChannelSource(mayUseSecondary, cancellationContext);
10099
}
101100

102-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(CancellationToken cancellationToken)
101+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationCancellationContext cancellationContext)
103102
{
104103
ThrowIfDisposed();
105104
return Task.FromResult(GetChannelSourceHelper());
106105
}
107106

108-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
107+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
109108
{
110-
return GetWriteChannelSourceAsync(cancellationToken);
109+
return GetWriteChannelSourceAsync(cancellationContext);
111110
}
112111

113-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
112+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
114113
{
115-
return GetWriteChannelSourceAsync(cancellationToken); // ignore mayUseSecondary
114+
return GetWriteChannelSourceAsync(cancellationContext); // ignore mayUseSecondary
116115
}
117116

118-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
117+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
119118
{
120-
return GetWriteChannelSourceAsync(mayUseSecondary, cancellationToken);
119+
return GetWriteChannelSourceAsync(mayUseSecondary, cancellationContext);
121120
}
122121

123122
private IChannelSourceHandle GetChannelSourceHelper()

src/MongoDB.Driver/Core/Bindings/ChannelSourceHandle.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
using System;
17-
using System.Threading;
1817
using System.Threading.Tasks;
1918
using MongoDB.Driver.Core.Misc;
2019
using MongoDB.Driver.Core.Servers;
@@ -55,16 +54,16 @@ public ICoreSessionHandle Session
5554
}
5655

5756
// methods
58-
public IChannelHandle GetChannel(CancellationToken cancellationToken)
57+
public IChannelHandle GetChannel(OperationCancellationContext cancellationContext)
5958
{
6059
ThrowIfDisposed();
61-
return _reference.Instance.GetChannel(cancellationToken);
60+
return _reference.Instance.GetChannel(cancellationContext);
6261
}
6362

64-
public Task<IChannelHandle> GetChannelAsync(CancellationToken cancellationToken)
63+
public Task<IChannelHandle> GetChannelAsync(OperationCancellationContext cancellationContext)
6564
{
6665
ThrowIfDisposed();
67-
return _reference.Instance.GetChannelAsync(cancellationToken);
66+
return _reference.Instance.GetChannelAsync(cancellationContext);
6867
}
6968

7069
public void Dispose()

src/MongoDB.Driver/Core/Bindings/ChannelSourceReadWriteBinding.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
using System;
1717
using System.Collections.Generic;
18-
using System.Threading;
1918
using System.Threading.Tasks;
2019
using MongoDB.Driver.Core.Misc;
2120
using MongoDB.Driver.Core.Servers;
@@ -46,68 +45,68 @@ public ICoreSessionHandle Session
4645
get { return _session; }
4746
}
4847

49-
public IChannelSourceHandle GetReadChannelSource(CancellationToken cancellationToken)
48+
public IChannelSourceHandle GetReadChannelSource(OperationCancellationContext cancellationContext)
5049
{
5150
ThrowIfDisposed();
5251
return GetChannelSourceHelper();
5352
}
5453

55-
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(CancellationToken cancellationToken)
54+
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(OperationCancellationContext cancellationContext)
5655
{
5756
ThrowIfDisposed();
5857
return Task.FromResult(GetChannelSourceHelper());
5958
}
6059

61-
public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
60+
public IChannelSourceHandle GetReadChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
6261
{
63-
return GetReadChannelSource(cancellationToken);
62+
return GetReadChannelSource(cancellationContext);
6463
}
6564

66-
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
65+
public Task<IChannelSourceHandle> GetReadChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
6766
{
68-
return GetReadChannelSourceAsync(cancellationToken);
67+
return GetReadChannelSourceAsync(cancellationContext);
6968
}
7069

71-
public IChannelSourceHandle GetWriteChannelSource(CancellationToken cancellationToken)
70+
public IChannelSourceHandle GetWriteChannelSource(OperationCancellationContext cancellationContext)
7271
{
7372
ThrowIfDisposed();
7473
return GetChannelSourceHelper();
7574
}
7675

77-
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
76+
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
7877
{
79-
return GetWriteChannelSource(cancellationToken);
78+
return GetWriteChannelSource(cancellationContext);
8079
}
8180

82-
public IChannelSourceHandle GetWriteChannelSource(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
81+
public IChannelSourceHandle GetWriteChannelSource(IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
8382
{
84-
return GetWriteChannelSource(cancellationToken); // ignore mayUseSecondary
83+
return GetWriteChannelSource(cancellationContext); // ignore mayUseSecondary
8584
}
8685

87-
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
86+
public IChannelSourceHandle GetWriteChannelSource(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
8887
{
89-
return GetWriteChannelSource(mayUseSecondary, cancellationToken);
88+
return GetWriteChannelSource(mayUseSecondary, cancellationContext);
9089
}
9190

92-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(CancellationToken cancellationToken)
91+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(OperationCancellationContext cancellationContext)
9392
{
9493
ThrowIfDisposed();
9594
return Task.FromResult(GetChannelSourceHelper());
9695
}
9796

98-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, CancellationToken cancellationToken)
97+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, OperationCancellationContext cancellationContext)
9998
{
100-
return GetWriteChannelSourceAsync(cancellationToken);
99+
return GetWriteChannelSourceAsync(cancellationContext);
101100
}
102101

103-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
102+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
104103
{
105-
return GetWriteChannelSourceAsync(cancellationToken); // ignore mayUseSecondary
104+
return GetWriteChannelSourceAsync(cancellationContext); // ignore mayUseSecondary
106105
}
107106

108-
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, CancellationToken cancellationToken)
107+
public Task<IChannelSourceHandle> GetWriteChannelSourceAsync(IReadOnlyCollection<ServerDescription> deprioritizedServers, IMayUseSecondaryCriteria mayUseSecondary, OperationCancellationContext cancellationContext)
109108
{
110-
return GetWriteChannelSourceAsync(mayUseSecondary, cancellationToken);
109+
return GetWriteChannelSourceAsync(mayUseSecondary, cancellationContext);
111110
}
112111

113112
public void Dispose()

0 commit comments

Comments
 (0)