Skip to content

Commit e6be564

Browse files
authored
CSHARP-5234: Make IConnection/IChannels and related API internal (#1434)
1 parent f76c7cd commit e6be564

18 files changed

+28
-437
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,18 @@
1616
using System;
1717
using System.Threading;
1818
using System.Threading.Tasks;
19-
using MongoDB.Driver.Core.Connections;
2019
using MongoDB.Driver.Core.Misc;
2120
using MongoDB.Driver.Core.Servers;
2221

2322
namespace MongoDB.Driver.Core.Bindings
2423
{
25-
/// <summary>
26-
/// Represents a handle to a channel source.
27-
/// </summary>
2824
internal sealed class ChannelSourceHandle : IChannelSourceHandle
2925
{
3026
// fields
3127
private bool _disposed;
3228
private readonly ReferenceCounted<IChannelSource> _reference;
3329

3430
// constructors
35-
/// <summary>
36-
/// Initializes a new instance of the <see cref="ChannelSourceHandle"/> class.
37-
/// </summary>
38-
/// <param name="channelSource">The channel source.</param>
3931
public ChannelSourceHandle(IChannelSource channelSource)
4032
: this(new ReferenceCounted<IChannelSource>(channelSource))
4133
{
@@ -47,40 +39,34 @@ private ChannelSourceHandle(ReferenceCounted<IChannelSource> reference)
4739
}
4840

4941
// properties
50-
/// <inheritdoc/>
5142
public IServer Server
5243
{
5344
get { return _reference.Instance.Server; }
5445
}
5546

56-
/// <inheritdoc/>
5747
public ServerDescription ServerDescription
5848
{
5949
get { return _reference.Instance.ServerDescription; }
6050
}
6151

62-
/// <inheritdoc/>
6352
public ICoreSessionHandle Session
6453
{
6554
get { return _reference.Instance.Session; }
6655
}
6756

6857
// methods
69-
/// <inheritdoc/>
7058
public IChannelHandle GetChannel(CancellationToken cancellationToken)
7159
{
7260
ThrowIfDisposed();
7361
return _reference.Instance.GetChannel(cancellationToken);
7462
}
7563

76-
/// <inheritdoc/>
7764
public Task<IChannelHandle> GetChannelAsync(CancellationToken cancellationToken)
7865
{
7966
ThrowIfDisposed();
8067
return _reference.Instance.GetChannelAsync(cancellationToken);
8168
}
8269

83-
/// <inheritdoc/>
8470
public void Dispose()
8571
{
8672
if (!_disposed)
@@ -91,7 +77,6 @@ public void Dispose()
9177
}
9278
}
9379

94-
/// <inheritdoc/>
9580
public IChannelSourceHandle Fork()
9681
{
9782
ThrowIfDisposed();

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2017-present MongoDB Inc.
1+
/* Copyright 2010-present MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020

2121
namespace MongoDB.Driver
2222
{
23-
internal class CoreServerSessionPool : ICoreServerSessionPool
23+
internal sealed class CoreServerSessionPool : ICoreServerSessionPool
2424
{
2525
// private fields
2626
private readonly ICluster _cluster;
@@ -33,7 +33,6 @@ public CoreServerSessionPool(ICluster cluster)
3333
_cluster = Ensure.IsNotNull(cluster, nameof(cluster));
3434
}
3535

36-
/// <inheritdoc />
3736
public ICoreServerSession AcquireSession()
3837
{
3938
lock (_lock)
@@ -59,7 +58,6 @@ public ICoreServerSession AcquireSession()
5958
return new ReleaseOnDisposeCoreServerSession(new CoreServerSession(), this);
6059
}
6160

62-
/// <inheritdoc />
6361
public void ReleaseSession(ICoreServerSession session)
6462
{
6563
lock (_lock)

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,7 @@ public CoreTransaction(long transactionNumber, TransactionOptions transactionOpt
6464
/// </value>
6565
public CoreTransactionState State => _state;
6666

67-
/// <summary>
68-
/// Gets pinned channel for the current transaction.
69-
/// Value has meaning if and only if a transaction is in progress.
70-
/// </summary>
71-
/// <value>
72-
/// The pinned channel for the current transaction.
73-
/// </value>
74-
public IChannelHandle PinnedChannel
67+
internal IChannelHandle PinnedChannel
7568
{
7669
get => _pinnedChannel;
7770
}

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

Lines changed: 2 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,11 @@
2727

2828
namespace MongoDB.Driver.Core.Bindings
2929
{
30-
/// <summary>
31-
/// Represents a channel (similar to a connection but operates at the level of protocols rather than messages).
32-
/// </summary>
33-
public interface IChannel : IDisposable
30+
internal interface IChannel : IDisposable
3431
{
35-
/// <summary>
36-
/// Gets the connection.
37-
/// </summary>
38-
/// <value>
39-
/// The connection.
40-
/// </value>
4132
IConnectionHandle Connection { get; }
42-
43-
/// <summary>
44-
/// Gets the connection description.
45-
/// </summary>
46-
/// <value>
47-
/// The connection description.
48-
/// </value>
4933
ConnectionDescription ConnectionDescription { get; }
5034

51-
/// <summary>
52-
/// Executes a Command protocol.
53-
/// </summary>
54-
/// <typeparam name="TResult">The type of the result.</typeparam>
55-
/// <param name="session">The session.</param>
56-
/// <param name="readPreference">The read preference.</param>
57-
/// <param name="databaseNamespace">The database namespace.</param>
58-
/// <param name="command">The command.</param>
59-
/// <param name="commandPayloads">The command payloads.</param>
60-
/// <param name="commandValidator">The command validator.</param>
61-
/// <param name="additionalOptions">The additional options.</param>
62-
/// <param name="postWriteAction">The post write action.</param>
63-
/// <param name="responseHandling">The response handling.</param>
64-
/// <param name="resultSerializer">The result serializer.</param>
65-
/// <param name="messageEncoderSettings">The message encoder settings.</param>
66-
/// <param name="cancellationToken">The cancellation token.</param>
67-
/// <returns>
68-
/// The result of the Command protocol.
69-
/// </returns>
7035
TResult Command<TResult>(
7136
ICoreSession session,
7237
ReadPreference readPreference,
@@ -81,25 +46,6 @@ TResult Command<TResult>(
8146
MessageEncoderSettings messageEncoderSettings,
8247
CancellationToken cancellationToken);
8348

84-
/// <summary>
85-
/// Executes a Command protocol.
86-
/// </summary>
87-
/// <typeparam name="TResult">The type of the result.</typeparam>
88-
/// <param name="session">The session.</param>
89-
/// <param name="readPreference">The read preference.</param>
90-
/// <param name="databaseNamespace">The database namespace.</param>
91-
/// <param name="command">The command.</param>
92-
/// <param name="commandPayloads">The command payloads.</param>
93-
/// <param name="commandValidator">The command validator.</param>
94-
/// <param name="additionalOptions">The additional options.</param>
95-
/// <param name="postWriteAction">The post write action.</param>
96-
/// <param name="responseHandling">The response handling.</param>
97-
/// <param name="resultSerializer">The result serializer.</param>
98-
/// <param name="messageEncoderSettings">The message encoder settings.</param>
99-
/// <param name="cancellationToken">The cancellation token.</param>
100-
/// <returns>
101-
/// A Task whose result is the result of the Command protocol.
102-
/// </returns>
10349
Task<TResult> CommandAsync<TResult>(
10450
ICoreSession session,
10551
ReadPreference readPreference,
@@ -114,25 +60,6 @@ Task<TResult> CommandAsync<TResult>(
11460
MessageEncoderSettings messageEncoderSettings,
11561
CancellationToken cancellationToken);
11662

117-
/// <summary>
118-
/// Executes a Query protocol.
119-
/// </summary>
120-
/// <typeparam name="TDocument">The type of the document.</typeparam>
121-
/// <param name="collectionNamespace">The collection namespace.</param>
122-
/// <param name="query">The query.</param>
123-
/// <param name="fields">The fields.</param>
124-
/// <param name="queryValidator">The query validator.</param>
125-
/// <param name="skip">The number of documents to skip.</param>
126-
/// <param name="batchSize">The size of a batch.</param>
127-
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
128-
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
129-
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
130-
/// <param name="tailableCursor">if set to <c>true</c> the query should return a tailable cursor.</param>
131-
/// <param name="awaitData">if set to <c>true</c> the server should await awhile before returning an empty batch for a tailable cursor.</param>
132-
/// <param name="serializer">The serializer.</param>
133-
/// <param name="messageEncoderSettings">The message encoder settings.</param>
134-
/// <param name="cancellationToken">The cancellation token.</param>
135-
/// <returns>The result of the Insert protocol.</returns>
13663
CursorBatch<TDocument> Query<TDocument>(
13764
CollectionNamespace collectionNamespace,
13865
BsonDocument query,
@@ -149,26 +76,6 @@ CursorBatch<TDocument> Query<TDocument>(
14976
MessageEncoderSettings messageEncoderSettings,
15077
CancellationToken cancellationToken);
15178

152-
/// <summary>
153-
/// Executes a Query protocol.
154-
/// </summary>
155-
/// <typeparam name="TDocument">The type of the document.</typeparam>
156-
/// <param name="collectionNamespace">The collection namespace.</param>
157-
/// <param name="query">The query.</param>
158-
/// <param name="fields">The fields.</param>
159-
/// <param name="queryValidator">The query validator.</param>
160-
/// <param name="skip">The number of documents to skip.</param>
161-
/// <param name="batchSize">The size of a batch.</param>
162-
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
163-
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
164-
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
165-
/// <param name="oplogReplay">if set to <c>true</c> the OplogReplay bit will be set.</param>
166-
/// <param name="tailableCursor">if set to <c>true</c> the query should return a tailable cursor.</param>
167-
/// <param name="awaitData">if set to <c>true</c> the server should await awhile before returning an empty batch for a tailable cursor.</param>
168-
/// <param name="serializer">The serializer.</param>
169-
/// <param name="messageEncoderSettings">The message encoder settings.</param>
170-
/// <param name="cancellationToken">The cancellation token.</param>
171-
/// <returns>The result of the Insert protocol.</returns>
17279
[Obsolete("Use an overload that does not have an oplogReplay parameter instead.")]
17380
CursorBatch<TDocument> Query<TDocument>(
17481
CollectionNamespace collectionNamespace,
@@ -187,25 +94,6 @@ CursorBatch<TDocument> Query<TDocument>(
18794
MessageEncoderSettings messageEncoderSettings,
18895
CancellationToken cancellationToken);
18996

190-
/// <summary>
191-
/// Executes a Query protocol.
192-
/// </summary>
193-
/// <typeparam name="TDocument">The type of the document.</typeparam>
194-
/// <param name="collectionNamespace">The collection namespace.</param>
195-
/// <param name="query">The query.</param>
196-
/// <param name="fields">The fields.</param>
197-
/// <param name="queryValidator">The query validator.</param>
198-
/// <param name="skip">The number of documents to skip.</param>
199-
/// <param name="batchSize">The size of a batch.</param>
200-
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
201-
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
202-
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
203-
/// <param name="tailableCursor">if set to <c>true</c> the query should return a tailable cursor.</param>
204-
/// <param name="awaitData">if set to <c>true</c> the server should await awhile before returning an empty batch for a tailable cursor.</param>
205-
/// <param name="serializer">The serializer.</param>
206-
/// <param name="messageEncoderSettings">The message encoder settings.</param>
207-
/// <param name="cancellationToken">The cancellation token.</param>
208-
/// <returns>A Task whose result is the result of the Insert protocol.</returns>
20997
Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
21098
CollectionNamespace collectionNamespace,
21199
BsonDocument query,
@@ -222,26 +110,6 @@ Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
222110
MessageEncoderSettings messageEncoderSettings,
223111
CancellationToken cancellationToken);
224112

225-
/// <summary>
226-
/// Executes a Query protocol.
227-
/// </summary>
228-
/// <typeparam name="TDocument">The type of the document.</typeparam>
229-
/// <param name="collectionNamespace">The collection namespace.</param>
230-
/// <param name="query">The query.</param>
231-
/// <param name="fields">The fields.</param>
232-
/// <param name="queryValidator">The query validator.</param>
233-
/// <param name="skip">The number of documents to skip.</param>
234-
/// <param name="batchSize">The size of a batch.</param>
235-
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
236-
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
237-
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
238-
/// <param name="oplogReplay">if set to <c>true</c> the OplogReplay bit will be set.</param>
239-
/// <param name="tailableCursor">if set to <c>true</c> the query should return a tailable cursor.</param>
240-
/// <param name="awaitData">if set to <c>true</c> the server should await awhile before returning an empty batch for a tailable cursor.</param>
241-
/// <param name="serializer">The serializer.</param>
242-
/// <param name="messageEncoderSettings">The message encoder settings.</param>
243-
/// <param name="cancellationToken">The cancellation token.</param>
244-
/// <returns>A Task whose result is the result of the Insert protocol.</returns>
245113
[Obsolete("Use an overload that does not have an oplogReplay parameter instead.")]
246114
Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
247115
CollectionNamespace collectionNamespace,
@@ -261,15 +129,8 @@ Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
261129
CancellationToken cancellationToken);
262130
}
263131

264-
/// <summary>
265-
/// Represents a handle to a channel.
266-
/// </summary>
267-
public interface IChannelHandle : IChannel
132+
internal interface IChannelHandle : IChannel
268133
{
269-
/// <summary>
270-
/// Returns a new handle to the underlying channel.
271-
/// </summary>
272-
/// <returns>A channel handle.</returns>
273134
IChannelHandle Fork();
274135
}
275136
}

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,64 +16,22 @@
1616
using System;
1717
using System.Threading;
1818
using System.Threading.Tasks;
19-
using MongoDB.Driver.Core.Connections;
2019
using MongoDB.Driver.Core.Servers;
2120

2221
namespace MongoDB.Driver.Core.Bindings
2322
{
24-
/// <summary>
25-
/// Represents a channel source.
26-
/// </summary>
2723
internal interface IChannelSource : IDisposable
2824
{
29-
/// <summary>
30-
/// Gets the server.
31-
/// </summary>
32-
/// <value>
33-
/// The server.
34-
/// </value>
3525
IServer Server { get; }
36-
37-
/// <summary>
38-
/// Gets the server description.
39-
/// </summary>
40-
/// <value>
41-
/// The server description.
42-
/// </value>
4326
ServerDescription ServerDescription { get; }
44-
45-
/// <summary>
46-
/// Gets the session.
47-
/// </summary>
48-
/// <value>
49-
/// The session.
50-
/// </value>
5127
ICoreSessionHandle Session { get; }
5228

53-
/// <summary>
54-
/// Gets a channel.
55-
/// </summary>
56-
/// <param name="cancellationToken">The cancellation token.</param>
57-
/// <returns>A channel.</returns>
5829
IChannelHandle GetChannel(CancellationToken cancellationToken);
59-
60-
/// <summary>
61-
/// Gets a channel.
62-
/// </summary>
63-
/// <param name="cancellationToken">The cancellation token.</param>
64-
/// <returns>A Task whose result is a channel.</returns>
6530
Task<IChannelHandle> GetChannelAsync(CancellationToken cancellationToken);
6631
}
6732

68-
/// <summary>
69-
/// Represents a handle to a channel source.
70-
/// </summary>
7133
internal interface IChannelSourceHandle : IChannelSource
7234
{
73-
/// <summary>
74-
/// Returns a new handle to the underlying channel source.
75-
/// </summary>
76-
/// <returns>A handle to a channel source.</returns>
7735
IChannelSourceHandle Fork();
7836
}
7937
}

0 commit comments

Comments
 (0)