Skip to content

Commit 5194a65

Browse files
authored
Refactor, rename and seal various types (#44)
1 parent ed29193 commit 5194a65

27 files changed

+93
-217
lines changed

src/Elastic.Transport/Components/NodePool/Node.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Elastic.Transport
1212
/// <summary>
1313
/// Represents an endpoint <see cref="Uri"/> with additional associated metadata on which the <see cref="ITransport{TConnectionSettings}"/> can act.
1414
/// </summary>
15-
public class Node : IEquatable<Node>
15+
public sealed class Node : IEquatable<Node>
1616
{
1717
private IReadOnlyCollection<string> _features;
1818

@@ -34,6 +34,7 @@ public Node(Uri uri, IEnumerable<string> features = null)
3434
}
3535

3636
private HashSet<string> _featureSet;
37+
3738
/// <summary>
3839
/// A readonly collection backed by an <see cref="HashSet{T}"/> that signals what features are enabled on the node.
3940
/// <para> This is loosely typed as to be agnostic to what solution the transport ends up talking to </para>

src/Elastic.Transport/Components/NodePool/StickyNodePool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Elastic.Transport
1313
/// A connection pool implementation that does not support reseeding and stays on the first <see cref="Node"/> reporting true for <see cref="Node.IsAlive"/>.
1414
/// This is great if for instance you have multiple proxies that you can fallback on allowing you to seed the proxies in order of preference.
1515
/// </summary>
16-
public class StickyNodePool : StaticNodePool
16+
public sealed class StickyNodePool : StaticNodePool
1717
{
1818
/// <inheritdoc cref="StickyNodePool"/>
1919
public StickyNodePool(IEnumerable<Uri> uris, IDateTimeProvider dateTimeProvider = null)

src/Elastic.Transport/Components/NodePool/StickySniffingNodePool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Elastic.Transport
1414
/// A connection pool implementation that supports reseeding but stays on the first <see cref="Node"/> reporting true for <see cref="Node.IsAlive"/>.
1515
/// This is great if for instance you have multiple proxies that you can fallback on allowing you to seed the proxies in order of preference.
1616
/// </summary>
17-
public class StickySniffingNodePool : SniffingNodePool
17+
public sealed class StickySniffingNodePool : SniffingNodePool
1818
{
1919
/// <inheritdoc cref="StickySniffingNodePool"/>
2020
public StickySniffingNodePool(IEnumerable<Uri> uris, Func<Node, float> nodeScorer, IDateTimeProvider dateTimeProvider = null)

src/Elastic.Transport/Components/Pipeline/IRequestPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace Elastic.Transport
1212
{
1313
/// <summary> Models the workflow of a request to multiple nodes</summary>
14-
public interface IRequestPipeline : IDisposable
14+
public interface IRequestPipeline : IDisposable // TODO - Should we move IDisposable to the implementation / Make this an abstract base type instead?
1515
{
1616
//TODO should not be List but requires a refactor
1717
/// <summary>

src/Elastic.Transport/Components/Pipeline/RequestData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Elastic.Transport
1919
/// and <see cref="IRequestConfiguration" />.
2020
/// </para>
2121
/// </summary>
22-
public class RequestData
22+
public sealed class RequestData
2323
{
2424
//TODO add xmldocs and clean up this class
2525
#pragma warning disable 1591

src/Elastic.Transport/Components/Providers/MemoryStreamFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Elastic.Transport
99
/// <summary>
1010
/// A factory for creating memory streams using instances of <see cref="MemoryStream" />
1111
/// </summary>
12-
public class MemoryStreamFactory : IMemoryStreamFactory
12+
public sealed class MemoryStreamFactory : IMemoryStreamFactory
1313
{
1414
/// <summary> Provide a static instance of this stateless class, so it can be reused</summary>
1515
public static MemoryStreamFactory Default { get; } = new MemoryStreamFactory();

src/Elastic.Transport/Components/Providers/RecyclableMemoryStream.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,12 @@ protected override void Dispose(bool disposing)
315315
/// Equivalent to Dispose
316316
/// </summary>
317317
#if NETSTANDARD1_4
318-
public void Close()
318+
public void Close() => Dispose(true);
319319
#else
320-
public override void Close()
320+
public override void Close() => Dispose(true);
321321
#endif
322-
{
323-
Dispose(true);
324-
}
325322

326-
#endregion
323+
#endregion
327324

328325
#region MemoryStream overrides
329326

src/Elastic.Transport/Components/Providers/RecyclableMemoryStreamFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Elastic.Transport
1010
/// <summary>
1111
/// A factory for creating memory streams using a recyclable pool of <see cref="MemoryStream" /> instances
1212
/// </summary>
13-
public class RecyclableMemoryStreamFactory : IMemoryStreamFactory
13+
public sealed class RecyclableMemoryStreamFactory : IMemoryStreamFactory
1414
{
1515
private const string TagSource = "Elastic.Transport";
1616
private readonly RecyclableMemoryStreamManager _manager;

src/Elastic.Transport/Components/Providers/RecyclableMemoryStreamManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ public long LargePoolInUseSize
292292
/// <returns>A byte[] array</returns>
293293
internal byte[] GetBlock()
294294
{
295-
byte[] block;
296-
if (!_smallPool.TryPop(out block))
295+
if (!_smallPool.TryPop(out var block))
297296
{
298297
// We'll add this back to the pool when the stream is disposed
299298
// (unless our free pool is too large)

src/Elastic.Transport/Components/Serialization/SerializerRegistrationInformation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Elastic.Transport
88
{
99
/// <summary> Provides some information to the transport auditing and diagnostics infrastructure about the serializer in use and its <see cref="Purpose"/> </summary>
10-
public class SerializerRegistrationInformation
10+
public sealed class SerializerRegistrationInformation
1111
{
1212
private readonly string _stringRepresentation;
1313

0 commit comments

Comments
 (0)