-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Don't add supervisor more than once. #9962
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
Conversation
| final def ++[B](that: Supervisor[B]): Supervisor[(A, B)] = | ||
| Supervisor.Zip(self, that) |
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.
I don't think you need patchAdd - we should just change the behavior of ++.
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.
Yep, we can, but it that requires making the return type Supervisor[Any]. While nothing in ZIO seems to actually use the returned tuple, it's a public API so we can't change it now.
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.
@quelgar this method is still being used in 2 places:
zio/core/shared/src/main/scala/zio/ZIO.scala
Line 2040 in c6f342e
FiberRef.currentSupervisor.locallyWith(_ ++ supervisor)(self) case Zip(left, right) => removeSupervisor(left, that) ++ removeSupervisor(right, that)
The second one I'm not sure we need to change it but the first one definitely.
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.
Yep changed the first one, thanks.
For the second, yeah it's not actually adding anything, it's just rebuilding based on the existing graph, so no need to change it 👍 .
kyri-petrou
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, just a minor comment
| final def ++[B](that: Supervisor[B]): Supervisor[(A, B)] = | ||
| Supervisor.Zip(self, that) |
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.
@quelgar this method is still being used in 2 places:
zio/core/shared/src/main/scala/zio/ZIO.scala
Line 2040 in c6f342e
FiberRef.currentSupervisor.locallyWith(_ ++ supervisor)(self) case Zip(left, right) => removeSupervisor(left, that) ++ removeSupervisor(right, that)
The second one I'm not sure we need to change it but the first one definitely.
b4b6937 to
0678ec6
Compare
See #9668 for rationale.
This adds
Supervisor#addPatchthat works the same as++except: if the supervisor to be added is already present, the current supervisor is returned unchanged. This is used to implementAddSupervisorpatching, so that complex layer graphs never result in a supervisor being added more than once.@kyri-petrou please take a look at your convenience.