-
Notifications
You must be signed in to change notification settings - Fork 2
add option funcs to WakuNode, add extraOptions to pass arbitrary config to nwaku #50
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
base: master
Are you sure you want to change the base?
Conversation
4d63acc to
d7da6d6
Compare
gabrielmer
left a comment
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! Just added a small question :))
| for _, o := range opts { | ||
| o(n) | ||
| } |
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.
what does this do? not sure I follow it
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.
Which is why I provided a link to the article in the description: https://golang.cafe/blog/golang-functional-options-pattern.html
TL;DR: It allows you to define and passing functions that get called automatically which adds more flexibility to configuration than a custom struct - same approach has been used in go-waku (https://github.com/waku-org/go-waku/blob/master/waku/v2/node/wakuoptions.go#L135), so then you end up with something like:
NewNode(something,
WithTimeout(..),
WithRLN(...),
WIthGabrielsBrain(...),
...
)
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.
Oooh makes sense! Thanks so much! 🤩
Ivansete-status
left a comment
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.
LGTM! Thanks for it! 💯
Maybe interesting to add a simple unit test showing how to use it
I am just not sure what the test should test:-) Like how do I "prove" the node is configured properly with that extra config? I am open to suggestions:-) |
Co-authored-by: Ivan FB <[email protected]>
ah yes good point hehe ^^' |
WakuNodeExtraOptions- a map ofstring -> interface{}of options allowing to configure any of nwaku config optionsExample:
This will configure given URL as RLN RPC for nwaku