Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Dec 2, 2024

  • Add new method Dispatcher.refresh() to fetch latest dispatches

@Marenz Marenz requested a review from a team as a code owner December 2, 2024 13:58
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:actor Affects the dispatching actor part:dispatcher Affects the high-level dispatcher interface labels Dec 2, 2024
@Marenz Marenz marked this pull request as draft December 2, 2024 14:18
@Marenz Marenz marked this pull request as ready for review December 2, 2024 14:26
Copy link
Contributor

@llucax llucax left a 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()
Copy link
Contributor

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.

Copy link
Contributor

@ela-kotulska-frequenz ela-kotulska-frequenz Dec 3, 2024

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?

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@Marenz Marenz Dec 3, 2024

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

Copy link
Contributor

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

@Marenz
Copy link
Contributor Author

Marenz commented Dec 3, 2024

Closing in favor of #86

@Marenz Marenz closed this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:actor Affects the dispatching actor part:dispatcher Affects the high-level dispatcher interface part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants