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

Make 'BasicHost.emitters.evtLocalAddrsUpdated' stateful. #1145

Closed
lthibault opened this issue Jul 31, 2021 · 4 comments · Fixed by #1147
Closed

Make 'BasicHost.emitters.evtLocalAddrsUpdated' stateful. #1145

lthibault opened this issue Jul 31, 2021 · 4 comments · Fixed by #1147

Comments

@lthibault
Copy link
Contributor

Problem

Currently, subscribing to event.EvtLocalAddrsUpdated is not stateful, meaning that subscribers will miss the initial set of addresses emitted during host initialization.

While not a huge deal (we can just call h.Addrs()), this requires additional initialization outside of the subscription logic. This is kind of annoying; I would much prefer to write:

for addrsChanged := range sub.Out() {
    do_something(addrsChanged)
}

Currently, I have to write something akin to setup(h.Addrs()) somewhere else.

Solution

The solution is to pass eventbus.Stateful to the emitter's constructor, here.

Is this doable, or will it break something? I'm happy to submit a PR if this is pre-approved in principle.

@Stebalien
Copy link
Member

Stebalien commented Aug 1, 2021 via email

@lthibault
Copy link
Contributor Author

Perfect! I'll have a patch ready shortly.

@lthibault
Copy link
Contributor Author

@Stebalien See #1147.

Do you think it's worth making EvtEvtLocalProtocolsUpdated stateful as well?

@Stebalien
Copy link
Member

Not really. The addresses one makes sense (somewhat) because it has includes all addresses. The protocols one is just for protocol updates.

I say somewhat for the addresses one because ideally it wouldn't return "removed" addresses in the first event.

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.

2 participants