Skip to content
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

Actor subscribe to event stream #66

Closed
noahsilverman opened this issue Nov 28, 2023 · 7 comments · Fixed by #101
Closed

Actor subscribe to event stream #66

noahsilverman opened this issue Nov 28, 2023 · 7 comments · Fixed by #101
Assignees

Comments

@noahsilverman
Copy link

It would be awesome if any actor could subscribe to the global event stream This could become a nice broadcast/signalling channel for all running children.

The challenge is: how to access it.

In the eventStream example, the code subscribes directly to the event stream by calling a function of the engine. However, a child only knows its own PID, and does not have direct access to the engine.

One awkward way would be to subscribe when the Receiver gets a started message:

func (state *a) Receive(ctx *actor.Context) {

	switch msg := ctx.Message().(type) {

	case *actor.Started:
		ctx.Engine().EventStream.Subscribe(...)
}

Is this good enough, or do we want something more specific?

@anthdm
Copy link
Owner

anthdm commented Nov 28, 2023

@noahsilverman Do you mean that you want the event stream to be available on every actor magically, without subscribing to it first?

@noahsilverman
Copy link
Author

@anthdm Not magically. I Just thought it would be nice if there was an easy (or direct) way for any actor to subscribe or publish to eventStream.

When I've built actor-based systems in Erlang, I always had some kind of global notification process running. So, any actor could publish "announcement", and any actor could optionally listen for global events.

Subscribing, during the actor.Started message, works. But feels a bit awkward.

@anthdm
Copy link
Owner

anthdm commented Nov 29, 2023

@noahsilverman I understand what you are saying. Let me think of a good way to handle that.

@noahsilverman
Copy link
Author

Please let me know if I can help

@anthdm
Copy link
Owner

anthdm commented Dec 3, 2023

@noahsilverman I just did a major refactor on how event stream is going to work in the future. Its already merged in master. Still need to write documentation about it, though. Keep an eye on the docs. Will leave this issue open until that is done.

@perbu
Copy link
Collaborator

perbu commented Dec 7, 2023

I have a resonably good grip on this. I'll make sure it is documented.

@perbu perbu self-assigned this Dec 7, 2023
@perbu
Copy link
Collaborator

perbu commented Dec 9, 2023

@noahsilverman could you review the PR mentioned above and see if you think I've hit the spot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants