-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make loggers to not block ActorSystem creation #4424
Merged
Aaronontheweb
merged 22 commits into
akkadotnet:dev
from
IgorFedchenko:4054-load-loggers-async
May 26, 2020
Merged
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bbe90a4
enable loggers to start asynchronously
Aaronontheweb 86d4a44
Refactored and optimized loggers addition
IgorFedchenko 8ea1601
Using Task.Run to start background task with thread context capture
IgorFedchenko 2267c83
Rollback from async Ask to blocking Result after Task.Run
IgorFedchenko dafff6a
Moved async loggers to settings, disabled by default
IgorFedchenko 0e0a181
Use async API when possible inside logger creation task
IgorFedchenko 0755636
Renamed new logger setting to LoggerAsyncStart
IgorFedchenko 7560048
Removed async/await use in logger creation
IgorFedchenko dcb3874
Return old Ask implementation
IgorFedchenko b305b4e
Enabled async loggers start by default
IgorFedchenko 271826b
Added API approvement
IgorFedchenko 6722974
Added new setting spec (passing)
IgorFedchenko bd3c560
Fixed LoggerSpec
IgorFedchenko 1e3f00e
Included akka.logger-async-start into reference akka.net configuration
IgorFedchenko 2c12a89
Fixed/disabled racy specs
IgorFedchenko 65bec08
Enabled setting by default
IgorFedchenko 5035f15
Disabled setting by default
IgorFedchenko 36e5cbe
Merge branch 'dev' into 4054-load-loggers-async
IgorFedchenko 390cc1f
Merge branch 'dev' into 4054-load-loggers-async
IgorFedchenko 29d4b8b
Merge branch 'dev' into 4054-load-loggers-async
IgorFedchenko 2b683ac
Disabled racy/hanging specs
IgorFedchenko b808798
Merge branch 'dev' into 4054-load-loggers-async
IgorFedchenko File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// //----------------------------------------------------------------------- | ||
// // <copyright file="LoggerStartupSpec.cs" company="Akka.NET Project"> | ||
// // Copyright (C) 2009-2020 Lightbend Inc. <http://www.lightbend.com> | ||
// // Copyright (C) 2013-2020 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// // </copyright> | ||
// //----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Event; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Akka.Tests.Loggers | ||
{ | ||
public class LoggerStartupSpec : TestKit.Xunit2.TestKit | ||
{ | ||
private const int LoggerResponseDelayMs = 10_000; | ||
|
||
[Fact] | ||
public async Task Logger_async_start_configuration_helps_to_ignore_hanging_loggers() | ||
{ | ||
var loggerAsyncStartDisabledConfig = ConfigurationFactory.ParseString($"akka.logger-async-start = false"); | ||
var loggerAsyncStartEnabledConfig = ConfigurationFactory.ParseString($"akka.logger-async-start = true"); | ||
|
||
var slowLoggerConfig = ConfigurationFactory.ParseString($"akka.loggers = [\"{typeof(SlowLoggerActor).FullName}, {typeof(SlowLoggerActor).Assembly.GetName().Name}\"]"); | ||
|
||
// Without logger async start, ActorSystem creation will hang | ||
this.Invoking(_ => ActorSystem.Create("handing", slowLoggerConfig.WithFallback(loggerAsyncStartDisabledConfig))) | ||
.ShouldThrow<Exception>("System can not start - logger timed out"); | ||
|
||
// With logger async start, ActorSystem is created without issues | ||
// Created without timeouts | ||
var system = ActorSystem.Create("working", slowLoggerConfig.WithFallback(loggerAsyncStartEnabledConfig)); | ||
} | ||
|
||
public class SlowLoggerActor : ReceiveActor | ||
{ | ||
public SlowLoggerActor() | ||
{ | ||
ReceiveAsync<InitializeLogger>(async _ => | ||
{ | ||
// Ooops... Logger is responding too slow | ||
await Task.Delay(LoggerResponseDelayMs); | ||
Sender.Tell(new LoggerInitialized()); | ||
}); | ||
} | ||
|
||
private void Log(LogLevel level, string str) | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try running it with this setting enabled to true everywhere? Looks like the test suite is running without it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - want to check if test suite will work well. Because it seems to me that it is blocking even without async version.
And before introducing this setting, the code was using "async" implementation by default (so I added this setting to be able to disable new behavior) - and test suite kind of stopped.
Probably I need to wait longer. Just checking out CI output and it does not change for some time