Skip to content

Commit

Permalink
move DateTime / TimeSpan extension APIs out of Akka.Util and into…
Browse files Browse the repository at this point in the history
… Akka.Cluster.Metrics (#6427)

* remove `DateTimeExtensions`

* deleted metrics collector mock.

* moved `TimeSpanExtensions` into Akka.Cluster.Metrics.Tests

* API approvals

* Revert "deleted metrics collector mock."

This reverts commit 08c022e.

* added mock back

* missed API approval
  • Loading branch information
Aaronontheweb committed Feb 22, 2023
1 parent e5d8c30 commit 0e0bd83
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 33 deletions.
Expand Up @@ -5,6 +5,7 @@
<PropertyGroup>
<AssemblyTitle>Akka.Cluster.Metrics.Tests</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetTestVersion);$(NetCoreTestVersion)</TargetFrameworks>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Expand Up @@ -94,7 +94,7 @@ public async Task Metrics_extension_Should_control_collector_on_off_state()

private Task AwaitSampleAsync(double? timeMs = null)
{
timeMs = timeMs ?? _sampleInterval.TotalMilliseconds * 5;
timeMs ??= _sampleInterval.TotalMilliseconds * 5;

return Task.Delay(TimeSpan.FromMilliseconds(timeMs.Value));
}
Expand Down
Expand Up @@ -30,7 +30,7 @@ public MetricsCollectorMock(ActorSystem system)
/// <inheritdoc />
public NodeMetrics Sample()
{
return new NodeMetrics(new Address("akka", _system.Name), DateTime.UtcNow.ToTimestamp().Seconds, new []
return new NodeMetrics(new Address("akka", _system.Name), DateTime.UtcNow.ToTimestamp(), new []
{
new NodeMetrics.Types.Metric("metric1", _random.Next(0, 100), new NodeMetrics.Types.EWMA(5, 0.5)),
new NodeMetrics.Types.Metric("metric2", _random.Next(0, 100), new NodeMetrics.Types.EWMA(5, 0.2)),
Expand Down
Expand Up @@ -9,7 +9,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using Akka.Cluster.Metrics.Serialization;
using Akka.Util.Extensions;
using FluentAssertions;
using Xunit;
using Address = Akka.Actor.Address;
Expand Down
Expand Up @@ -7,7 +7,7 @@

using System;

namespace Akka.Util.Extensions
namespace Akka.Cluster.Metrics.Tests
{
/// <summary>
/// TimeSpanExtensions
Expand Down
Expand Up @@ -7,12 +7,12 @@

using System;

namespace Akka.Util.Extensions
namespace Akka.Cluster.Metrics
{
/// <summary>
/// DateTimeExtensions
/// </summary>
public static class DateTimeExtensions
internal static class DateTimeExtensions
{
private static readonly DateTime UnixOffset = new DateTime(1970, 1, 1);

Expand Down
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Akka.Cluster.Metrics.Tests")]
@@ -1,4 +1,5 @@
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/akkadotnet/akka.net")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Cluster.Metrics.Tests")]
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")]
namespace Akka.Cluster.Metrics
{
Expand Down
@@ -1,4 +1,5 @@
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/akkadotnet/akka.net")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Cluster.Metrics.Tests")]
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName=".NET 6.0")]
namespace Akka.Cluster.Metrics
{
Expand Down
@@ -1,4 +1,5 @@
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/akkadotnet/akka.net")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Cluster.Metrics.Tests")]
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")]
namespace Akka.Cluster.Metrics
{
Expand Down
Expand Up @@ -5245,19 +5245,10 @@ namespace Akka.Util
}
namespace Akka.Util.Extensions
{
public class static DateTimeExtensions
{
public static long ToTimestamp(this System.DateTime dateTime) { }
}
public class static ObjectExtensions
{
public static Akka.Util.Option<T> AsOption<T>(this T obj) { }
}
public class static TimeSpanExtensions
{
public static System.TimeSpan Multiply(this System.TimeSpan multiplicand, int multiplier) { }
public static System.TimeSpan Multiply(this System.TimeSpan multiplicand, double multiplier) { }
}
}
namespace Akka.Util.Internal
{
Expand Down
Expand Up @@ -5253,19 +5253,10 @@ namespace Akka.Util
}
namespace Akka.Util.Extensions
{
public class static DateTimeExtensions
{
public static long ToTimestamp(this System.DateTime dateTime) { }
}
public class static ObjectExtensions
{
public static Akka.Util.Option<T> AsOption<T>(this T obj) { }
}
public class static TimeSpanExtensions
{
public static System.TimeSpan Multiply(this System.TimeSpan multiplicand, int multiplier) { }
public static System.TimeSpan Multiply(this System.TimeSpan multiplicand, double multiplier) { }
}
}
namespace Akka.Util.Internal
{
Expand Down
Expand Up @@ -5245,19 +5245,10 @@ namespace Akka.Util
}
namespace Akka.Util.Extensions
{
public class static DateTimeExtensions
{
public static long ToTimestamp(this System.DateTime dateTime) { }
}
public class static ObjectExtensions
{
public static Akka.Util.Option<T> AsOption<T>(this T obj) { }
}
public class static TimeSpanExtensions
{
public static System.TimeSpan Multiply(this System.TimeSpan multiplicand, int multiplier) { }
public static System.TimeSpan Multiply(this System.TimeSpan multiplicand, double multiplier) { }
}
}
namespace Akka.Util.Internal
{
Expand Down

0 comments on commit 0e0bd83

Please sign in to comment.