-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: allowing configuration of application level callbacks #3206
Conversation
You can find the image built from this PR at
Built from 8b2241a |
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.
Thanks so much for it! I like the concept very much but I think we need to address a couple of minor details :)
Nice PR! 🥳
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.
Would set_event_callback
stil lbe necessary with this new AppCallbacks
feature?
My understanding is that it is still necessary because there's two type of callbacks - the callbacks at the nwaku's application level which in libwaku we use to emit events (the type of callback of this PR), and a callback defined at libwaku's client to handle all these events emitted by the application level callbacks. Or in other words the callbacks of this PR are run whenever something in nwaku happens, for example when a Relay message is received. Let me know if I might be missing something or if you think of a way to simplify this structure :) |
Description
We noticed that libwaku doesn't automatically configure a callback for receiving Relay messages when creating a node. Currently, the user has to manually subscribe to each topic providing their callback.
In order to make libwaku more user friendly, we need to be able to register all the event-emitting callbacks automatically when creating a node. Therefore, I added a
WakuCallbacks
type where a user can pass all the different callbacks they need when creating a node. Currently, onlyrelayHandler
is defined in the type, but in a following PRs new callbacks will be added (for example, a callback that runs every time a topic health changes)Changes
WakuCallbacks
type for application-level callbackssetupCallbacks
procedure that adds the configuredWakuCallbacks
Waku.new()
to acceptWakuCallbacks
and properly set them upcallbacks
parameter to libwaku'screateWaku
so we can configure in node creation all the event-emitting callbacksIssue
#3076