-
Notifications
You must be signed in to change notification settings - Fork 191
Add close on ActorSystem #2486
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
Add close on ActorSystem #2486
Conversation
c370223 to
075b049
Compare
075b049 to
8188c2d
Compare
Is there a requirement for close to block until the closing is 'complete'?
I can see the appeal, though blocking is a bit 'uncharacteristic' for us. I guess because you're stopping the ActorSystem and thus are anyway 'on your way out' it might be fine? |
I believe so otherwise you can get weird behaviour but I will do research to confirm. From what I gather (and also when learning Kotlin and using stuff like Arrow Resource),
To clarify, if I replace |
8188c2d to
c873612
Compare
Why? When I want to make sure the cleanup is triggered but don't care too much when it happens, it might be fine?
It's an interesting data point that the
Sure, I meant blocking in the 'production' code is a bit uncharacteristic - in tests it's indeed definitely fine. |
From what I recall, if there is an error in cleaning up on I would say personally that having |
c873612 to
103cb63
Compare
|
So regarding blocking on
And more directly from https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html
Implies that it is expected that if the Personally I was also apprehensive of implementing |
|
Would it be acceptable to not put this on ActorSystem but create a factory method like We could also support mixing in a non-blocking close. |
Well I would still have to put it on I think the point is, if you are going to use This really does seem to be one of those cases where either we implement |
A config option to decide on whether the close is blocking alongside a config to control the timeout for blocking seems ok. |
Cool, Ill see feedback from others as well |
b4685cb to
306bc9c
Compare
|
Once get merged, this should be ported to 2.0.0 btw, @mdedetrich what's the status of kotlin dsl of Pekko? |
| override lazy val getWhenTerminated: CompletionStage[pekko.Done] = | ||
| whenTerminated.asJava | ||
|
|
||
| override def close(): Unit = system.close() |
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.
add @since 1.3.0
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.
Same as #2486 (comment), this is not part of public API
| # Terminate the ActorSystem in the last phase actor-system-terminate. | ||
| terminate-actor-system = on | ||
|
|
||
| # The timeout that will be used when calling .close on an ActorSystem |
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.
add since 1.3.0
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.
Do we have an example of what this is meant to look like?
I have some good news on this front, there is an official sbt kotlin plugin by jetbrains so it should be largely trivial https://github.com/JetBrains/sbt-kotlin-plugin The thing is that its blocked by #2093 as kotlion also has its own way of handling async IO (it has suspend functions) |
|
I will wait a few days to see if @raboof responds and also his views on making the blocking nature configurable |
...kit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/ActorSystemStub.scala
Show resolved
Hide resolved
306bc9c to
eca63a0
Compare
|
I have just updated the PR to actually add tests to make sure the One note is that when I cherry pick this into Pekko 1.3.x, the |
55746f1 to
46dd388
Compare
46dd388 to
7df9fb8
Compare
pjfanning
left a comment
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.
lgtm
|
@mdedetrich feel free to merge this and send a backport to 1.3.x |
|
I will do the backporting |
Please let me do it as I have to modify a test |
|
@mdedetrich Nice you are online, hands over~ |
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
(cherry picked from commit d5ee8a6)
Adds the
closemethod onActorSystem(classic and typed) as well as implementing theAutoCloseableinterface, work taken from #2479. Regardless of what happens with #2093, the changes in this PR are always valid (closeis blocking and returnsUnit/Voidso its valid for bothjavadslandscaladsl).The PR also cleans up test code by removing the
Await.result(system.close,...)pattern that is used everywhere.An overloaded
close(duration: Duration)method can be added in Pekko 2.0.0 if #2479 works out, as thescaladslwill use the ScalaDurationand thejavadslwill use the JavaDuration.