Skip to content

Commit 4871202

Browse files
committed
showcase index type overrides and add additional url test for it on .Get() for #1714
1 parent 4b1e942 commit 4871202

File tree

10 files changed

+171
-133
lines changed

10 files changed

+171
-133
lines changed

src/Elasticsearch.Net/Auditing/Audit.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ public class Audit
1111
public string Path { get; internal set; }
1212
public Exception Exception { get; internal set; }
1313

14-
public Audit(AuditEvent type, DateTime occured)
14+
public Audit(AuditEvent type, DateTime started)
1515
{
1616
this.Event = type;
17-
this.Started = occured;
17+
this.Started = started;
1818
}
1919

2020
public override string ToString()
2121
{
2222
var took = Started - Ended;
23-
return $"Node: {Node?.Uri}, Event: {Event.GetStringValue()} NodeAlive: {Node?.IsAlive}, Took: {took.ToString()}";
23+
return $"Node: {Node?.Uri}, Event: {Event.GetStringValue()} NodeAlive: {Node?.IsAlive}, Took: {took}";
2424
}
2525
}
2626
}

src/Elasticsearch.Net/Configuration/ConnectionConfiguration.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace Elasticsearch.Net
1010
/// </summary>
1111
public class ConnectionConfiguration : ConnectionConfiguration<ConnectionConfiguration>
1212
{
13-
public static TimeSpan DefaultTimeout = TimeSpan.FromMinutes(1);
14-
public static TimeSpan DefaultPingTimeout = TimeSpan.FromSeconds(2);
15-
public static TimeSpan DefaultPingTimeoutOnSSL = TimeSpan.FromSeconds(5);
13+
public static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes(1);
14+
public static readonly TimeSpan DefaultPingTimeout = TimeSpan.FromSeconds(2);
15+
public static readonly TimeSpan DefaultPingTimeoutOnSSL = TimeSpan.FromSeconds(5);
1616

1717
/// <summary>
1818
/// ConnectionConfiguration allows you to control how ElasticsearchClient behaves and where/how it connects
@@ -47,6 +47,10 @@ public ConnectionConfiguration(IConnectionPool connectionPool, Func<ConnectionCo
4747
public ConnectionConfiguration(IConnectionPool connectionPool, IConnection connection, Func<ConnectionConfiguration, IElasticsearchSerializer> serializerFactory)
4848
: base(connectionPool, connection, serializerFactory)
4949
{ }
50+
51+
public void Dispose()
52+
{
53+
}
5054
}
5155

5256
[Browsable(false)]
@@ -308,6 +312,11 @@ public T BasicAuthentication(string userName, string password)
308312
/// <para>Note: HTTP pipelining must also be enabled in Elasticsearch for this to work properly.</para>
309313
/// </summary>
310314
public T EnableHttpPipelining(bool enabled = true) => Assign(a => a._enableHttpPipelining = enabled);
315+
316+
public void Dispose()
317+
{
318+
this._connectionPool?.Dispose();
319+
}
311320
}
312321
}
313322

src/Elasticsearch.Net/Configuration/IConnectionConfigurationValues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Elasticsearch.Net
55
{
6-
public interface IConnectionConfigurationValues
6+
public interface IConnectionConfigurationValues : IDisposable
77
{
88
/// <summary> The connection pool to use when talking with elasticsearch </summary>
99
IConnectionPool ConnectionPool { get; }

src/Elasticsearch.Net/ConnectionPool/IConnectionPool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Elasticsearch.Net
55
{
6-
public interface IConnectionPool
6+
public interface IConnectionPool : IDisposable
77
{
88
/// <summary>
99
/// Returns a readonly constant view of all the nodes in the cluster, this might involve creating copies of the nodes e.g

src/Elasticsearch.Net/ConnectionPool/SingleNodeConnectionPool.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ public SingleNodeConnectionPool(Uri uri, IDateTimeProvider dateTimeProvider = nu
2929
}
3030

3131
public IEnumerable<Node> CreateView(Action<AuditEvent, Node> audit = null) => this.Nodes;
32+
33+
public void Dispose()
34+
{
35+
}
3236
}
3337
}

src/Elasticsearch.Net/ConnectionPool/SniffingConnectionPool.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,10 @@ public override IEnumerable<Node> CreateView(Action<AuditEvent, Node> audit = nu
7373
}
7474
}
7575

76+
public override void Dispose()
77+
{
78+
this._readerWriter?.Dispose();
79+
base.Dispose();
80+
}
7681
}
7782
}

src/Elasticsearch.Net/ConnectionPool/StaticConnectionPool.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,8 @@ public virtual IEnumerable<Node> CreateView(Action<AuditEvent, Node> audit = nul
9797
}
9898
}
9999

100+
public virtual void Dispose()
101+
{
102+
}
100103
}
101104
}

src/Elasticsearch.Net/Elasticsearch.Net.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<WarningLevel>4</WarningLevel>
2424
<UseVSHostingProcess>false</UseVSHostingProcess>
2525
<Prefer32Bit>false</Prefer32Bit>
26+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
2627
</PropertyGroup>
2728
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2829
<DebugType>pdbonly</DebugType>
@@ -54,6 +55,7 @@
5455
<ItemGroup>
5556
<Compile Include="Configuration\RequestConfiguration.cs" />
5657
<Compile Include="Exceptions\UnexpectedElasticsearchClientException.cs" />
58+
<Compile Include="GlobalSuppressions.cs" />
5759
<Compile Include="Transport\Pipeline\PipelineException.cs" />
5860
<Compile Include="Connection\HttpMethod.cs" />
5961
<Compile Include="Auditing\Audit.cs" />

0 commit comments

Comments
 (0)