Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename EndpointParser #157

Merged
merged 1 commit into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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