Thespian icon indicating copy to clipboard operation
Thespian copied to clipboard

Actor's parent address

Open Scony opened this issue 7 years ago • 4 comments

I did some research (docs + google + lib reverse engineering) but I can’t find an answer for my question: is there any way for the child actor to get its parent address ? At the moment I must introduce a “Setup” or “Initialize” message in my code and utilize “sender”. But I guess there is some other way.

If there is no such feature, then my question is: why ? Previously I’ve been using Akka for Scala, and there is such possibility, so I assume it makes some sense from the actors model POV.

I will appreciate any answer .

Scony avatar Apr 19 '17 16:04 Scony

That information is currently not exposed to the Actor itself, so your methodology of a message send from the parent is the recommended Thespian solution.

There is no fundamental reason for not providing this to the Actor other than simplicity. Most of the scenarios I've encountered to-date where the child needed to know the parent's address also involved passing some information from the parent to the child, so an initial message was needed anyhow.

kquick avatar Apr 19 '17 17:04 kquick

Well, thank you for explanations.

I think you may consider adding such feature in the future. It may be very beneficial for the users. The present situation may be a bit confusing, because a child actor actually has no link to its parent as long as it doesn't receive any message form it. Also - from the child actor perspective - how do you know that the "Setup" message came from the parent ? Or even any message ? Without knowing your parent's address you don't know. The only solution that comes to my mind is to ensure that the first message always comes from the parent. Then you can store it and use it. But during writing tests one may accidentally forgot about this constraint and cause some harm. Also, this seem to put pressure on the thespian lib client as he is forced to write extra code.

Scony avatar Apr 19 '17 19:04 Scony

Thank you! I appreciate the suggestion and I will look into adding this as a feature in the near future.

-Kevin

Pawel Lampe writes:

Well, thank you for explanations.

I think you may consider adding such feature in the future. It may be very beneficial for the users. The present situation may be a bit confusing, because a child actor actually has no link to its parent as long as it doesn't receive any message form it. Also - from the child actor perspective - how do you know that the "Setup" message came from the parent ? Or even any message ? Without knowing your parent's address you don't know. The only solution that comes to my mind is to ensure that the first message always comes from the parent. Then you can store it and use it. But during writing a tests one may accidentally forgot about this constraint and cause some harm. Also, this seem to put pressure on the thespian lib client as he is forced to write extra code.

kquick avatar Apr 20 '17 05:04 kquick

I am agree, this feature will be useful.

andreikee avatar Oct 26 '20 21:10 andreikee