-
Notifications
You must be signed in to change notification settings - Fork 235
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
Execute arbitrary function when DHT message is received #331
Comments
I'm now thinking about implementing a datastore which maintains a set of handler functions that are triggered when |
Hey @gpestana! I think the key question here is whether you want values to be transformed or not. In other words, could we satisfy this requirement with an event bus where the DHT and other components publish events to notify of others of what's happening? Components like yours could subscribe to certain event types and react to those. Or were you looking to modify the data that's actually being stored in the local view of the DHT? This would be pretty unsafe. |
An event pipeline would be great, since the idea is not to change the protocol itself but to augment it. Are there any plans/discussions for implementing such event bus? |
We've discussed some of this in libp2p/go-libp2p#467 which is mostly about the service-based host abstraction. @vyzo is putting together a technical description and proposal. The eventbus will come at a later stage, although with the go-libp2p-core refactor, it could be moved forward because one no longer depends on the other. Is this something you'd like to hack on? ;-) |
yeah, definitely. I'd love to see this feature in since I've got a couple of ideas for integrating p3lib with libp2p that could use something like the event bus! |
As a developer I'd like to execute arbitrary functions when a host receives a dht message. For example, when the node processes an incoming
GET_VALUE
message, I'd like to spawn a new go routine alongsidehandleGetValue(...)
.I can't think of any way of doing this without changing the current handlers logic to accept a channel that accepts events that can be handled in the main go routine. This solution feels a bit clumsy and probably adds unnecessary complexity for a 'niche' case. But on the other hand, that feature would be nice for developers who need to develop protocols based on the dht node's behaviour.
Any suggestions/thoughts about this?
edit
For context, I'd like to implement a MVP of a coin flipping request delegation to work with libp2p, something like this: gpestana/notes#23
The text was updated successfully, but these errors were encountered: