From 293e5a9ddf7e183c45961430aaaa4699e63fbbf9 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Fri, 12 Aug 2022 07:28:46 +0700 Subject: [PATCH] Update RELEASE_NOTES.md for v0.4.2 release (#93) --- RELEASE_NOTES.md | 98 ++++------------------- src/Akka.Hosting/AkkaHostingExtensions.cs | 27 ------- 2 files changed, 17 insertions(+), 108 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3a51725e..7b98cd59 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,91 +1,27 @@ -## [0.4.1] / 21 July 2022 -- [Fix `Microsoft.Extensions.Logging.ILoggerFactory` logging support](https://github.com/akkadotnet/Akka.Hosting/pull/81) -- [Add `InMemory` snapshot store and journal persistence support](https://github.com/akkadotnet/Akka.Hosting/pull/84) +## [0.4.2] / 11 August 2022 +- [Update Akka.NET from 1.4.39 to 1.4.40](https://github.com/akkadotnet/akka.net/releases/tag/1.4.40) +- [Add `WithExtensions()` method](https://github.com/akkadotnet/Akka.Hosting/pull/92) +- [Add `AddStartup` method](https://github.com/akkadotnet/Akka.Hosting/pull/90) -Due to a bad API design, we're rolling back the `Microsoft.Extensions.Logging.ILoggerFactory` logger support introduced in version 0.4.0, the 0.4.0 NuGet version is now considered as deprecated in support of the new API design introduced in version 0.4.1. +__WithExtensions()__ -__Logger Configuration Support__ - -You can now use the new `AkkaConfigurationBuilder` extension method called `ConfigureLoggers(Action)` to configure how Akka.NET logger behave. +`AkkaConfigurationBuilder.WithExtensions()` is used to configure the `akka.extensions` HOCON settings. It is used to set an Akka.NET extension provider to start-up automatically during `ActorSystem` start-up. Example: ```csharp -builder.Services.AddAkka("MyActorSystem", configurationBuilder => -{ - configurationBuilder - .ConfigureLoggers(setup => - { - // Example: This sets the minimum log level - setup.LogLevel = LogLevel.DebugLevel; - - // Example: Clear all loggers - setup.ClearLoggers(); - - // Example: Add the default logger - // NOTE: You can also use setup.AddLogger(); - setup.AddDefaultLogger(); - - // Example: Add the ILoggerFactory logger - // NOTE: - // - You can also use setup.AddLogger(); - // - To use a specific ILoggerFactory instance, you can use setup.AddLoggerFactory(myILoggerFactory); - setup.AddLoggerFactory(); - - // Example: Adding a serilog logger - setup.AddLogger(); - }) - .WithActors((system, registry) => - { - var echo = system.ActorOf(act => - { - act.ReceiveAny((o, context) => - { - Logging.GetLogger(context.System, "echo").Info($"Actor received {o}"); - context.Sender.Tell($"{context.Self} rcv {o}"); - }); - }, "echo"); - registry.TryRegister(echo); // register for DI - }); -}); +// Starts distributed pub-sub, cluster metrics, and cluster bootstrap extensions at start-up +builder.WithExtensions( + typeof(DistributedPubSubExtensionProvider), + typeof(ClusterMetricsExtensionProvider), + typeof(ClusterBootstrapProvider)); ``` -A complete code sample can be viewed [here](https://github.com/akkadotnet/Akka.Hosting/tree/dev/src/Examples/Akka.Hosting.LoggingDemo). - -Exposed properties are: -- `LogLevel`: Configure the Akka.NET minimum log level filter, defaults to `InfoLevel` -- `LogConfigOnStart`: When set to true, Akka.NET will log the complete HOCON settings it is using at start up, this can then be used for debugging purposes. - -Currently supported logger methods: -- `ClearLoggers()`: Clear all registered logger types. -- `AddLogger()`: Add a logger type by providing its class type. -- `AddDefaultLogger()`: Add the default Akka.NET console logger. -- `AddLoggerFactory()`: Add the new `ILoggerFactory` logger. - -__Microsoft.Extensions.Logging.ILoggerFactory Logging Support__ - -You can now use `ILoggerFactory` from Microsoft.Extensions.Logging as one of the sinks for Akka.NET logger. This logger will use the `ILoggerFactory` service set up inside the dependency injection `ServiceProvider` as its sink. +__AddStartup()__ -__Microsoft.Extensions.Logging Log Event Filtering__ - -There will be two log event filters acting on the final log input, the Akka.NET `akka.loglevel` setting and the `Microsoft.Extensions.Logging` settings, make sure that both are set correctly or some log messages will be missing. - -To set up the `Microsoft.Extensions.Logging` log filtering, you will need to edit the `appsettings.json` file. Note that we also set the `Akka` namespace to be filtered at debug level in the example below. - -```json -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information", - "Akka": "Debug" - } - } -} -``` +`AddStartup()` method adds `StartupTask` delegate to the configuration builder. -__InMemory Snapshot Store And Journal Support__ +This feature is useful when a user need to run a specific initialization code if anf only if the `ActorSystem` and all of the actors have been started. Although it is semantically the same as `AddActors` and `WithActors`, it disambiguate the use-case with a guarantee that it will only be executed after everything is ready. -You can now use these `AkkaConfigurationBuilder` extension methods to enable `InMemory` persistence back end: -- `WithInMemoryJournal()`: Sets the `InMemory` journal as the default journal persistence plugin -- `WithInMemorySnapshotStore()`: Sets the `InMemory` snapshot store as the default snapshot-store persistence plugin. \ No newline at end of file +For example, this feature is useful for: +- kicking off actor initializations by using Tell()s once all of the actor infrastructure are in place, or +- pre-populating certain persistence or database data after everything is set up and running, useful for unit testing or adding fake data for local development. \ No newline at end of file diff --git a/src/Akka.Hosting/AkkaHostingExtensions.cs b/src/Akka.Hosting/AkkaHostingExtensions.cs index 148c4907..4cc15140 100644 --- a/src/Akka.Hosting/AkkaHostingExtensions.cs +++ b/src/Akka.Hosting/AkkaHostingExtensions.cs @@ -145,32 +145,5 @@ public static AkkaConfigurationBuilder WithActors(this AkkaConfigurationBuilder { return builder.StartActors(actorStarter); } - - /// - /// Adds a list of Akka.NET extensions that will be started automatically when the - /// starts up. - /// - /// - /// - /// // Starts distributed pub-sub, cluster metrics, and cluster bootstrap extensions at start-up - /// builder.WithExtensions( - /// typeof(DistributedPubSubExtensionProvider), - /// typeof(ClusterMetricsExtensionProvider), - /// typeof(ClusterBootstrapProvider)); - /// - /// - /// The builder instance being configured. - /// A list of extension providers that will be automatically started - /// when the starts - /// The same instance originally passed in. - public static AkkaConfigurationBuilder WithExtensions( - this AkkaConfigurationBuilder builder, - params Type[] extensions) - { - builder.AddHocon( - $"akka.extensions=[{string.Join(", ", extensions.Select(s => $"\"{s.AssemblyQualifiedName}\""))}]", - HoconAddMode.Prepend); - return builder; - } } }