-
Couldn't load subscription status.
- Fork 6
Add Dispatcher.refresh() method #81
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
Signed-off-by: Mathias L. Baumann <[email protected]>
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.
Why do we need this? I guess it is only for disaster recovery as normally the dispatcher should be always up to date, or is the steam-based update now available yet?
|
|
||
| async def refresh(self) -> None: | ||
| """Re-fetch all dispatches.""" | ||
| await self._actor.fetch() |
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 this is a good idea Design-wise. The idea is to only communicate with actors via channels once they are created. Maybe for this case is overkill, at least until we can really distribute actors in other processes/nodes, and if that is the case ok, but I would leave it as a private method and just add an ignore and a comment saying this is a hack.
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.
Right thanks! My use case:
I have an actor that uses Dispacher.
When Dispacher starts (For the first time) it sends all dispaches and I receive them.
If my actor crashes and restarts latest dispaches are not send. And this is understandable because dispacher doesn't know that I restarted.
Another solution would be to create new dispacher on every restart. Would it be ok?
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.
Just to clarify, as you commented in this review comment, I'm only referring to the call to the actor inside refresh(), adding refresh() itself is OK because Dispatcher is just a class that uses an actor underneath (and the class instance should always be local, only the actor might be in another process/node).
That said, yeah, I think if it crashes it should be OK to re-create, it shouldn't happen all the time anyway.
But I don't oppose to this addition, I think things could go wrong and having a way to force a refresh could still be useful in some cases. But maybe we should add some sort of Warning if refresh() is not really intended to be used in normal conditions, just to avoid confusion or people thinking they need to actively refresh the dispatcher instance.
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.
BTW, the dispatcher should be instantiated by the app, not an actor, right? We should have only one dispatcher for the whole app/all actors, no?
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.
BTW, the dispatcher should be instantiated by the app, not an actor, right? We should have only one dispatcher for the whole app/all actors, no?
good point, yes
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.
Ok, I will think and redesign my use case... Sorry
|
Closing in favor of #86 |
Uh oh!
There was an error while loading. Please reload this page.