Skip to content

make AkkaHostedService public + virtual #306

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

Merged

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented May 17, 2023

Fixes #298

Changes

Re-implementation of #299 - no abstract base classes, just made the main one public + virtual in order to keep things simple for Akka.Hosting.Maui et

Made clear in XML-DOC comment, this is a "there be dragons" use case for end-users. We're not going to provide you with much support beyond making this possible. Best of luck.

Checklist

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

Re-implementation of akkadotnet#299

Made clear in XML-DOC comment, this is a "there be dragons" use case for end-users. We're not going to provide you with much support beyond making this possible. Best of luck.
private readonly AkkaConfigurationBuilder _configurationBuilder;
private readonly IHostApplicationLifetime? _hostApplicationLifetime;
private readonly ILogger<AkkaHostedService> _logger;
protected ActorSystem? ActorSystem;
Copy link
Member Author

Choose a reason for hiding this comment

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

Made all of these accessible in derivative classes.

@@ -11,36 +12,42 @@ namespace Akka.Hosting
/// <summary>
/// INTERNAL API
/// </summary>
internal sealed class AkkaHostedService : IHostedService
/// <remarks>
/// Open for modification in cases where users need fine-grained control over <see cref="Actor.ActorSystem"/> startup and
Copy link
Member Author

Choose a reason for hiding this comment

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

Warning to users: there will be tears if you don't study our source code when you try to extend this, and we will not help you with whatever weird DI stuff you're trying to do. Best of luck.

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, small nitpick.

@@ -77,6 +77,34 @@ public static IServiceCollection AddAkka(this IServiceCollection services, strin

return services;
}

public static IServiceCollection AddAkka<T>(this IServiceCollection services, string actorSystemName, Action<AkkaConfigurationBuilder, IServiceProvider> builder) where T:AkkaHostedService
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the generic code is identical to the non-generic one, we should just call the generic one from inside the non-generic extension method. Saves us the time to have to check that both implementation are the same in the future.

@Aaronontheweb Aaronontheweb requested a review from Arkatufus May 17, 2023 18:30
@Aaronontheweb Aaronontheweb merged commit 3dcde9d into akkadotnet:dev May 17, 2023
@Aaronontheweb Aaronontheweb deleted the akkahosting-service-public branch May 17, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finer grain control over ActorSystem startup
2 participants