Skip to content

Commit

Permalink
Merge pull request #157 from martincostello/issue-154-rename-endpoint…
Browse files Browse the repository at this point in the history
…parser

Rename EndpointParser
  • Loading branch information
martincostello authored Dec 13, 2018
2 parents 2c989e9 + 553ea03 commit 6849649
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
6 changes: 2 additions & 4 deletions src/JustEat.StatsD/EndpointLookups/EndpointParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

namespace JustEat.StatsD.EndpointLookups
{
//// TODO Is this more of a EndPointFactory?

/// <summary>
/// A class containing methods to instances of <see cref="IEndPointSource"/>. This class cannot be inherited.
/// A class containing methods to create instances of <see cref="IEndPointSource"/>. This class cannot be inherited.
/// </summary>
public static class EndpointParser
public static class EndPointFactory
{
/// <summary>
/// Creates an <see cref="IEndPointSource"/> from the specified <see cref="EndPoint"/>.
Expand Down
2 changes: 1 addition & 1 deletion src/JustEat.StatsD/StatsDPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public StatsDPublisher(StatsDConfiguration configuration)
throw new ArgumentException("No hostname or IP address is set.", nameof(configuration));
}

var endpointSource = EndpointParser.MakeEndPointSource(
var endpointSource = EndPointFactory.MakeEndPointSource(
configuration.Host, configuration.Port, configuration.DnsLookupInterval);

var transport = new SocketTransport(endpointSource, configuration.SocketProtocol);
Expand Down
2 changes: 1 addition & 1 deletion src/JustEat.StatsD/StatsDServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private static IEndPointSource ResolveEndPointSource(IServiceProvider provider)
{
var config = provider.GetRequiredService<StatsDConfiguration>();

return EndpointParser.MakeEndPointSource(
return EndPointFactory.MakeEndPointSource(
config.Host,
config.Port,
config.DnsLookupInterval);
Expand Down
2 changes: 1 addition & 1 deletion tests/Benchmark/StatSendingBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Setup()
Prefix = "testmetric"
};

var endpointSource = EndpointParser.MakeEndPointSource(
var endpointSource = EndPointFactory.MakeEndPointSource(
config.Host, config.Port, config.DnsLookupInterval);

var ipTransport = new SocketTransport(endpointSource, SocketProtocol.IP);
Expand Down
2 changes: 1 addition & 1 deletion tests/Benchmark/UdpStatSendingBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Setup()
Prefix = "testmetric"
};

var endpointSource = EndpointParser.MakeEndPointSource(
var endpointSource = EndPointFactory.MakeEndPointSource(
config.Host,
config.Port,
config.DnsLookupInterval);
Expand Down
4 changes: 2 additions & 2 deletions tests/Benchmark/UdpTransportBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public void Setup()
Host = "127.0.0.1",
};

var endpointSource1 = EndpointParser.MakeEndPointSource(
var endpointSource1 = EndPointFactory.MakeEndPointSource(
config.Host,
config.Port,
config.DnsLookupInterval);

var endpointSource2 = EndpointParser.MakeEndPointSource(
var endpointSource2 = EndPointFactory.MakeEndPointSource(
config.Host,
config.Port + 1,
config.DnsLookupInterval);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System;
using System.Net;
using Shouldly;
using Xunit;

namespace JustEat.StatsD.EndpointLookups
{
public static class EndpointParserTests
public static class EndPointFactoryTests
{
[Fact]
public static void CanParseIpValue()
{
var parsed = EndpointParser.MakeEndPointSource("11.12.13.14", 8125, null);
var parsed = EndPointFactory.MakeEndPointSource("11.12.13.14", 8125, null);

parsed.ShouldNotBeNull();

Expand All @@ -21,30 +21,30 @@ public static void CanParseIpValue()
[Fact]
public static void CanParseHostValue()
{
var parsed = EndpointParser.MakeEndPointSource("somehost.somewhere.com", 8125, null);
var parsed = EndPointFactory.MakeEndPointSource("somehost.somewhere.com", 8125, null);
parsed.ShouldNotBeNull();
}

[Fact]
public static void CanParseLocalhostValue()
{
var parsed = EndpointParser.MakeEndPointSource("localhost", 8125, null);
var parsed = EndPointFactory.MakeEndPointSource("localhost", 8125, null);
parsed.ShouldNotBeNull();
parsed.GetEndpoint().ShouldNotBeNull();
}

[Fact]
public static void CanParseCachedLocalhostValue()
{
var parsed = EndpointParser.MakeEndPointSource("localhost", 8125, TimeSpan.FromMinutes(5));
var parsed = EndPointFactory.MakeEndPointSource("localhost", 8125, TimeSpan.FromMinutes(5));
parsed.ShouldNotBeNull();
parsed.GetEndpoint().ShouldNotBeNull();
}

[Fact]
public static void CanParseHostValueWithCache()
{
var parsed = EndpointParser.MakeEndPointSource("somehost.somewhere.com", 8125, TimeSpan.FromMinutes(5));
var parsed = EndPointFactory.MakeEndPointSource("somehost.somewhere.com", 8125, TimeSpan.FromMinutes(5));
parsed.ShouldNotBeNull();
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/JustEat.StatsD.Tests/WhenUsingUdpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public WhenUsingUdpTransport(UdpListeners _)
public void AMetricCanBeSentWithoutAnExceptionBeingThrown()
{
// Arrange
var endPointSource = EndpointParser.MakeEndPointSource(
var endPointSource = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointA,
null);

Expand All @@ -35,7 +35,7 @@ public void AMetricCanBeSentWithoutAnExceptionBeingThrown()
public void MultipleMetricsCanBeSentWithoutAnExceptionBeingThrownSerial()
{
// Arrange
var endPointSource = EndpointParser.MakeEndPointSource(
var endPointSource = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointA,
null);

Expand All @@ -53,7 +53,7 @@ public void MultipleMetricsCanBeSentWithoutAnExceptionBeingThrownSerial()
public void MultipleMetricsCanBeSentWithoutAnExceptionBeingThrownParallel()
{
// Arrange
var endPointSource = EndpointParser.MakeEndPointSource(
var endPointSource = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointA,
null);

Expand All @@ -71,11 +71,11 @@ public void MultipleMetricsCanBeSentWithoutAnExceptionBeingThrownParallel()
public static void EndpointSwitchShouldNotCauseExceptionsSequential()
{
// Arrange
var endPointSource1 = EndpointParser.MakeEndPointSource(
var endPointSource1 = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointA,
null);

var endPointSource2 = EndpointParser.MakeEndPointSource(
var endPointSource2 = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointB,
null);

Expand All @@ -93,11 +93,11 @@ public static void EndpointSwitchShouldNotCauseExceptionsSequential()
public static void EndpointSwitchShouldNotCauseExceptionsParallel()
{
// Arrange
var endPointSource1 = EndpointParser.MakeEndPointSource(
var endPointSource1 = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointA,
null);

var endPointSource2 = EndpointParser.MakeEndPointSource(
var endPointSource2 = EndPointFactory.MakeEndPointSource(
UdpListeners.EndpointB,
null);

Expand Down

0 comments on commit 6849649

Please sign in to comment.