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

Akka.Actor: make ITimeProvider injectable into consuming classes #7314

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Aug 6, 2024

Changes

Removes dependencies on the static DateTimeNowTimeProvider and instead has everything use the IScheduler instead, which provides the exact same functionality with identical implementations. This makes it possible to inject the ITimeProvider using the ActorSystem's configuration instead.

This should enable us to be able to support .NET 8's TimeProvider more easily in the future for testing purposes.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

All of this functionality was duplicated on the `IScheduler` anyway - so removing this makes it possible to actually inject the `ITimeProvider` into downstream dependencies using the `ActorSystem`
Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed my changes

/// <summary>
/// TBD
/// </summary>

public static DateTimeOffsetNowTimeProvider Instance { get; } = new();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, I removed all references to this type (all of which were contained inside Akka.Delivery and Akka.Cluster.Sharding.Delivery) and preferred to use the IScheduler's implementation of these same methods instead, which are identical on the HashedWheelTimer base class.

@@ -589,6 +589,7 @@ namespace Akka.Actor
public CoordinatedShutdownExtension() { }
public override Akka.Actor.CoordinatedShutdown CreateExtension(Akka.Actor.ExtendedActorSystem system) { }
}
[System.ObsoleteAttribute("This class will be removed in Akka.NET v1.6.0 - use the IScheduler instead.")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked the DateTimeNowTimeProvider as Obsolete and slated for removal in v1.6.

@Aaronontheweb Aaronontheweb marked this pull request as ready for review August 6, 2024 17:08
Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb Aaronontheweb merged commit da3ded3 into akkadotnet:dev Aug 7, 2024
10 of 12 checks passed
@Aaronontheweb Aaronontheweb deleted the ITimeProvider-injection branch August 7, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants